| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_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/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "webkit/browser/fileapi/file_system_operation.h" | 15 #include "webkit/browser/fileapi/file_system_operation.h" |
| 16 #include "webkit/browser/fileapi/file_system_url.h" | 16 #include "webkit/browser/fileapi/file_system_url.h" |
| 17 | 17 |
| 18 namespace fileapi { | 18 namespace storage { |
| 19 class FileSystemContext; | 19 class FileSystemContext; |
| 20 class FileSystemOperationContext; | 20 class FileSystemOperationContext; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace sync_file_system { | 23 namespace sync_file_system { |
| 24 | 24 |
| 25 class SyncableFileOperationRunner; | 25 class SyncableFileOperationRunner; |
| 26 | 26 |
| 27 // A wrapper class of FileSystemOperation for syncable file system. | 27 // A wrapper class of FileSystemOperation for syncable file system. |
| 28 class SyncableFileSystemOperation | 28 class SyncableFileSystemOperation |
| 29 : public NON_EXPORTED_BASE(fileapi::FileSystemOperation), | 29 : public NON_EXPORTED_BASE(storage::FileSystemOperation), |
| 30 public base::NonThreadSafe { | 30 public base::NonThreadSafe { |
| 31 public: | 31 public: |
| 32 virtual ~SyncableFileSystemOperation(); | 32 virtual ~SyncableFileSystemOperation(); |
| 33 | 33 |
| 34 // fileapi::FileSystemOperation overrides. | 34 // storage::FileSystemOperation overrides. |
| 35 virtual void CreateFile(const fileapi::FileSystemURL& url, | 35 virtual void CreateFile(const storage::FileSystemURL& url, |
| 36 bool exclusive, | 36 bool exclusive, |
| 37 const StatusCallback& callback) OVERRIDE; | 37 const StatusCallback& callback) OVERRIDE; |
| 38 virtual void CreateDirectory(const fileapi::FileSystemURL& url, | 38 virtual void CreateDirectory(const storage::FileSystemURL& url, |
| 39 bool exclusive, | 39 bool exclusive, |
| 40 bool recursive, | 40 bool recursive, |
| 41 const StatusCallback& callback) OVERRIDE; | 41 const StatusCallback& callback) OVERRIDE; |
| 42 virtual void Copy(const fileapi::FileSystemURL& src_url, | 42 virtual void Copy(const storage::FileSystemURL& src_url, |
| 43 const fileapi::FileSystemURL& dest_url, | 43 const storage::FileSystemURL& dest_url, |
| 44 CopyOrMoveOption option, | 44 CopyOrMoveOption option, |
| 45 const CopyProgressCallback& progress_callback, | 45 const CopyProgressCallback& progress_callback, |
| 46 const StatusCallback& callback) OVERRIDE; | 46 const StatusCallback& callback) OVERRIDE; |
| 47 virtual void Move(const fileapi::FileSystemURL& src_url, | 47 virtual void Move(const storage::FileSystemURL& src_url, |
| 48 const fileapi::FileSystemURL& dest_url, | 48 const storage::FileSystemURL& dest_url, |
| 49 CopyOrMoveOption option, | 49 CopyOrMoveOption option, |
| 50 const StatusCallback& callback) OVERRIDE; | 50 const StatusCallback& callback) OVERRIDE; |
| 51 virtual void DirectoryExists(const fileapi::FileSystemURL& url, | 51 virtual void DirectoryExists(const storage::FileSystemURL& url, |
| 52 const StatusCallback& callback) OVERRIDE; | 52 const StatusCallback& callback) OVERRIDE; |
| 53 virtual void FileExists(const fileapi::FileSystemURL& url, | 53 virtual void FileExists(const storage::FileSystemURL& url, |
| 54 const StatusCallback& callback) OVERRIDE; | 54 const StatusCallback& callback) OVERRIDE; |
| 55 virtual void GetMetadata(const fileapi::FileSystemURL& url, | 55 virtual void GetMetadata(const storage::FileSystemURL& url, |
| 56 const GetMetadataCallback& callback) OVERRIDE; | 56 const GetMetadataCallback& callback) OVERRIDE; |
| 57 virtual void ReadDirectory(const fileapi::FileSystemURL& url, | 57 virtual void ReadDirectory(const storage::FileSystemURL& url, |
| 58 const ReadDirectoryCallback& callback) OVERRIDE; | 58 const ReadDirectoryCallback& callback) OVERRIDE; |
| 59 virtual void Remove(const fileapi::FileSystemURL& url, bool recursive, | 59 virtual void Remove(const storage::FileSystemURL& url, |
| 60 bool recursive, |
| 60 const StatusCallback& callback) OVERRIDE; | 61 const StatusCallback& callback) OVERRIDE; |
| 61 virtual void Write(const fileapi::FileSystemURL& url, | 62 virtual void Write(const storage::FileSystemURL& url, |
| 62 scoped_ptr<fileapi::FileWriterDelegate> writer_delegate, | 63 scoped_ptr<storage::FileWriterDelegate> writer_delegate, |
| 63 scoped_ptr<net::URLRequest> blob_request, | 64 scoped_ptr<net::URLRequest> blob_request, |
| 64 const WriteCallback& callback) OVERRIDE; | 65 const WriteCallback& callback) OVERRIDE; |
| 65 virtual void Truncate(const fileapi::FileSystemURL& url, int64 length, | 66 virtual void Truncate(const storage::FileSystemURL& url, |
| 67 int64 length, |
| 66 const StatusCallback& callback) OVERRIDE; | 68 const StatusCallback& callback) OVERRIDE; |
| 67 virtual void TouchFile(const fileapi::FileSystemURL& url, | 69 virtual void TouchFile(const storage::FileSystemURL& url, |
| 68 const base::Time& last_access_time, | 70 const base::Time& last_access_time, |
| 69 const base::Time& last_modified_time, | 71 const base::Time& last_modified_time, |
| 70 const StatusCallback& callback) OVERRIDE; | 72 const StatusCallback& callback) OVERRIDE; |
| 71 virtual void OpenFile(const fileapi::FileSystemURL& url, | 73 virtual void OpenFile(const storage::FileSystemURL& url, |
| 72 int file_flags, | 74 int file_flags, |
| 73 const OpenFileCallback& callback) OVERRIDE; | 75 const OpenFileCallback& callback) OVERRIDE; |
| 74 virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; | 76 virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; |
| 75 virtual void CreateSnapshotFile( | 77 virtual void CreateSnapshotFile( |
| 76 const fileapi::FileSystemURL& path, | 78 const storage::FileSystemURL& path, |
| 77 const SnapshotFileCallback& callback) OVERRIDE; | 79 const SnapshotFileCallback& callback) OVERRIDE; |
| 78 virtual void CopyInForeignFile(const base::FilePath& src_local_disk_path, | 80 virtual void CopyInForeignFile(const base::FilePath& src_local_disk_path, |
| 79 const fileapi::FileSystemURL& dest_url, | 81 const storage::FileSystemURL& dest_url, |
| 80 const StatusCallback& callback) OVERRIDE; | 82 const StatusCallback& callback) OVERRIDE; |
| 81 virtual void RemoveFile(const fileapi::FileSystemURL& url, | 83 virtual void RemoveFile(const storage::FileSystemURL& url, |
| 82 const StatusCallback& callback) OVERRIDE; | 84 const StatusCallback& callback) OVERRIDE; |
| 83 virtual void RemoveDirectory(const fileapi::FileSystemURL& url, | 85 virtual void RemoveDirectory(const storage::FileSystemURL& url, |
| 84 const StatusCallback& callback) OVERRIDE; | 86 const StatusCallback& callback) OVERRIDE; |
| 85 virtual void CopyFileLocal(const fileapi::FileSystemURL& src_url, | 87 virtual void CopyFileLocal(const storage::FileSystemURL& src_url, |
| 86 const fileapi::FileSystemURL& dest_url, | 88 const storage::FileSystemURL& dest_url, |
| 87 CopyOrMoveOption option, | 89 CopyOrMoveOption option, |
| 88 const CopyFileProgressCallback& progress_callback, | 90 const CopyFileProgressCallback& progress_callback, |
| 89 const StatusCallback& callback) OVERRIDE; | 91 const StatusCallback& callback) OVERRIDE; |
| 90 virtual void MoveFileLocal(const fileapi::FileSystemURL& src_url, | 92 virtual void MoveFileLocal(const storage::FileSystemURL& src_url, |
| 91 const fileapi::FileSystemURL& dest_url, | 93 const storage::FileSystemURL& dest_url, |
| 92 CopyOrMoveOption option, | 94 CopyOrMoveOption option, |
| 93 const StatusCallback& callback) OVERRIDE; | 95 const StatusCallback& callback) OVERRIDE; |
| 94 virtual base::File::Error SyncGetPlatformPath( | 96 virtual base::File::Error SyncGetPlatformPath( |
| 95 const fileapi::FileSystemURL& url, | 97 const storage::FileSystemURL& url, |
| 96 base::FilePath* platform_path) OVERRIDE; | 98 base::FilePath* platform_path) OVERRIDE; |
| 97 | 99 |
| 98 private: | 100 private: |
| 99 typedef SyncableFileSystemOperation self; | 101 typedef SyncableFileSystemOperation self; |
| 100 class QueueableTask; | 102 class QueueableTask; |
| 101 | 103 |
| 102 // Only SyncFileSystemBackend can create a new operation directly. | 104 // Only SyncFileSystemBackend can create a new operation directly. |
| 103 friend class SyncFileSystemBackend; | 105 friend class SyncFileSystemBackend; |
| 104 | 106 |
| 105 SyncableFileSystemOperation( | 107 SyncableFileSystemOperation( |
| 106 const fileapi::FileSystemURL& url, | 108 const storage::FileSystemURL& url, |
| 107 fileapi::FileSystemContext* file_system_context, | 109 storage::FileSystemContext* file_system_context, |
| 108 scoped_ptr<fileapi::FileSystemOperationContext> operation_context); | 110 scoped_ptr<storage::FileSystemOperationContext> operation_context); |
| 109 | 111 |
| 110 void DidFinish(base::File::Error status); | 112 void DidFinish(base::File::Error status); |
| 111 void DidWrite(const WriteCallback& callback, | 113 void DidWrite(const WriteCallback& callback, |
| 112 base::File::Error result, | 114 base::File::Error result, |
| 113 int64 bytes, | 115 int64 bytes, |
| 114 bool complete); | 116 bool complete); |
| 115 | 117 |
| 116 void OnCancelled(); | 118 void OnCancelled(); |
| 117 | 119 |
| 118 const fileapi::FileSystemURL url_; | 120 const storage::FileSystemURL url_; |
| 119 | 121 |
| 120 scoped_ptr<fileapi::FileSystemOperation> impl_; | 122 scoped_ptr<storage::FileSystemOperation> impl_; |
| 121 base::WeakPtr<SyncableFileOperationRunner> operation_runner_; | 123 base::WeakPtr<SyncableFileOperationRunner> operation_runner_; |
| 122 std::vector<fileapi::FileSystemURL> target_paths_; | 124 std::vector<storage::FileSystemURL> target_paths_; |
| 123 | 125 |
| 124 StatusCallback completion_callback_; | 126 StatusCallback completion_callback_; |
| 125 | 127 |
| 126 base::WeakPtrFactory<SyncableFileSystemOperation> weak_factory_; | 128 base::WeakPtrFactory<SyncableFileSystemOperation> weak_factory_; |
| 127 | 129 |
| 128 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation); | 130 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation); |
| 129 }; | 131 }; |
| 130 | 132 |
| 131 } // namespace sync_file_system | 133 } // namespace sync_file_system |
| 132 | 134 |
| 133 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_
H_ | 135 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_LOCAL_SYNCABLE_FILE_SYSTEM_OPERATION_
H_ |
| OLD | NEW |