| 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 WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_SYNCABLE_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/local_file_system_operation.h" | 15 #include "webkit/browser/fileapi/file_system_operation_impl.h" |
| 16 #include "webkit/browser/webkit_storage_browser_export.h" | 16 #include "webkit/browser/webkit_storage_browser_export.h" |
| 17 | 17 |
| 18 namespace fileapi { | 18 namespace fileapi { |
| 19 class FileSystemContext; | 19 class FileSystemContext; |
| 20 class FileSystemOperationContext; | 20 class FileSystemOperationContext; |
| 21 class SandboxFileSystemBackend; | 21 class SandboxFileSystemBackend; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace sync_file_system { | 24 namespace sync_file_system { |
| 25 | 25 |
| 26 class SyncableFileOperationRunner; | 26 class SyncableFileOperationRunner; |
| 27 | 27 |
| 28 // A wrapper class of LocalFileSystemOperation for syncable file system. | 28 // A wrapper class of FileSystemOperationImpl for syncable file system. |
| 29 class WEBKIT_STORAGE_BROWSER_EXPORT SyncableFileSystemOperation | 29 class WEBKIT_STORAGE_BROWSER_EXPORT SyncableFileSystemOperation |
| 30 : public fileapi::LocalFileSystemOperation, | 30 : public fileapi::FileSystemOperationImpl, |
| 31 public base::SupportsWeakPtr<SyncableFileSystemOperation>, | 31 public base::SupportsWeakPtr<SyncableFileSystemOperation>, |
| 32 public base::NonThreadSafe { | 32 public base::NonThreadSafe { |
| 33 public: | 33 public: |
| 34 virtual ~SyncableFileSystemOperation(); | 34 virtual ~SyncableFileSystemOperation(); |
| 35 | 35 |
| 36 // fileapi::FileSystemOperation overrides. | 36 // fileapi::FileSystemOperation overrides. |
| 37 virtual void CreateFile(const fileapi::FileSystemURL& url, | 37 virtual void CreateFile(const fileapi::FileSystemURL& url, |
| 38 bool exclusive, | 38 bool exclusive, |
| 39 const StatusCallback& callback) OVERRIDE; | 39 const StatusCallback& callback) OVERRIDE; |
| 40 virtual void CreateDirectory(const fileapi::FileSystemURL& url, | 40 virtual void CreateDirectory(const fileapi::FileSystemURL& url, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 69 const StatusCallback& callback) OVERRIDE; | 69 const StatusCallback& callback) OVERRIDE; |
| 70 virtual void OpenFile(const fileapi::FileSystemURL& url, | 70 virtual void OpenFile(const fileapi::FileSystemURL& url, |
| 71 int file_flags, | 71 int file_flags, |
| 72 base::ProcessHandle peer_handle, | 72 base::ProcessHandle peer_handle, |
| 73 const OpenFileCallback& callback) OVERRIDE; | 73 const OpenFileCallback& callback) OVERRIDE; |
| 74 virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; | 74 virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; |
| 75 virtual void CreateSnapshotFile( | 75 virtual void CreateSnapshotFile( |
| 76 const fileapi::FileSystemURL& path, | 76 const fileapi::FileSystemURL& path, |
| 77 const SnapshotFileCallback& callback) OVERRIDE; | 77 const SnapshotFileCallback& callback) OVERRIDE; |
| 78 | 78 |
| 79 // LocalFileSystemOperation overrides. | 79 // FileSystemOperationImpl overrides. |
| 80 virtual void CopyInForeignFile(const base::FilePath& src_local_disk_path, | 80 virtual void CopyInForeignFile(const base::FilePath& src_local_disk_path, |
| 81 const fileapi::FileSystemURL& dest_url, | 81 const fileapi::FileSystemURL& dest_url, |
| 82 const StatusCallback& callback) OVERRIDE; | 82 const StatusCallback& callback) OVERRIDE; |
| 83 | 83 |
| 84 using base::SupportsWeakPtr<SyncableFileSystemOperation>::AsWeakPtr; | 84 using base::SupportsWeakPtr<SyncableFileSystemOperation>::AsWeakPtr; |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 typedef SyncableFileSystemOperation self; | 87 typedef SyncableFileSystemOperation self; |
| 88 class QueueableTask; | 88 class QueueableTask; |
| 89 | 89 |
| 90 // Only FileSystemBackends can create a new operation directly. | 90 // Only FileSystemBackends can create a new operation directly. |
| 91 friend class fileapi::SandboxFileSystemBackend; | 91 friend class fileapi::SandboxFileSystemBackend; |
| 92 friend class SandboxFileSystemBackend; | 92 friend class SandboxFileSystemBackend; |
| 93 SyncableFileSystemOperation( | 93 SyncableFileSystemOperation( |
| 94 const fileapi::FileSystemURL& url, | 94 const fileapi::FileSystemURL& url, |
| 95 fileapi::FileSystemContext* file_system_context, | 95 fileapi::FileSystemContext* file_system_context, |
| 96 scoped_ptr<fileapi::FileSystemOperationContext> operation_context); | 96 scoped_ptr<fileapi::FileSystemOperationContext> operation_context); |
| 97 fileapi::LocalFileSystemOperation* NewOperation(); | 97 fileapi::FileSystemOperationImpl* NewOperation(); |
| 98 | 98 |
| 99 void DidFinish(base::PlatformFileError status); | 99 void DidFinish(base::PlatformFileError status); |
| 100 void DidWrite(const WriteCallback& callback, | 100 void DidWrite(const WriteCallback& callback, |
| 101 base::PlatformFileError result, | 101 base::PlatformFileError result, |
| 102 int64 bytes, | 102 int64 bytes, |
| 103 bool complete); | 103 bool complete); |
| 104 | 104 |
| 105 void OnCancelled(); | 105 void OnCancelled(); |
| 106 | 106 |
| 107 const fileapi::FileSystemURL url_; | 107 const fileapi::FileSystemURL url_; |
| 108 | 108 |
| 109 base::WeakPtr<SyncableFileOperationRunner> operation_runner_; | 109 base::WeakPtr<SyncableFileOperationRunner> operation_runner_; |
| 110 scoped_ptr<fileapi::LocalFileSystemOperation> inflight_operation_; | 110 scoped_ptr<fileapi::FileSystemOperationImpl> inflight_operation_; |
| 111 std::vector<fileapi::FileSystemURL> target_paths_; | 111 std::vector<fileapi::FileSystemURL> target_paths_; |
| 112 | 112 |
| 113 StatusCallback completion_callback_; | 113 StatusCallback completion_callback_; |
| 114 | 114 |
| 115 bool is_directory_operation_enabled_; | 115 bool is_directory_operation_enabled_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation); | 117 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace sync_file_system | 120 } // namespace sync_file_system |
| 121 | 121 |
| 122 #endif // WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | 122 #endif // WEBKIT_BROWSER_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ |
| OLD | NEW |