[email protected] | 4c03b2e9 | 2012-01-03 19:36:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| 6 | #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| 7 | |
| 8 | #include <vector> |
| 9 | |
| 10 | #include "base/callback.h" |
| 11 | #include "base/file_path.h" |
| 12 | #include "base/file_util_proxy.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 14 | #include "base/platform_file.h" |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 15 | #include "base/tracked_objects.h" |
| 16 | |
| 17 | namespace base { |
| 18 | class MessageLoopProxy; |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | namespace fileapi { |
| 22 | |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 23 | using base::MessageLoopProxy; |
| 24 | using base::PlatformFile; |
[email protected] | bacef3c | 2011-03-28 22:26:50 | [diff] [blame] | 25 | using base::PlatformFileError; |
| 26 | using base::PlatformFileInfo; |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 27 | |
[email protected] | fea88cd | 2011-11-09 06:57:30 | [diff] [blame] | 28 | // This class provides relay methods for supporting asynchronous access to |
| 29 | // FileSystem API operations. (Most of necessary relay methods are provided |
| 30 | // by base::FileUtilProxy, but there are a few operations that are not |
| 31 | // covered or are slightly different from the version of base::FileUtilProxy. |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 32 | class FileSystemFileUtilProxy { |
| 33 | public: |
[email protected] | 0a3bd7e | 2011-10-19 07:21:57 | [diff] [blame] | 34 | typedef base::FileUtilProxy::Entry Entry; |
| 35 | |
[email protected] | 0a3bd7e | 2011-10-19 07:21:57 | [diff] [blame] | 36 | typedef base::Callback<void(PlatformFileError, |
| 37 | bool /* created */ |
| 38 | )> EnsureFileExistsCallback; |
| 39 | typedef base::Callback<void(PlatformFileError, |
| 40 | const PlatformFileInfo&, |
| 41 | const FilePath& /* platform_path */ |
| 42 | )> GetFileInfoCallback; |
| 43 | typedef base::Callback<void(PlatformFileError, |
[email protected] | bf48bed | 2012-02-24 20:49:07 | [diff] [blame^] | 44 | const std::vector<Entry>&, |
| 45 | bool has_more)> ReadDirectoryCallback; |
[email protected] | 0a3bd7e | 2011-10-19 07:21:57 | [diff] [blame] | 46 | |
[email protected] | fea88cd | 2011-11-09 06:57:30 | [diff] [blame] | 47 | typedef base::Callback<PlatformFileError(bool* /* created */ |
| 48 | )> EnsureFileExistsTask; |
| 49 | typedef base::Callback<PlatformFileError(PlatformFileInfo*, |
| 50 | FilePath*)> GetFileInfoTask; |
| 51 | typedef base::Callback<PlatformFileError(std::vector<Entry>* |
| 52 | )> ReadDirectoryTask; |
| 53 | |
| 54 | // Calls EnsureFileExistsTask |task| on the given |message_loop_proxy|. |
| 55 | static bool RelayEnsureFileExists( |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 56 | scoped_refptr<MessageLoopProxy> message_loop_proxy, |
[email protected] | fea88cd | 2011-11-09 06:57:30 | [diff] [blame] | 57 | const EnsureFileExistsTask& task, |
[email protected] | f1ef8d4 | 2011-10-17 19:39:59 | [diff] [blame] | 58 | const EnsureFileExistsCallback& callback); |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 59 | |
[email protected] | fea88cd | 2011-11-09 06:57:30 | [diff] [blame] | 60 | // Calls GetFileInfoTask |task| on the given |message_loop_proxy|. |
| 61 | static bool RelayGetFileInfo( |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 62 | scoped_refptr<MessageLoopProxy> message_loop_proxy, |
[email protected] | fea88cd | 2011-11-09 06:57:30 | [diff] [blame] | 63 | const GetFileInfoTask& task, |
[email protected] | 0f695a7 | 2011-10-17 20:12:05 | [diff] [blame] | 64 | const GetFileInfoCallback& callback); |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 65 | |
[email protected] | fea88cd | 2011-11-09 06:57:30 | [diff] [blame] | 66 | // Calls ReadDirectoryTask |task| on the given |message_loop_proxy|. |
| 67 | // TODO: this should support returning entries in multiple chunks. |
| 68 | static bool RelayReadDirectory( |
| 69 | scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 70 | const ReadDirectoryTask& task, |
| 71 | const ReadDirectoryCallback& callback); |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 72 | |
[email protected] | d5233ef4 | 2011-03-04 04:14:04 | [diff] [blame] | 73 | private: |
| 74 | DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
| 75 | }; |
| 76 | |
| 77 | } // namespace fileapi |
| 78 | |
| 79 | #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |