Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / webkit / chromeos / fileapi / remote_file_system_operation.h
blobba429c1a0d8ecf1d768a9478b37efe0ee62c904f
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.
5 #ifndef WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_
6 #define WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_
8 #include "webkit/fileapi/file_system_operation.h"
9 #include "webkit/fileapi/file_writer_delegate.h"
10 #include "webkit/fileapi/remote_file_system_proxy.h"
12 namespace base {
13 class Value;
16 namespace fileapi {
17 class FileWriterDelegate;
18 class LocalFileSystemOperation;
21 namespace chromeos {
23 // FileSystemOperation implementation for local file systems.
24 class RemoteFileSystemOperation : public fileapi::FileSystemOperation {
25 public:
26 typedef fileapi::FileWriterDelegate FileWriterDelegate;
27 virtual ~RemoteFileSystemOperation();
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 void NotifyCloseFile(const fileapi::FileSystemURL& url) OVERRIDE;
71 virtual fileapi::LocalFileSystemOperation*
72 AsLocalFileSystemOperation() OVERRIDE;
73 virtual void CreateSnapshotFile(
74 const fileapi::FileSystemURL& url,
75 const SnapshotFileCallback& callback) OVERRIDE;
77 private:
78 friend class CrosMountPointProvider;
80 RemoteFileSystemOperation(
81 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy);
83 // Used only for internal assertions.
84 // Returns false if there's another inflight pending operation.
85 bool SetPendingOperationType(OperationType type);
87 // Generic callback that translates platform errors to WebKit error codes.
88 void DidDirectoryExists(const StatusCallback& callback,
89 base::PlatformFileError rv,
90 const base::PlatformFileInfo& file_info,
91 const base::FilePath& unused);
92 void DidFileExists(const StatusCallback& callback,
93 base::PlatformFileError rv,
94 const base::PlatformFileInfo& file_info,
95 const base::FilePath& unused);
96 void DidGetMetadata(const GetMetadataCallback& callback,
97 base::PlatformFileError rv,
98 const base::PlatformFileInfo& file_info,
99 const base::FilePath& platform_path);
100 void DidReadDirectory(
101 const ReadDirectoryCallback& callback,
102 base::PlatformFileError rv,
103 const std::vector<base::FileUtilProxy::Entry>& entries,
104 bool has_more);
105 void DidWrite(base::PlatformFileError result,
106 int64 bytes,
107 FileWriterDelegate::WriteProgressStatus write_status);
108 void DidFinishFileOperation(const StatusCallback& callback,
109 base::PlatformFileError rv);
110 void DidCreateSnapshotFile(
111 const SnapshotFileCallback& callback,
112 base::PlatformFileError result,
113 const base::PlatformFileInfo& file_info,
114 const base::FilePath& platform_path,
115 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
116 void DidOpenFile(
117 const OpenFileCallback& callback,
118 base::PlatformFileError result,
119 base::PlatformFile file,
120 base::ProcessHandle peer_handle);
123 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy_;
124 // A flag to make sure we call operation only once per instance.
125 OperationType pending_operation_;
126 scoped_ptr<fileapi::FileWriterDelegate> file_writer_delegate_;
128 WriteCallback write_callback_;
129 StatusCallback cancel_callback_;
131 DISALLOW_COPY_AND_ASSIGN(RemoteFileSystemOperation);
134 } // namespace chromeos
136 #endif // WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_OPERATION_H_