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