| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 base::PassPlatformFile file, | 136 base::PassPlatformFile file, |
| 137 bool created); | 137 bool created); |
| 138 | 138 |
| 139 // Checks the validity of a given |path| for reading, and cracks the path into | 139 // Checks the validity of a given |path| for reading, and cracks the path into |
| 140 // root URL and virtual path components. | 140 // root URL and virtual path components. |
| 141 // Returns true if the given |path| is a valid FileSystem path. | 141 // Returns true if the given |path| is a valid FileSystem path. |
| 142 // Otherwise it calls dispatcher's DidFail method with | 142 // Otherwise it calls dispatcher's DidFail method with |
| 143 // PLATFORM_FILE_ERROR_SECURITY and returns false. | 143 // PLATFORM_FILE_ERROR_SECURITY and returns false. |
| 144 // (Note: this doesn't delete this when it calls DidFail and returns false; | 144 // (Note: this doesn't delete this when it calls DidFail and returns false; |
| 145 // it's the caller's responsibility.) | 145 // it's the caller's responsibility.) |
| 146 bool VerifyFileSystemPathForRead(const FilePath& path, | 146 bool VerifyFileSystemPathForRead(const GURL& path, |
| 147 GURL* root_url, | 147 GURL* root_url, |
| 148 FileSystemType* type, | 148 FileSystemType* type, |
| 149 FilePath* virtual_path); | 149 FilePath* virtual_path); |
| 150 | 150 |
| 151 // Checks the validity of a given |path| for writing, and cracks the path into | 151 // Checks the validity of a given |path| for writing, and cracks the path into |
| 152 // root URL and virtual path components. | 152 // root URL and virtual path components. |
| 153 // Returns true if the given |path| is a valid FileSystem path, and | 153 // Returns true if the given |path| is a valid FileSystem path, and |
| 154 // its origin embedded in the path has the right to write. | 154 // its origin embedded in the path has the right to write. |
| 155 // Otherwise it fires dispatcher's DidFail method with | 155 // Otherwise it fires dispatcher's DidFail method with |
| 156 // PLATFORM_FILE_ERROR_SECURITY if the path is not valid for writing, | 156 // PLATFORM_FILE_ERROR_SECURITY if the path is not valid for writing, |
| 157 // or with PLATFORM_FILE_ERROR_NO_SPACE if the origin is not allowed to | 157 // or with PLATFORM_FILE_ERROR_NO_SPACE if the origin is not allowed to |
| 158 // write to the storage. | 158 // write to the storage. |
| 159 // In either case it returns false after firing DidFail. | 159 // In either case it returns false after firing DidFail. |
| 160 // If |create| flag is true this also checks if the |path| contains | 160 // If |create| flag is true this also checks if the |path| contains |
| 161 // any restricted names and chars. If it does, the call fires dispatcher's | 161 // any restricted names and chars. If it does, the call fires dispatcher's |
| 162 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. | 162 // DidFail with PLATFORM_FILE_ERROR_SECURITY and returns false. |
| 163 // (Note: this doesn't delete this when it calls DidFail and returns false; | 163 // (Note: this doesn't delete this when it calls DidFail and returns false; |
| 164 // it's the caller's responsibility.) | 164 // it's the caller's responsibility.) |
| 165 bool VerifyFileSystemPathForWrite(const FilePath& path, | 165 bool VerifyFileSystemPathForWrite(const GURL& path, |
| 166 bool create, | 166 bool create, |
| 167 GURL* root_url, | 167 GURL* root_url, |
| 168 FileSystemType* type, | 168 FileSystemType* type, |
| 169 FilePath* virtual_path); | 169 FilePath* virtual_path); |
| 170 | 170 |
| 171 #ifndef NDEBUG | 171 #ifndef NDEBUG |
| 172 enum OperationType { | 172 enum OperationType { |
| 173 kOperationNone, | 173 kOperationNone, |
| 174 kOperationOpenFileSystem, | 174 kOperationOpenFileSystem, |
| 175 kOperationCreateFile, | 175 kOperationCreateFile, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 205 scoped_ptr<FileWriterDelegate> file_writer_delegate_; | 205 scoped_ptr<FileWriterDelegate> file_writer_delegate_; |
| 206 scoped_ptr<net::URLRequest> blob_request_; | 206 scoped_ptr<net::URLRequest> blob_request_; |
| 207 scoped_ptr<FileSystemOperation> cancel_operation_; | 207 scoped_ptr<FileSystemOperation> cancel_operation_; |
| 208 | 208 |
| 209 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); | 209 DISALLOW_COPY_AND_ASSIGN(FileSystemOperation); |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 } // namespace fileapi | 212 } // namespace fileapi |
| 213 | 213 |
| 214 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 214 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |