| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | |
| 6 #define WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "base/threading/non_thread_safe.h" | |
| 15 #include "webkit/fileapi/local_file_system_operation.h" | |
| 16 #include "webkit/storage/webkit_storage_export.h" | |
| 17 | |
| 18 namespace fileapi { | |
| 19 class FileSystemContext; | |
| 20 class FileSystemOperationContext; | |
| 21 class SandboxMountPointProvider; | |
| 22 } | |
| 23 | |
| 24 namespace sync_file_system { | |
| 25 | |
| 26 class SyncableFileOperationRunner; | |
| 27 | |
| 28 // A wrapper class of LocalFileSystemOperation for syncable file system. | |
| 29 class WEBKIT_STORAGE_EXPORT SyncableFileSystemOperation | |
| 30 : public fileapi::LocalFileSystemOperation, | |
| 31 public base::NonThreadSafe { | |
| 32 public: | |
| 33 virtual ~SyncableFileSystemOperation(); | |
| 34 | |
| 35 // fileapi::FileSystemOperation overrides. | |
| 36 virtual void CreateFile(const fileapi::FileSystemURL& url, | |
| 37 bool exclusive, | |
| 38 const StatusCallback& callback) OVERRIDE; | |
| 39 virtual void CreateDirectory(const fileapi::FileSystemURL& url, | |
| 40 bool exclusive, | |
| 41 bool recursive, | |
| 42 const StatusCallback& callback) OVERRIDE; | |
| 43 virtual void Copy(const fileapi::FileSystemURL& src_url, | |
| 44 const fileapi::FileSystemURL& dest_url, | |
| 45 const StatusCallback& callback) OVERRIDE; | |
| 46 virtual void Move(const fileapi::FileSystemURL& src_url, | |
| 47 const fileapi::FileSystemURL& dest_url, | |
| 48 const StatusCallback& callback) OVERRIDE; | |
| 49 virtual void DirectoryExists(const fileapi::FileSystemURL& url, | |
| 50 const StatusCallback& callback) OVERRIDE; | |
| 51 virtual void FileExists(const fileapi::FileSystemURL& url, | |
| 52 const StatusCallback& callback) OVERRIDE; | |
| 53 virtual void GetMetadata(const fileapi::FileSystemURL& url, | |
| 54 const GetMetadataCallback& callback) OVERRIDE; | |
| 55 virtual void ReadDirectory(const fileapi::FileSystemURL& url, | |
| 56 const ReadDirectoryCallback& callback) OVERRIDE; | |
| 57 virtual void Remove(const fileapi::FileSystemURL& url, bool recursive, | |
| 58 const StatusCallback& callback) OVERRIDE; | |
| 59 virtual void Write(const net::URLRequestContext* url_request_context, | |
| 60 const fileapi::FileSystemURL& url, | |
| 61 const GURL& blob_url, | |
| 62 int64 offset, | |
| 63 const WriteCallback& callback) OVERRIDE; | |
| 64 virtual void Truncate(const fileapi::FileSystemURL& url, int64 length, | |
| 65 const StatusCallback& callback) OVERRIDE; | |
| 66 virtual void TouchFile(const fileapi::FileSystemURL& url, | |
| 67 const base::Time& last_access_time, | |
| 68 const base::Time& last_modified_time, | |
| 69 const StatusCallback& callback) OVERRIDE; | |
| 70 virtual void OpenFile(const fileapi::FileSystemURL& url, | |
| 71 int file_flags, | |
| 72 base::ProcessHandle peer_handle, | |
| 73 const OpenFileCallback& callback) OVERRIDE; | |
| 74 virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; | |
| 75 virtual void CreateSnapshotFile( | |
| 76 const fileapi::FileSystemURL& path, | |
| 77 const SnapshotFileCallback& callback) OVERRIDE; | |
| 78 | |
| 79 // LocalFileSystemOperation overrides. | |
| 80 virtual void CopyInForeignFile(const base::FilePath& src_local_disk_path, | |
| 81 const fileapi::FileSystemURL& dest_url, | |
| 82 const StatusCallback& callback) OVERRIDE; | |
| 83 | |
| 84 private: | |
| 85 typedef SyncableFileSystemOperation self; | |
| 86 class QueueableTask; | |
| 87 | |
| 88 // Only MountPointProviders can create a new operation directly. | |
| 89 friend class fileapi::SandboxMountPointProvider; | |
| 90 friend class SandboxMountPointProvider; | |
| 91 SyncableFileSystemOperation( | |
| 92 fileapi::FileSystemContext* file_system_context, | |
| 93 scoped_ptr<fileapi::FileSystemOperationContext> operation_context); | |
| 94 fileapi::LocalFileSystemOperation* NewOperation(); | |
| 95 | |
| 96 void DidFinish(base::PlatformFileError status); | |
| 97 void DidWrite(const WriteCallback& callback, | |
| 98 base::PlatformFileError result, | |
| 99 int64 bytes, | |
| 100 bool complete); | |
| 101 | |
| 102 void OnCancelled(); | |
| 103 void AbortOperation(const StatusCallback& callback, | |
| 104 base::PlatformFileError error); | |
| 105 | |
| 106 base::WeakPtr<SyncableFileOperationRunner> operation_runner_; | |
| 107 fileapi::LocalFileSystemOperation* inflight_operation_; | |
| 108 std::vector<fileapi::FileSystemURL> target_paths_; | |
| 109 | |
| 110 StatusCallback completion_callback_; | |
| 111 | |
| 112 bool is_directory_operation_enabled_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(SyncableFileSystemOperation); | |
| 115 }; | |
| 116 | |
| 117 } // namespace sync_file_system | |
| 118 | |
| 119 #endif // WEBKIT_FILEAPI_SYNCABLE_SYNCABLE_FILE_SYSTEM_OPERATION_H_ | |
| OLD | NEW |