OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_OPERATION_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // the class. It's expecting a pointer to a singleton. | 50 // the class. It's expecting a pointer to a singleton. |
51 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, | 51 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, |
52 scoped_refptr<base::MessageLoopProxy> proxy, | 52 scoped_refptr<base::MessageLoopProxy> proxy, |
53 FileSystemContext* file_system_context, | 53 FileSystemContext* file_system_context, |
54 FileSystemFileUtil* file_system_file_util); | 54 FileSystemFileUtil* file_system_file_util); |
55 virtual ~FileSystemOperation(); | 55 virtual ~FileSystemOperation(); |
56 | 56 |
57 void OpenFileSystem(const GURL& origin_url, | 57 void OpenFileSystem(const GURL& origin_url, |
58 fileapi::FileSystemType type, | 58 fileapi::FileSystemType type, |
59 bool create); | 59 bool create); |
60 void CreateFile(const FilePath& path, | 60 void CreateFile(const GURL& path, |
61 bool exclusive); | 61 bool exclusive); |
62 void CreateDirectory(const FilePath& path, | 62 void CreateDirectory(const GURL& path, |
63 bool exclusive, | 63 bool exclusive, |
64 bool recursive); | 64 bool recursive); |
65 void Copy(const FilePath& src_path, | 65 void Copy(const GURL& src_path, |
66 const FilePath& dest_path); | 66 const GURL& dest_path); |
67 void Move(const FilePath& src_path, | 67 void Move(const GURL& src_path, |
68 const FilePath& dest_path); | 68 const GURL& dest_path); |
69 void DirectoryExists(const FilePath& path); | 69 void DirectoryExists(const GURL& path); |
70 void FileExists(const FilePath& path); | 70 void FileExists(const GURL& path); |
71 void GetMetadata(const FilePath& path); | 71 void GetMetadata(const GURL& path); |
72 void ReadDirectory(const FilePath& path); | 72 void ReadDirectory(const GURL& path); |
73 void Remove(const FilePath& path, bool recursive); | 73 void Remove(const GURL& path, bool recursive); |
74 void Write(scoped_refptr<net::URLRequestContext> url_request_context, | 74 void Write(scoped_refptr<net::URLRequestContext> url_request_context, |
75 const FilePath& path, | 75 const GURL& path, |
76 const GURL& blob_url, | 76 const GURL& blob_url, |
77 int64 offset); | 77 int64 offset); |
78 void Truncate(const FilePath& path, int64 length); | 78 void Truncate(const GURL& path, int64 length); |
79 void TouchFile(const FilePath& path, | 79 void TouchFile(const GURL& path, |
80 const base::Time& last_access_time, | 80 const base::Time& last_access_time, |
81 const base::Time& last_modified_time); | 81 const base::Time& last_modified_time); |
82 | 82 |
83 // Try to cancel the current operation [we support cancelling write or | 83 // Try to cancel the current operation [we support cancelling write or |
84 // truncate only]. Report failure for the current operation, then tell the | 84 // truncate only]. Report failure for the current operation, then tell the |
85 // passed-in operation to report success. | 85 // passed-in operation to report success. |
86 void Cancel(FileSystemOperation* cancel_operation); | 86 void Cancel(FileSystemOperation* cancel_operation); |
87 | 87 |
88 private: | 88 private: |
89 FileSystemContext* file_system_context() const { | 89 FileSystemContext* file_system_context() const { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 base::PassPlatformFile file, | 135 base::PassPlatformFile file, |
136 bool created); | 136 bool created); |
137 | 137 |
138 // Checks the validity of a given |path| for reading, and cracks the path into | 138 // Checks the validity of a given |path| for reading, and cracks the path into |
139 // root URL and virtual path components. | 139 // root URL and virtual path components. |
140 // Returns true if the given |path| is a valid FileSystem path. | 140 // Returns true if the given |path| is a valid FileSystem path. |
141 // Otherwise it calls dispatcher's DidFail method with | 141 // Otherwise it calls dispatcher's DidFail method with |
142 // PLATFORM_FILE_ERROR_SECURITY and returns false. | 142 // PLATFORM_FILE_ERROR_SECURITY and returns false. |
143 // (Note: this doesn't delete this when it calls DidFail and returns false; | 143 // (Note: this doesn't delete this when it calls DidFail and returns false; |
144 // it's the caller's responsibility.) | 144 // it's the caller's responsibility.) |
145 bool VerifyFileSystemPathForRead(const FilePath& path, | 145 bool VerifyFileSystemPathForRead(const GURL& path, |
146 GURL* root_url, | 146 GURL* root_url, |
147 FileSystemType* type, | 147 FileSystemType* type, |
148 FilePath* virtual_path); | 148 FilePath* virtual_path); |
149 | 149 |
150 // Checks the validity of a given |path| for writing, and cracks the path into | 150 // Checks the validity of a given |path| for writing, and cracks the path into |
151 // root URL and virtual path components. | 151 // root URL and virtual path components. |
152 // Returns true if the given |path| is a valid FileSystem path, and | 152 // Returns true if the given |path| is a valid FileSystem path, and |
153 // its origin embedded in the path has the right to write. | 153 // its origin embedded in the path has the right to write. |
154 // Otherwise it fires dispatcher's DidFail method with | 154 // Otherwise it fires dispatcher's DidFail method with |
155 // PLATFORM_FILE_ERROR_SECURITY if the path is not valid for writing, | 155 // PLATFORM_FILE_ERROR_SECURITY if the path is not valid for writing, |
156 // or with PLATFORM_FILE_ERROR_NO_SPACE if the origin is not allowed to | 156 // or with PLATFORM_FILE_ERROR_NO_SPACE if the origin is not allowed to |
157 // write to the storage. | 157 // write to the storage. |
158 // In either case it returns false after firing DidFail. | 158 // In either case it returns false after firing DidFail. |
159 // If |create| flag is true this also checks if the |path| contains | 159 // If |create| flag is true this also checks if the |path| contains |
160 // any restricted names and chars. If it does, the call fires dispatcher's | 160 // any restricted names and chars. If it does, the call fires dispatcher's |
161 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. | 161 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. |
162 // (Note: this doesn't delete this when it calls DidFail and returns false; | 162 // (Note: this doesn't delete this when it calls DidFail and returns false; |
163 // it's the caller's responsibility.) | 163 // it's the caller's responsibility.) |
164 bool VerifyFileSystemPathForWrite(const FilePath& path, | 164 bool VerifyFileSystemPathForWrite(const GURL& path, |
165 bool create, | 165 bool create, |
166 GURL* root_url, | 166 GURL* root_url, |
167 FileSystemType* type, | 167 FileSystemType* type, |
168 FilePath* virtual_path); | 168 FilePath* virtual_path); |
169 | 169 |
170 #ifndef NDEBUG | 170 #ifndef NDEBUG |
171 enum OperationType { | 171 enum OperationType { |
172 kOperationNone, | 172 kOperationNone, |
173 kOperationOpenFileSystem, | 173 kOperationOpenFileSystem, |
174 kOperationCreateFile, | 174 kOperationCreateFile, |
(...skipping 29 matching lines...) Expand all Loading... |
204 scoped_ptr<FileWriterDelegate> file_writer_delegate_; | 204 scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
205 scoped_ptr<net::URLRequest> blob_request_; | 205 scoped_ptr<net::URLRequest> blob_request_; |
206 scoped_ptr<FileSystemOperation> cancel_operation_; | 206 scoped_ptr<FileSystemOperation> cancel_operation_; |
207 | 207 |
208 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); | 208 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); |
209 }; | 209 }; |
210 | 210 |
211 } // namespace fileapi | 211 } // namespace fileapi |
212 | 212 |
213 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 213 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
OLD | NEW |