| 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 STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| 6 #define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 6 #define STORAGE_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" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 STORAGE_EXPORT static FileSystemOperation* Create( | 61 STORAGE_EXPORT static FileSystemOperation* Create( |
| 62 const FileSystemURL& url, | 62 const FileSystemURL& url, |
| 63 FileSystemContext* file_system_context, | 63 FileSystemContext* file_system_context, |
| 64 scoped_ptr<FileSystemOperationContext> operation_context); | 64 scoped_ptr<FileSystemOperationContext> operation_context); |
| 65 | 65 |
| 66 virtual ~FileSystemOperation() {} | 66 virtual ~FileSystemOperation() {} |
| 67 | 67 |
| 68 // Used for CreateFile(), etc. |result| is the return code of the operation. | 68 // Used for CreateFile(), etc. |result| is the return code of the operation. |
| 69 typedef base::Callback<void(base::File::Error result)> StatusCallback; | 69 typedef base::Callback<void(base::File::Error result)> StatusCallback; |
| 70 | 70 |
| 71 // Called when an error had happened during operation. | |
| 72 // |url| is the url of processed entry. | |
| 73 // |error| is the error code of the failed operation. | |
| 74 typedef base::Callback<void(const FileSystemURL& url, | |
| 75 base::File::Error error)> ErrorCallback; | |
| 76 | |
| 77 // Used for GetMetadata(). |result| is the return code of the operation, | 71 // Used for GetMetadata(). |result| is the return code of the operation, |
| 78 // |file_info| is the obtained file info. | 72 // |file_info| is the obtained file info. |
| 79 typedef base::Callback< | 73 typedef base::Callback< |
| 80 void(base::File::Error result, | 74 void(base::File::Error result, |
| 81 const base::File::Info& file_info)> GetMetadataCallback; | 75 const base::File::Info& file_info)> GetMetadataCallback; |
| 82 | 76 |
| 83 // Used for OpenFile(). |on_close_callback| will be called after the file is | 77 // Used for OpenFile(). |on_close_callback| will be called after the file is |
| 84 // closed in the child process. It can be null, if no operation is needed on | 78 // closed in the child process. It can be null, if no operation is needed on |
| 85 // closing a file. | 79 // closing a file. |
| 86 typedef base::Callback< | 80 typedef base::Callback< |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // longer necessary in the javascript world. | 113 // longer necessary in the javascript world. |
| 120 // Please see the comment for ShareableFileReference for details. | 114 // Please see the comment for ShareableFileReference for details. |
| 121 // | 115 // |
| 122 typedef base::Callback< | 116 typedef base::Callback< |
| 123 void(base::File::Error result, | 117 void(base::File::Error result, |
| 124 const base::File::Info& file_info, | 118 const base::File::Info& file_info, |
| 125 const base::FilePath& platform_path, | 119 const base::FilePath& platform_path, |
| 126 const scoped_refptr<storage::ShareableFileReference>& file_ref)> | 120 const scoped_refptr<storage::ShareableFileReference>& file_ref)> |
| 127 SnapshotFileCallback; | 121 SnapshotFileCallback; |
| 128 | 122 |
| 123 // Used to specify how recursive operation delegate behaves for errors. |
| 124 // With ERROR_BEHAVIOR_TERMINATE, it stops following operation when it fails |
| 125 // an operation. |
| 126 // With ERROR_BEHAVIOR_CONTINUE, it continues following operation even when it |
| 127 // fails some of the operations. |
| 128 enum ErrorBehavior { ERROR_BEHAVIOR_TERMINATE, ERROR_BEHAVIOR_CONTINUE }; |
| 129 |
| 129 // Used for progress update callback for Copy(). | 130 // Used for progress update callback for Copy(). |
| 130 // | 131 // |
| 131 // BEGIN_COPY_ENTRY is fired for each copy creation beginning (for both | 132 // BEGIN_COPY_ENTRY is fired for each copy creation beginning (for both |
| 132 // file and directory). | 133 // file and directory). |
| 133 // The |source_url| is the URL of the source entry. |size| should not be | 134 // The |source_url| is the URL of the source entry. |size| should not be |
| 134 // used. | 135 // used. |
| 135 // | 136 // |
| 136 // END_COPY_ENTRY is fired for each copy creation finishing (for both | 137 // END_COPY_ENTRY is fired for each copy creation finishing (for both |
| 137 // file and directory). | 138 // file and directory). |
| 138 // The |source_url| is the URL of the source entry. The |destination_url| is | 139 // The |source_url| is the URL of the source entry. The |destination_url| is |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // for root directory. | 193 // for root directory. |
| 193 // For 2)'s case, we can add BEGIN_DELETE_ENTRY and END_DELETE_ENTRY for each | 194 // For 2)'s case, we can add BEGIN_DELETE_ENTRY and END_DELETE_ENTRY for each |
| 194 // entry. | 195 // entry. |
| 195 // For both cases, we probably won't need to use PROGRESS event because | 196 // For both cases, we probably won't need to use PROGRESS event because |
| 196 // these operations should be done quickly (at least much faster than copying | 197 // these operations should be done quickly (at least much faster than copying |
| 197 // usually). | 198 // usually). |
| 198 enum CopyProgressType { | 199 enum CopyProgressType { |
| 199 BEGIN_COPY_ENTRY, | 200 BEGIN_COPY_ENTRY, |
| 200 END_COPY_ENTRY, | 201 END_COPY_ENTRY, |
| 201 PROGRESS, | 202 PROGRESS, |
| 203 ERROR |
| 202 }; | 204 }; |
| 203 typedef base::Callback<void(CopyProgressType type, | 205 typedef base::Callback<void(CopyProgressType type, |
| 204 const FileSystemURL& source_url, | 206 const FileSystemURL& source_url, |
| 205 const FileSystemURL& destination_url, | 207 const FileSystemURL& destination_url, |
| 206 int64 size)> | 208 int64 size)> |
| 207 CopyProgressCallback; | 209 CopyProgressCallback; |
| 208 | 210 |
| 209 // Used for CopyFileLocal() to report progress update. | 211 // Used for CopyFileLocal() to report progress update. |
| 210 // |size| is the cumulative copied bytes for the copy. | 212 // |size| is the cumulative copied bytes for the copy. |
| 211 // At the beginning the progress callback should be called with |size| = 0, | 213 // At the beginning the progress callback should be called with |size| = 0, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 bool exclusive, | 246 bool exclusive, |
| 245 bool recursive, | 247 bool recursive, |
| 246 const StatusCallback& callback) = 0; | 248 const StatusCallback& callback) = 0; |
| 247 | 249 |
| 248 // Copies a file or directory from |src_path| to |dest_path|. If | 250 // Copies a file or directory from |src_path| to |dest_path|. If |
| 249 // |src_path| is a directory, the contents of |src_path| are copied to | 251 // |src_path| is a directory, the contents of |src_path| are copied to |
| 250 // |dest_path| recursively. A new file or directory is created at | 252 // |dest_path| recursively. A new file or directory is created at |
| 251 // |dest_path| as needed. | 253 // |dest_path| as needed. |
| 252 // |option| specifies the minor behavior of Copy(). See CopyOrMoveOption's | 254 // |option| specifies the minor behavior of Copy(). See CopyOrMoveOption's |
| 253 // comment for details. | 255 // comment for details. |
| 256 // |error_behavior| specifies whether this continues operation after it |
| 257 // failed an operation or not. |
| 254 // |progress_callback| is periodically called to report the progress | 258 // |progress_callback| is periodically called to report the progress |
| 255 // update. See also the comment of CopyProgressCallback. This callback is | 259 // update. See also the comment of CopyProgressCallback. This callback is |
| 256 // optional. | 260 // optional. |
| 257 // | 261 // |
| 258 // For recursive case this internally creates new FileSystemOperations and | 262 // For recursive case this internally creates new FileSystemOperations and |
| 259 // calls: | 263 // calls: |
| 260 // - ReadDirectory, CopyFileLocal and CreateDirectory | 264 // - ReadDirectory, CopyFileLocal and CreateDirectory |
| 261 // for same-filesystem case, or | 265 // for same-filesystem case, or |
| 262 // - ReadDirectory and CreateSnapshotFile on source filesystem and | 266 // - ReadDirectory and CreateSnapshotFile on source filesystem and |
| 263 // CopyInForeignFile and CreateDirectory on dest filesystem | 267 // CopyInForeignFile and CreateDirectory on dest filesystem |
| 264 // for cross-filesystem case. | 268 // for cross-filesystem case. |
| 265 // | 269 // |
| 266 virtual void Copy(const FileSystemURL& src_path, | 270 virtual void Copy(const FileSystemURL& src_path, |
| 267 const FileSystemURL& dest_path, | 271 const FileSystemURL& dest_path, |
| 268 CopyOrMoveOption option, | 272 CopyOrMoveOption option, |
| 273 const ErrorBehavior error_behavior, |
| 269 const CopyProgressCallback& progress_callback, | 274 const CopyProgressCallback& progress_callback, |
| 270 const StatusCallback& callback) = 0; | 275 const StatusCallback& callback) = 0; |
| 271 | 276 |
| 272 // Moves a file or directory from |src_path| to |dest_path|. A new file | 277 // Moves a file or directory from |src_path| to |dest_path|. A new file |
| 273 // or directory is created at |dest_path| as needed. | 278 // or directory is created at |dest_path| as needed. |
| 274 // |option| specifies the minor behavior of Copy(). See CopyOrMoveOption's | 279 // |option| specifies the minor behavior of Copy(). See CopyOrMoveOption's |
| 275 // comment for details. | 280 // comment for details. |
| 276 // | 281 // |
| 277 // For recursive case this internally creates new FileSystemOperations and | 282 // For recursive case this internally creates new FileSystemOperations and |
| 278 // calls: | 283 // calls: |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 kOperationOpenFile, | 487 kOperationOpenFile, |
| 483 kOperationCloseFile, | 488 kOperationCloseFile, |
| 484 kOperationGetLocalPath, | 489 kOperationGetLocalPath, |
| 485 kOperationCancel, | 490 kOperationCancel, |
| 486 }; | 491 }; |
| 487 }; | 492 }; |
| 488 | 493 |
| 489 } // namespace storage | 494 } // namespace storage |
| 490 | 495 |
| 491 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ | 496 #endif // STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |