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_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
13 #include "base/process/process.h" | 14 #include "base/process/process.h" |
14 #include "webkit/browser/fileapi/file_system_operation_context.h" | 15 #include "webkit/browser/fileapi/file_system_operation_context.h" |
15 #include "webkit/browser/webkit_storage_browser_export.h" | 16 #include "webkit/browser/webkit_storage_browser_export.h" |
16 #include "webkit/common/fileapi/directory_entry.h" | 17 #include "webkit/common/fileapi/directory_entry.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class Time; | 20 class Time; |
20 } | 21 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 class FileSystemOperation { | 60 class FileSystemOperation { |
60 public: | 61 public: |
61 WEBKIT_STORAGE_BROWSER_EXPORT static FileSystemOperation* Create( | 62 WEBKIT_STORAGE_BROWSER_EXPORT static FileSystemOperation* Create( |
62 const FileSystemURL& url, | 63 const FileSystemURL& url, |
63 FileSystemContext* file_system_context, | 64 FileSystemContext* file_system_context, |
64 scoped_ptr<FileSystemOperationContext> operation_context); | 65 scoped_ptr<FileSystemOperationContext> operation_context); |
65 | 66 |
66 virtual ~FileSystemOperation() {} | 67 virtual ~FileSystemOperation() {} |
67 | 68 |
68 // Used for CreateFile(), etc. |result| is the return code of the operation. | 69 // Used for CreateFile(), etc. |result| is the return code of the operation. |
69 typedef base::Callback<void(base::PlatformFileError result)> StatusCallback; | 70 typedef base::Callback<void(base::File::Error result)> StatusCallback; |
70 | 71 |
71 // Used for GetMetadata(). |result| is the return code of the operation, | 72 // Used for GetMetadata(). |result| is the return code of the operation, |
72 // |file_info| is the obtained file info. | 73 // |file_info| is the obtained file info. |
73 typedef base::Callback< | 74 typedef base::Callback< |
74 void(base::PlatformFileError result, | 75 void(base::File::Error result, |
75 const base::PlatformFileInfo& file_info)> GetMetadataCallback; | 76 const base::File::Info& file_info)> GetMetadataCallback; |
76 | 77 |
77 // Used for OpenFile(). |result| is the return code of the operation. | 78 // Used for OpenFile(). |result| is the return code of the operation. |
78 // |on_close_callback| will be called after the file is closed in the child | 79 // |on_close_callback| will be called after the file is closed in the child |
79 // process. It can be null, if no operation is needed on closing a file. | 80 // process. It can be null, if no operation is needed on closing a file. |
80 typedef base::Callback< | 81 typedef base::Callback< |
81 void(base::PlatformFileError result, | 82 void(base::File::Error result, |
82 base::PlatformFile file, | 83 base::PlatformFile file, |
83 const base::Closure& on_close_callback)> OpenFileCallback; | 84 const base::Closure& on_close_callback)> OpenFileCallback; |
84 | 85 |
85 // Used for ReadDirectoryCallback. | 86 // Used for ReadDirectoryCallback. |
86 typedef std::vector<DirectoryEntry> FileEntryList; | 87 typedef std::vector<DirectoryEntry> FileEntryList; |
87 | 88 |
88 // Used for ReadDirectory(). |result| is the return code of the operation, | 89 // Used for ReadDirectory(). |result| is the return code of the operation, |
89 // |file_list| is the list of files read, and |has_more| is true if some files | 90 // |file_list| is the list of files read, and |has_more| is true if some files |
90 // are yet to be read. | 91 // are yet to be read. |
91 typedef base::Callback< | 92 typedef base::Callback< |
92 void(base::PlatformFileError result, | 93 void(base::File::Error result, |
93 const FileEntryList& file_list, | 94 const FileEntryList& file_list, |
94 bool has_more)> ReadDirectoryCallback; | 95 bool has_more)> ReadDirectoryCallback; |
95 | 96 |
96 // Used for CreateSnapshotFile(). (Please see the comment at | 97 // Used for CreateSnapshotFile(). (Please see the comment at |
97 // CreateSnapshotFile() below for how the method is called) | 98 // CreateSnapshotFile() below for how the method is called) |
98 // |result| is the return code of the operation. | 99 // |result| is the return code of the operation. |
99 // |file_info| is the metadata of the snapshot file created. | 100 // |file_info| is the metadata of the snapshot file created. |
100 // |platform_path| is the path to the snapshot file created. | 101 // |platform_path| is the path to the snapshot file created. |
101 // | 102 // |
102 // The snapshot file could simply be of the local file pointed by the given | 103 // The snapshot file could simply be of the local file pointed by the given |
103 // filesystem URL in local filesystem cases; remote filesystems | 104 // filesystem URL in local filesystem cases; remote filesystems |
104 // may want to download the file into a temporary snapshot file and then | 105 // may want to download the file into a temporary snapshot file and then |
105 // return the metadata of the temporary file. | 106 // return the metadata of the temporary file. |
106 // | 107 // |
107 // |file_ref| is used to manage the lifetime of the returned | 108 // |file_ref| is used to manage the lifetime of the returned |
108 // snapshot file. It can be set to let the chromium backend take | 109 // snapshot file. It can be set to let the chromium backend take |
109 // care of the life time of the snapshot file. Otherwise (if the returned | 110 // care of the life time of the snapshot file. Otherwise (if the returned |
110 // file does not require any handling) the implementation can just | 111 // file does not require any handling) the implementation can just |
111 // return NULL. In a more complex case, the implementaiton can manage | 112 // return NULL. In a more complex case, the implementaiton can manage |
112 // the lifetime of the snapshot file on its own (e.g. by its cache system) | 113 // the lifetime of the snapshot file on its own (e.g. by its cache system) |
113 // but also can be notified via the reference when the file becomes no | 114 // but also can be notified via the reference when the file becomes no |
114 // longer necessary in the javascript world. | 115 // longer necessary in the javascript world. |
115 // Please see the comment for ShareableFileReference for details. | 116 // Please see the comment for ShareableFileReference for details. |
116 // | 117 // |
117 typedef base::Callback< | 118 typedef base::Callback< |
118 void(base::PlatformFileError result, | 119 void(base::File::Error result, |
119 const base::PlatformFileInfo& file_info, | 120 const base::File::Info& file_info, |
120 const base::FilePath& platform_path, | 121 const base::FilePath& platform_path, |
121 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)> | 122 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)> |
122 SnapshotFileCallback; | 123 SnapshotFileCallback; |
123 | 124 |
124 // Used for progress update callback for Copy(). | 125 // Used for progress update callback for Copy(). |
125 // | 126 // |
126 // BEGIN_COPY_ENTRY is fired for each copy creation beginning (for both | 127 // BEGIN_COPY_ENTRY is fired for each copy creation beginning (for both |
127 // file and directory). | 128 // file and directory). |
128 // The |source_url| is the URL of the source entry. |size| should not be | 129 // The |source_url| is the URL of the source entry. |size| should not be |
129 // used. | 130 // used. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 OPTION_NONE, | 215 OPTION_NONE, |
215 | 216 |
216 // Preserves last modified time if possible. If the operation to update | 217 // Preserves last modified time if possible. If the operation to update |
217 // last modified time is not supported on the file system for the | 218 // last modified time is not supported on the file system for the |
218 // destination file, this option would be simply ignored (i.e. Copy would | 219 // destination file, this option would be simply ignored (i.e. Copy would |
219 // be successfully done without preserving last modified time). | 220 // be successfully done without preserving last modified time). |
220 OPTION_PRESERVE_LAST_MODIFIED, | 221 OPTION_PRESERVE_LAST_MODIFIED, |
221 }; | 222 }; |
222 | 223 |
223 // Used for Write(). | 224 // Used for Write(). |
224 typedef base::Callback<void(base::PlatformFileError result, | 225 typedef base::Callback<void(base::File::Error result, |
225 int64 bytes, | 226 int64 bytes, |
226 bool complete)> WriteCallback; | 227 bool complete)> WriteCallback; |
227 | 228 |
228 // Creates a file at |path|. If |exclusive| is true, an error is raised | 229 // Creates a file at |path|. If |exclusive| is true, an error is raised |
229 // in case a file is already present at the URL. | 230 // in case a file is already present at the URL. |
230 virtual void CreateFile(const FileSystemURL& path, | 231 virtual void CreateFile(const FileSystemURL& path, |
231 bool exclusive, | 232 bool exclusive, |
232 const StatusCallback& callback) = 0; | 233 const StatusCallback& callback) = 0; |
233 | 234 |
234 // Creates a directory at |path|. If |exclusive| is true, an error is | 235 // Creates a directory at |path|. If |exclusive| is true, an error is |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 virtual void MoveFileLocal(const FileSystemURL& src_url, | 446 virtual void MoveFileLocal(const FileSystemURL& src_url, |
446 const FileSystemURL& dest_url, | 447 const FileSystemURL& dest_url, |
447 CopyOrMoveOption option, | 448 CopyOrMoveOption option, |
448 const StatusCallback& callback) = 0; | 449 const StatusCallback& callback) = 0; |
449 | 450 |
450 // Synchronously gets the platform path for the given |url|. | 451 // Synchronously gets the platform path for the given |url|. |
451 // This may fail if the given |url|'s filesystem type is neither | 452 // This may fail if the given |url|'s filesystem type is neither |
452 // temporary nor persistent. | 453 // temporary nor persistent. |
453 // In such a case, base::PLATFORM_FILE_ERROR_INVALID_OPERATION will be | 454 // In such a case, base::PLATFORM_FILE_ERROR_INVALID_OPERATION will be |
454 // returned. | 455 // returned. |
455 virtual base::PlatformFileError SyncGetPlatformPath( | 456 virtual base::File::Error SyncGetPlatformPath( |
456 const FileSystemURL& url, | 457 const FileSystemURL& url, |
457 base::FilePath* platform_path) = 0; | 458 base::FilePath* platform_path) = 0; |
458 | 459 |
459 protected: | 460 protected: |
460 // Used only for internal assertions. | 461 // Used only for internal assertions. |
461 enum OperationType { | 462 enum OperationType { |
462 kOperationNone, | 463 kOperationNone, |
463 kOperationCreateFile, | 464 kOperationCreateFile, |
464 kOperationCreateDirectory, | 465 kOperationCreateDirectory, |
465 kOperationCreateSnapshotFile, | 466 kOperationCreateSnapshotFile, |
(...skipping 11 matching lines...) Expand all Loading... |
477 kOperationOpenFile, | 478 kOperationOpenFile, |
478 kOperationCloseFile, | 479 kOperationCloseFile, |
479 kOperationGetLocalPath, | 480 kOperationGetLocalPath, |
480 kOperationCancel, | 481 kOperationCancel, |
481 }; | 482 }; |
482 }; | 483 }; |
483 | 484 |
484 } // namespace fileapi | 485 } // namespace fileapi |
485 | 486 |
486 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 487 #endif // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
OLD | NEW |