| 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_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ | |
| 6 #define WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ | |
| 7 | |
| 8 #include "webkit/browser/fileapi/file_system_operation.h" | |
| 9 #include "webkit/browser/fileapi/file_writer_delegate.h" | |
| 10 #include "webkit/browser/fileapi/remote_file_system_proxy.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class Value; | |
| 14 } | |
| 15 | |
| 16 namespace fileapi { | |
| 17 class FileWriterDelegate; | |
| 18 class LocalFileSystemOperation; | |
| 19 } | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 // FileSystemOperation implementation for local file systems. | |
| 24 class RemoteFileSystemOperation : public fileapi::FileSystemOperation { | |
| 25 public: | |
| 26 typedef fileapi::FileWriterDelegate FileWriterDelegate; | |
| 27 virtual ~RemoteFileSystemOperation(); | |
| 28 | |
| 29 // FileSystemOperation overrides. | |
| 30 virtual void CreateFile(const fileapi::FileSystemURL& url, | |
| 31 bool exclusive, | |
| 32 const StatusCallback& callback) OVERRIDE; | |
| 33 virtual void CreateDirectory(const fileapi::FileSystemURL& url, | |
| 34 bool exclusive, | |
| 35 bool recursive, | |
| 36 const StatusCallback& callback) OVERRIDE; | |
| 37 virtual void Copy(const fileapi::FileSystemURL& src_url, | |
| 38 const fileapi::FileSystemURL& dest_url, | |
| 39 const StatusCallback& callback) OVERRIDE; | |
| 40 virtual void Move(const fileapi::FileSystemURL& src_url, | |
| 41 const fileapi::FileSystemURL& dest_url, | |
| 42 const StatusCallback& callback) OVERRIDE; | |
| 43 virtual void DirectoryExists(const fileapi::FileSystemURL& url, | |
| 44 const StatusCallback& callback) OVERRIDE; | |
| 45 virtual void FileExists(const fileapi::FileSystemURL& url, | |
| 46 const StatusCallback& callback) OVERRIDE; | |
| 47 virtual void GetMetadata(const fileapi::FileSystemURL& url, | |
| 48 const GetMetadataCallback& callback) OVERRIDE; | |
| 49 virtual void ReadDirectory(const fileapi::FileSystemURL& url, | |
| 50 const ReadDirectoryCallback& callback) OVERRIDE; | |
| 51 virtual void Remove(const fileapi::FileSystemURL& url, bool recursive, | |
| 52 const StatusCallback& callback) OVERRIDE; | |
| 53 virtual void Write(const net::URLRequestContext* url_request_context, | |
| 54 const fileapi::FileSystemURL& url, | |
| 55 const GURL& blob_url, | |
| 56 int64 offset, | |
| 57 const WriteCallback& callback) OVERRIDE; | |
| 58 virtual void Truncate(const fileapi::FileSystemURL& url, int64 length, | |
| 59 const StatusCallback& callback) OVERRIDE; | |
| 60 virtual void Cancel(const StatusCallback& cancel_callback) OVERRIDE; | |
| 61 virtual void TouchFile(const fileapi::FileSystemURL& url, | |
| 62 const base::Time& last_access_time, | |
| 63 const base::Time& last_modified_time, | |
| 64 const StatusCallback& callback) OVERRIDE; | |
| 65 virtual void OpenFile( | |
| 66 const fileapi::FileSystemURL& url, | |
| 67 int file_flags, | |
| 68 base::ProcessHandle peer_handle, | |
| 69 const OpenFileCallback& callback) OVERRIDE; | |
| 70 virtual fileapi::LocalFileSystemOperation* | |
| 71 AsLocalFileSystemOperation() OVERRIDE; | |
| 72 virtual void CreateSnapshotFile( | |
| 73 const fileapi::FileSystemURL& url, | |
| 74 const SnapshotFileCallback& callback) OVERRIDE; | |
| 75 | |
| 76 private: | |
| 77 friend class CrosMountPointProvider; | |
| 78 | |
| 79 RemoteFileSystemOperation( | |
| 80 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy); | |
| 81 | |
| 82 // Used only for internal assertions. | |
| 83 // Returns false if there's another inflight pending operation. | |
| 84 bool SetPendingOperationType(OperationType type); | |
| 85 | |
| 86 // Generic callback that translates platform errors to WebKit error codes. | |
| 87 void DidDirectoryExists(const StatusCallback& callback, | |
| 88 base::PlatformFileError rv, | |
| 89 const base::PlatformFileInfo& file_info, | |
| 90 const base::FilePath& unused); | |
| 91 void DidFileExists(const StatusCallback& callback, | |
| 92 base::PlatformFileError rv, | |
| 93 const base::PlatformFileInfo& file_info, | |
| 94 const base::FilePath& unused); | |
| 95 void DidGetMetadata(const GetMetadataCallback& callback, | |
| 96 base::PlatformFileError rv, | |
| 97 const base::PlatformFileInfo& file_info, | |
| 98 const base::FilePath& platform_path); | |
| 99 void DidReadDirectory(const ReadDirectoryCallback& callback, | |
| 100 base::PlatformFileError rv, | |
| 101 const std::vector<fileapi::DirectoryEntry>& entries, | |
| 102 bool has_more); | |
| 103 void DidWrite(base::PlatformFileError result, | |
| 104 int64 bytes, | |
| 105 FileWriterDelegate::WriteProgressStatus write_status); | |
| 106 void DidFinishFileOperation(const StatusCallback& callback, | |
| 107 base::PlatformFileError rv); | |
| 108 void DidCreateSnapshotFile( | |
| 109 const SnapshotFileCallback& callback, | |
| 110 base::PlatformFileError result, | |
| 111 const base::PlatformFileInfo& file_info, | |
| 112 const base::FilePath& platform_path, | |
| 113 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); | |
| 114 void DidOpenFile( | |
| 115 const fileapi::FileSystemURL& url, | |
| 116 const OpenFileCallback& callback, | |
| 117 base::PlatformFileError result, | |
| 118 base::PlatformFile file, | |
| 119 base::ProcessHandle peer_handle); | |
| 120 | |
| 121 | |
| 122 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy_; | |
| 123 // A flag to make sure we call operation only once per instance. | |
| 124 OperationType pending_operation_; | |
| 125 scoped_ptr<fileapi::FileWriterDelegate> file_writer_delegate_; | |
| 126 | |
| 127 WriteCallback write_callback_; | |
| 128 StatusCallback cancel_callback_; | |
| 129 | |
| 130 DISALLOW_COPY_AND_ASSIGN(RemoteFileSystemOperation); | |
| 131 }; | |
| 132 | |
| 133 } // namespace chromeos | |
| 134 | |
| 135 #endif // WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ | |
| OLD | NEW |