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 WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ | 5 #ifndef WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ |
6 #define WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ | 6 #define WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ |
7 | 7 |
| 8 #include "base/memory/weak_ptr.h" |
8 #include "webkit/browser/fileapi/file_system_operation.h" | 9 #include "webkit/browser/fileapi/file_system_operation.h" |
9 #include "webkit/browser/fileapi/file_writer_delegate.h" | 10 #include "webkit/browser/fileapi/file_writer_delegate.h" |
10 #include "webkit/browser/fileapi/remote_file_system_proxy.h" | 11 #include "webkit/browser/fileapi/remote_file_system_proxy.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class Value; | 14 class Value; |
14 } | 15 } |
15 | 16 |
16 namespace fileapi { | 17 namespace fileapi { |
17 class FileWriterDelegate; | 18 class FileWriterDelegate; |
18 class LocalFileSystemOperation; | 19 class LocalFileSystemOperation; |
19 } | 20 } |
20 | 21 |
21 namespace chromeos { | 22 namespace chromeos { |
22 | 23 |
23 // FileSystemOperation implementation for local file systems. | 24 // FileSystemOperation implementation for local file systems. |
24 class RemoteFileSystemOperation : public fileapi::FileSystemOperation { | 25 class RemoteFileSystemOperation |
| 26 : public fileapi::FileSystemOperation, |
| 27 public base::SupportsWeakPtr<RemoteFileSystemOperation> { |
25 public: | 28 public: |
26 typedef fileapi::FileWriterDelegate FileWriterDelegate; | 29 typedef fileapi::FileWriterDelegate FileWriterDelegate; |
27 virtual ~RemoteFileSystemOperation(); | 30 virtual ~RemoteFileSystemOperation(); |
28 | 31 |
29 // FileSystemOperation overrides. | 32 // FileSystemOperation overrides. |
30 virtual void CreateFile(const fileapi::FileSystemURL& url, | 33 virtual void CreateFile(const fileapi::FileSystemURL& url, |
31 bool exclusive, | 34 bool exclusive, |
32 const StatusCallback& callback) OVERRIDE; | 35 const StatusCallback& callback) OVERRIDE; |
33 virtual void CreateDirectory(const fileapi::FileSystemURL& url, | 36 virtual void CreateDirectory(const fileapi::FileSystemURL& url, |
34 bool exclusive, | 37 bool exclusive, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 88 |
86 // Generic callback that translates platform errors to WebKit error codes. | 89 // Generic callback that translates platform errors to WebKit error codes. |
87 void DidDirectoryExists(const StatusCallback& callback, | 90 void DidDirectoryExists(const StatusCallback& callback, |
88 base::PlatformFileError rv, | 91 base::PlatformFileError rv, |
89 const base::PlatformFileInfo& file_info, | 92 const base::PlatformFileInfo& file_info, |
90 const base::FilePath& unused); | 93 const base::FilePath& unused); |
91 void DidFileExists(const StatusCallback& callback, | 94 void DidFileExists(const StatusCallback& callback, |
92 base::PlatformFileError rv, | 95 base::PlatformFileError rv, |
93 const base::PlatformFileInfo& file_info, | 96 const base::PlatformFileInfo& file_info, |
94 const base::FilePath& unused); | 97 const base::FilePath& unused); |
95 void DidGetMetadata(const GetMetadataCallback& callback, | 98 void DidWrite(const WriteCallback& write_callback, |
96 base::PlatformFileError rv, | 99 base::PlatformFileError result, |
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, | 100 int64 bytes, |
105 FileWriterDelegate::WriteProgressStatus write_status); | 101 FileWriterDelegate::WriteProgressStatus write_status); |
106 void DidFinishFileOperation(const StatusCallback& callback, | 102 void DidFinishFileOperation(const StatusCallback& callback, |
107 base::PlatformFileError rv); | 103 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( | 104 void DidOpenFile( |
115 const fileapi::FileSystemURL& url, | 105 const fileapi::FileSystemURL& url, |
116 const OpenFileCallback& callback, | 106 const OpenFileCallback& callback, |
117 base::PlatformFileError result, | 107 base::PlatformFileError result, |
118 base::PlatformFile file, | 108 base::PlatformFile file, |
119 base::ProcessHandle peer_handle); | 109 base::ProcessHandle peer_handle); |
120 | 110 |
121 | |
122 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy_; | 111 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy_; |
123 // A flag to make sure we call operation only once per instance. | 112 // A flag to make sure we call operation only once per instance. |
124 OperationType pending_operation_; | 113 OperationType pending_operation_; |
125 scoped_ptr<fileapi::FileWriterDelegate> file_writer_delegate_; | 114 scoped_ptr<fileapi::FileWriterDelegate> file_writer_delegate_; |
126 | 115 |
127 WriteCallback write_callback_; | |
128 StatusCallback cancel_callback_; | 116 StatusCallback cancel_callback_; |
129 | 117 |
130 DISALLOW_COPY_AND_ASSIGN(RemoteFileSystemOperation); | 118 DISALLOW_COPY_AND_ASSIGN(RemoteFileSystemOperation); |
131 }; | 119 }; |
132 | 120 |
133 } // namespace chromeos | 121 } // namespace chromeos |
134 | 122 |
135 #endif // WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ | 123 #endif // WEBKIT_BROWSER_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_ |
OLD | NEW |