OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util_proxy.h" | 12 #include "base/file_util_proxy.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
15 #include "base/tracked_objects.h" | 15 #include "base/tracked_objects.h" |
| 16 #include "webkit/fileapi/file_system_operation_interface.h" |
16 | 17 |
17 namespace fileapi { | 18 namespace fileapi { |
18 | 19 |
19 using base::PlatformFile; | 20 using base::PlatformFile; |
20 using base::PlatformFileError; | 21 using base::PlatformFileError; |
21 using base::PlatformFileInfo; | 22 using base::PlatformFileInfo; |
22 | 23 |
23 class FileSystemFileUtil; | 24 class FileSystemFileUtil; |
24 class FileSystemOperationContext; | 25 class FileSystemOperationContext; |
25 class FileSystemURL; | 26 class FileSystemURL; |
26 | 27 |
27 // This class provides asynchronous access to FileSystemFileUtil methods for | 28 // This class provides asynchronous access to FileSystemFileUtil methods for |
28 // FileSystem API operations. This also implements cross-FileUtil copy/move | 29 // FileSystem API operations. This also implements cross-FileUtil copy/move |
29 // operations on top of FileSystemFileUtil methods. | 30 // operations on top of FileSystemFileUtil methods. |
30 class FileSystemFileUtilProxy { | 31 class FileSystemFileUtilProxy { |
31 public: | 32 public: |
32 // Some of the proxy routines are just wrapping around the FileUtilProxy's | 33 // Some of the proxy routines are just wrapping around the FileUtilProxy's |
33 // relay methods, so we use the same types as FileUtilProxy for them. | 34 // relay methods, so we use the same types as FileUtilProxy for them. |
34 typedef base::FileUtilProxy::Entry Entry; | 35 typedef base::FileUtilProxy::Entry Entry; |
35 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; | 36 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; |
36 | 37 |
37 typedef base::Callback<void(PlatformFileError status)> StatusCallback; | 38 typedef base::Callback<void(PlatformFileError status)> StatusCallback; |
38 typedef base::Callback<void(PlatformFileError status, | 39 typedef base::Callback<void(PlatformFileError status, |
39 bool created)> EnsureFileExistsCallback; | 40 bool created)> EnsureFileExistsCallback; |
40 typedef base::Callback<void(PlatformFileError status, | 41 typedef FileSystemOperationInterface::GetMetadataCallback GetFileInfoCallback; |
41 const PlatformFileInfo& info, | 42 typedef FileSystemOperationInterface::SnapshotFileCallback |
42 const FilePath& platform_path)> | 43 SnapshotFileCallback; |
43 GetFileInfoCallback; | 44 typedef FileSystemOperationInterface::ReadDirectoryCallback |
44 typedef base::Callback<void(PlatformFileError, | 45 ReadDirectoryCallback; |
45 const std::vector<Entry>&, | |
46 bool has_more)> ReadDirectoryCallback; | |
47 | 46 |
48 // Deletes a file or a directory on the given context's file_task_runner. | 47 // Deletes a file or a directory on the given context's file_task_runner. |
49 // It is an error to delete a non-empty directory with recursive=false. | 48 // It is an error to delete a non-empty directory with recursive=false. |
50 static bool Delete( | 49 static bool Delete( |
51 FileSystemOperationContext* context, | 50 FileSystemOperationContext* context, |
52 FileSystemFileUtil* file_util, | 51 FileSystemFileUtil* file_util, |
53 const FileSystemURL& url, | 52 const FileSystemURL& url, |
54 bool recursive, | 53 bool recursive, |
55 const StatusCallback& callback); | 54 const StatusCallback& callback); |
56 | 55 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const StatusCallback& callback); | 117 const StatusCallback& callback); |
119 | 118 |
120 // Retrieves the information about a file by calling |file_util|'s | 119 // Retrieves the information about a file by calling |file_util|'s |
121 // GetFileInfo method on the given context's file_task_runner. | 120 // GetFileInfo method on the given context's file_task_runner. |
122 static bool GetFileInfo( | 121 static bool GetFileInfo( |
123 FileSystemOperationContext* context, | 122 FileSystemOperationContext* context, |
124 FileSystemFileUtil* file_util, | 123 FileSystemFileUtil* file_util, |
125 const FileSystemURL& url, | 124 const FileSystemURL& url, |
126 const GetFileInfoCallback& callback); | 125 const GetFileInfoCallback& callback); |
127 | 126 |
| 127 // Creates a snapshot file by calling |file_util|'s CreateSnapshotFile |
| 128 // method on the given context's file_task_runner. |
| 129 static bool CreateSnapshotFile( |
| 130 FileSystemOperationContext* context, |
| 131 FileSystemFileUtil* file_util, |
| 132 const FileSystemURL& url, |
| 133 const SnapshotFileCallback& callback); |
| 134 |
128 // Reads the filenames in |url| by calling |file_util|'s | 135 // Reads the filenames in |url| by calling |file_util|'s |
129 // ReadDirectory method on the given context's file_task_runner. | 136 // ReadDirectory method on the given context's file_task_runner. |
130 // TODO: this should support returning entries in multiple chunks. | 137 // TODO: this should support returning entries in multiple chunks. |
131 static bool ReadDirectory( | 138 static bool ReadDirectory( |
132 FileSystemOperationContext* context, | 139 FileSystemOperationContext* context, |
133 FileSystemFileUtil* file_util, | 140 FileSystemFileUtil* file_util, |
134 const FileSystemURL& url, | 141 const FileSystemURL& url, |
135 const ReadDirectoryCallback& callback); | 142 const ReadDirectoryCallback& callback); |
136 | 143 |
137 // Touches a file by calling |file_util|'s Touch method | 144 // Touches a file by calling |file_util|'s Touch method |
(...skipping 15 matching lines...) Expand all Loading... |
153 int64 length, | 160 int64 length, |
154 const StatusCallback& callback); | 161 const StatusCallback& callback); |
155 | 162 |
156 private: | 163 private: |
157 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); | 164 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
158 }; | 165 }; |
159 | 166 |
160 } // namespace fileapi | 167 } // namespace fileapi |
161 | 168 |
162 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 169 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
OLD | NEW |