| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // This class is designed to serve one-time file system operation per instance. | 43 // This class is designed to serve one-time file system operation per instance. |
| 44 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, | 44 // Only one method(CreateFile, CreateDirectory, Copy, Move, DirectoryExists, |
| 45 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of | 45 // GetMetadata, ReadDirectory and Remove) may be called during the lifetime of |
| 46 // this object and it should be called no more than once. | 46 // this object and it should be called no more than once. |
| 47 // This class is self-destructed and an instance automatically gets deleted | 47 // This class is self-destructed and an instance automatically gets deleted |
| 48 // when its operation is finished. | 48 // when its operation is finished. |
| 49 class FileSystemOperation { | 49 class FileSystemOperation { |
| 50 public: | 50 public: |
| 51 // |dispatcher| will be owned by this class. | 51 // |dispatcher| will be owned by this class. |
| 52 // |file_system_file_util| is optional; if supplied, it will not be deleted by | 52 // |file_util| is optional; if supplied, it will not be deleted by |
| 53 // the class. It's expecting a pointer to a singleton. | 53 // the class. It's expecting a pointer to a singleton. |
| 54 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, | 54 FileSystemOperation(FileSystemCallbackDispatcher* dispatcher, |
| 55 scoped_refptr<base::MessageLoopProxy> proxy, | 55 scoped_refptr<base::MessageLoopProxy> proxy, |
| 56 FileSystemContext* file_system_context, | 56 FileSystemContext* file_system_context, |
| 57 FileSystemFileUtil* file_system_file_util); | 57 FileSystemFileUtil* file_util); |
| 58 virtual ~FileSystemOperation(); | 58 virtual ~FileSystemOperation(); |
| 59 | 59 |
| 60 void OpenFileSystem(const GURL& origin_url, | 60 void OpenFileSystem(const GURL& origin_url, |
| 61 fileapi::FileSystemType type, | 61 fileapi::FileSystemType type, |
| 62 bool create); | 62 bool create); |
| 63 void CreateFile(const GURL& path, | 63 void CreateFile(const GURL& path, |
| 64 bool exclusive); | 64 bool exclusive); |
| 65 void CreateDirectory(const GURL& path, | 65 void CreateDirectory(const GURL& path, |
| 66 bool exclusive, | 66 bool exclusive, |
| 67 bool recursive); | 67 bool recursive); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // FileSystemFileUtil subclass for this type. | 177 // FileSystemFileUtil subclass for this type. |
| 178 // Returns true if the given |path| is a valid FileSystem path. | 178 // Returns true if the given |path| is a valid FileSystem path. |
| 179 // Otherwise it calls dispatcher's DidFail method with | 179 // Otherwise it calls dispatcher's DidFail method with |
| 180 // PLATFORM_FILE_ERROR_SECURITY and returns false. | 180 // PLATFORM_FILE_ERROR_SECURITY and returns false. |
| 181 // (Note: this doesn't delete this when it calls DidFail and returns false; | 181 // (Note: this doesn't delete this when it calls DidFail and returns false; |
| 182 // it's the caller's responsibility.) | 182 // it's the caller's responsibility.) |
| 183 bool VerifyFileSystemPathForRead(const GURL& path, | 183 bool VerifyFileSystemPathForRead(const GURL& path, |
| 184 GURL* root_url, | 184 GURL* root_url, |
| 185 FileSystemType* type, | 185 FileSystemType* type, |
| 186 FilePath* virtual_path, | 186 FilePath* virtual_path, |
| 187 FileSystemFileUtil** file_system_file_util); | 187 FileSystemFileUtil** file_util); |
| 188 | 188 |
| 189 // Checks the validity of a given |path| for writing, cracks the path into | 189 // Checks the validity of a given |path| for writing, cracks the path into |
| 190 // root URL and virtual path components, and returns the correct | 190 // root URL and virtual path components, and returns the correct |
| 191 // FileSystemFileUtil subclass for this type. | 191 // FileSystemFileUtil subclass for this type. |
| 192 // Returns true if the given |path| is a valid FileSystem path, and | 192 // Returns true if the given |path| is a valid FileSystem path, and |
| 193 // its origin embedded in the path has the right to write. | 193 // its origin embedded in the path has the right to write. |
| 194 // Otherwise it fires dispatcher's DidFail method with | 194 // Otherwise it fires dispatcher's DidFail method with |
| 195 // PLATFORM_FILE_ERROR_SECURITY if the path is not valid for writing, | 195 // PLATFORM_FILE_ERROR_SECURITY if the path is not valid for writing, |
| 196 // or with PLATFORM_FILE_ERROR_NO_SPACE if the origin is not allowed to | 196 // or with PLATFORM_FILE_ERROR_NO_SPACE if the origin is not allowed to |
| 197 // write to the storage. | 197 // write to the storage. |
| 198 // In either case it returns false after firing DidFail. | 198 // In either case it returns false after firing DidFail. |
| 199 // If |create| flag is true this also checks if the |path| contains | 199 // If |create| flag is true this also checks if the |path| contains |
| 200 // any restricted names and chars. If it does, the call fires dispatcher's | 200 // any restricted names and chars. If it does, the call fires dispatcher's |
| 201 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. | 201 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. |
| 202 // (Note: this doesn't delete this when it calls DidFail and returns false; | 202 // (Note: this doesn't delete this when it calls DidFail and returns false; |
| 203 // it's the caller's responsibility.) | 203 // it's the caller's responsibility.) |
| 204 bool VerifyFileSystemPathForWrite(const GURL& path, | 204 bool VerifyFileSystemPathForWrite(const GURL& path, |
| 205 bool create, | 205 bool create, |
| 206 GURL* root_url, | 206 GURL* root_url, |
| 207 FileSystemType* type, | 207 FileSystemType* type, |
| 208 FilePath* virtual_path, | 208 FilePath* virtual_path, |
| 209 FileSystemFileUtil** file_system_file_util); | 209 FileSystemFileUtil** file_util); |
| 210 | 210 |
| 211 #ifndef NDEBUG | 211 #ifndef NDEBUG |
| 212 enum OperationType { | 212 enum OperationType { |
| 213 kOperationNone, | 213 kOperationNone, |
| 214 kOperationOpenFileSystem, | 214 kOperationOpenFileSystem, |
| 215 kOperationCreateFile, | 215 kOperationCreateFile, |
| 216 kOperationCreateDirectory, | 216 kOperationCreateDirectory, |
| 217 kOperationCopy, | 217 kOperationCopy, |
| 218 kOperationMove, | 218 kOperationMove, |
| 219 kOperationDirectoryExists, | 219 kOperationDirectoryExists, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 // Length to be truncated. | 270 // Length to be truncated. |
| 271 int64 length_; | 271 int64 length_; |
| 272 | 272 |
| 273 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); | 273 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); |
| 274 }; | 274 }; |
| 275 | 275 |
| 276 } // namespace fileapi | 276 } // namespace fileapi |
| 277 | 277 |
| 278 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 278 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |