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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 typedef FileSystemOperationInterface::ReadDirectoryCallback | 43 typedef FileSystemOperationInterface::ReadDirectoryCallback |
44 ReadDirectoryCallback; | 44 ReadDirectoryCallback; |
45 | 45 |
46 typedef base::Callback< | 46 typedef base::Callback< |
47 void(base::PlatformFileError result, | 47 void(base::PlatformFileError result, |
48 const base::PlatformFileInfo& file_info, | 48 const base::PlatformFileInfo& file_info, |
49 const FilePath& platform_path, | 49 const FilePath& platform_path, |
50 FileSystemFileUtil::SnapshotFilePolicy snapshot_policy)> | 50 FileSystemFileUtil::SnapshotFilePolicy snapshot_policy)> |
51 SnapshotFileCallback; | 51 SnapshotFileCallback; |
52 | 52 |
53 // Deletes a file or a directory on the given context's file_task_runner. | 53 // Deletes a file or a directory on the given context's task_runner. |
54 // It is an error to delete a non-empty directory with recursive=false. | 54 // It is an error to delete a non-empty directory with recursive=false. |
55 static bool Delete( | 55 static bool Delete( |
56 FileSystemOperationContext* context, | 56 FileSystemOperationContext* context, |
57 FileSystemFileUtil* file_util, | 57 FileSystemFileUtil* file_util, |
58 const FileSystemURL& url, | 58 const FileSystemURL& url, |
59 bool recursive, | 59 bool recursive, |
60 const StatusCallback& callback); | 60 const StatusCallback& callback); |
61 | 61 |
62 // Creates or opens a file with the given flags by calling |file_util|'s | 62 // Creates or opens a file with the given flags by calling |file_util|'s |
63 // CreateOrOpen method on the given context's file_task_runner. | 63 // CreateOrOpen method on the given context's task_runner. |
64 static bool CreateOrOpen( | 64 static bool CreateOrOpen( |
65 FileSystemOperationContext* context, | 65 FileSystemOperationContext* context, |
66 FileSystemFileUtil* file_util, | 66 FileSystemFileUtil* file_util, |
67 const FileSystemURL& url, | 67 const FileSystemURL& url, |
68 int file_flags, | 68 int file_flags, |
69 const CreateOrOpenCallback& callback); | 69 const CreateOrOpenCallback& callback); |
70 | 70 |
71 // Copies a file or a directory from |src_url| to |dest_url| by calling | 71 // Copies a file or a directory from |src_url| to |dest_url| by calling |
72 // FileSystemFileUtil's following methods on the given context's | 72 // FileSystemFileUtil's following methods on the given context's |
73 // file_task_runner. | 73 // task_runner. |
74 // - CopyOrMoveFile() for same-filesystem operations | 74 // - CopyOrMoveFile() for same-filesystem operations |
75 // - CopyInForeignFile() for (limited) cross-filesystem operations | 75 // - CopyInForeignFile() for (limited) cross-filesystem operations |
76 // | 76 // |
77 // Error cases: | 77 // Error cases: |
78 // If destination's parent doesn't exist. | 78 // If destination's parent doesn't exist. |
79 // If source dir exists but destination url is an existing file. | 79 // If source dir exists but destination url is an existing file. |
80 // If source file exists but destination url is an existing directory. | 80 // If source file exists but destination url is an existing directory. |
81 // If source is a parent of destination. | 81 // If source is a parent of destination. |
82 // If source doesn't exist. | 82 // If source doesn't exist. |
83 // If source and dest are the same url in the same filesystem. | 83 // If source and dest are the same url in the same filesystem. |
84 static bool Copy( | 84 static bool Copy( |
85 FileSystemOperationContext* context, | 85 FileSystemOperationContext* context, |
86 FileSystemFileUtil* src_util, | 86 FileSystemFileUtil* src_util, |
87 FileSystemFileUtil* dest_util, | 87 FileSystemFileUtil* dest_util, |
88 const FileSystemURL& src_url, | 88 const FileSystemURL& src_url, |
89 const FileSystemURL& dest_url, | 89 const FileSystemURL& dest_url, |
90 const StatusCallback& callback); | 90 const StatusCallback& callback); |
91 | 91 |
92 // Moves a file or a directory from |src_url| to |dest_url| by calling | 92 // Moves a file or a directory from |src_url| to |dest_url| by calling |
93 // FileSystemFileUtil's following methods on the given context's | 93 // FileSystemFileUtil's following methods on the given context's |
94 // file_task_runner. | 94 // task_runner. |
95 // - CopyOrMoveFile() for same-filesystem operations | 95 // - CopyOrMoveFile() for same-filesystem operations |
96 // - CopyInForeignFile() for (limited) cross-filesystem operations | 96 // - CopyInForeignFile() for (limited) cross-filesystem operations |
97 // | 97 // |
98 // This method returns an error on the same error cases with Copy. | 98 // This method returns an error on the same error cases with Copy. |
99 static bool Move( | 99 static bool Move( |
100 FileSystemOperationContext* context, | 100 FileSystemOperationContext* context, |
101 FileSystemFileUtil* src_util, | 101 FileSystemFileUtil* src_util, |
102 FileSystemFileUtil* dest_util, | 102 FileSystemFileUtil* dest_util, |
103 const FileSystemURL& src_url, | 103 const FileSystemURL& src_url, |
104 const FileSystemURL& dest_url, | 104 const FileSystemURL& dest_url, |
105 const StatusCallback& callback); | 105 const StatusCallback& callback); |
106 | 106 |
107 // Ensures that the given |url| exist by calling |file_util|'s | 107 // Ensures that the given |url| exist by calling |file_util|'s |
108 // EnsureFileExists method on the given context's file_task_runner. | 108 // EnsureFileExists method on the given context's task_runner. |
109 static bool EnsureFileExists( | 109 static bool EnsureFileExists( |
110 FileSystemOperationContext* context, | 110 FileSystemOperationContext* context, |
111 FileSystemFileUtil* file_util, | 111 FileSystemFileUtil* file_util, |
112 const FileSystemURL& url, | 112 const FileSystemURL& url, |
113 const EnsureFileExistsCallback& callback); | 113 const EnsureFileExistsCallback& callback); |
114 | 114 |
115 // Creates directory at a given url by calling |file_util|'s | 115 // Creates directory at a given url by calling |file_util|'s |
116 // CreateDirectory method on the given context's file_task_runner. | 116 // CreateDirectory method on the given context's task_runner. |
117 static bool CreateDirectory( | 117 static bool CreateDirectory( |
118 FileSystemOperationContext* context, | 118 FileSystemOperationContext* context, |
119 FileSystemFileUtil* file_util, | 119 FileSystemFileUtil* file_util, |
120 const FileSystemURL& url, | 120 const FileSystemURL& url, |
121 bool exclusive, | 121 bool exclusive, |
122 bool recursive, | 122 bool recursive, |
123 const StatusCallback& callback); | 123 const StatusCallback& callback); |
124 | 124 |
125 // Retrieves the information about a file by calling |file_util|'s | 125 // Retrieves the information about a file by calling |file_util|'s |
126 // GetFileInfo method on the given context's file_task_runner. | 126 // GetFileInfo method on the given context's task_runner. |
127 static bool GetFileInfo( | 127 static bool GetFileInfo( |
128 FileSystemOperationContext* context, | 128 FileSystemOperationContext* context, |
129 FileSystemFileUtil* file_util, | 129 FileSystemFileUtil* file_util, |
130 const FileSystemURL& url, | 130 const FileSystemURL& url, |
131 const GetFileInfoCallback& callback); | 131 const GetFileInfoCallback& callback); |
132 | 132 |
133 // Creates a snapshot file by calling |file_util|'s CreateSnapshotFile | 133 // Creates a snapshot file by calling |file_util|'s CreateSnapshotFile |
134 // method on the given context's file_task_runner. | 134 // method on the given context's task_runner. |
135 static bool CreateSnapshotFile( | 135 static bool CreateSnapshotFile( |
136 FileSystemOperationContext* context, | 136 FileSystemOperationContext* context, |
137 FileSystemFileUtil* file_util, | 137 FileSystemFileUtil* file_util, |
138 const FileSystemURL& url, | 138 const FileSystemURL& url, |
139 const SnapshotFileCallback& callback); | 139 const SnapshotFileCallback& callback); |
140 | 140 |
141 // Reads the filenames in |url| by calling |file_util|'s | 141 // Reads the filenames in |url| by calling |file_util|'s |
142 // ReadDirectory method on the given context's file_task_runner. | 142 // ReadDirectory method on the given context's task_runner. |
143 // TODO: this should support returning entries in multiple chunks. | 143 // TODO: this should support returning entries in multiple chunks. |
144 static bool ReadDirectory( | 144 static bool ReadDirectory( |
145 FileSystemOperationContext* context, | 145 FileSystemOperationContext* context, |
146 FileSystemFileUtil* file_util, | 146 FileSystemFileUtil* file_util, |
147 const FileSystemURL& url, | 147 const FileSystemURL& url, |
148 const ReadDirectoryCallback& callback); | 148 const ReadDirectoryCallback& callback); |
149 | 149 |
150 // Touches a file by calling |file_util|'s Touch method | 150 // Touches a file by calling |file_util|'s Touch method |
151 // on the given context's file_task_runner. | 151 // on the given context's task_runner. |
152 static bool Touch( | 152 static bool Touch( |
153 FileSystemOperationContext* context, | 153 FileSystemOperationContext* context, |
154 FileSystemFileUtil* file_util, | 154 FileSystemFileUtil* file_util, |
155 const FileSystemURL& url, | 155 const FileSystemURL& url, |
156 const base::Time& last_access_time, | 156 const base::Time& last_access_time, |
157 const base::Time& last_modified_time, | 157 const base::Time& last_modified_time, |
158 const StatusCallback& callback); | 158 const StatusCallback& callback); |
159 | 159 |
160 // Truncates a file to the given length by calling |file_util|'s | 160 // Truncates a file to the given length by calling |file_util|'s |
161 // Truncate method on the given context's file_task_runner. | 161 // Truncate method on the given context's task_runner. |
162 static bool Truncate( | 162 static bool Truncate( |
163 FileSystemOperationContext* context, | 163 FileSystemOperationContext* context, |
164 FileSystemFileUtil* file_util, | 164 FileSystemFileUtil* file_util, |
165 const FileSystemURL& url, | 165 const FileSystemURL& url, |
166 int64 length, | 166 int64 length, |
167 const StatusCallback& callback); | 167 const StatusCallback& callback); |
168 | 168 |
169 private: | 169 private: |
170 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); | 170 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
171 }; | 171 }; |
172 | 172 |
173 } // namespace fileapi | 173 } // namespace fileapi |
174 | 174 |
175 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 175 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
OLD | NEW |