| 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_PROXY_H_ | |
| 6 #define WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "webkit/fileapi/file_system_operation.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class SequencedTaskRunner; | |
| 14 } // namespace base | |
| 15 | |
| 16 namespace webkit_blob { | |
| 17 class FileStreamReader; | |
| 18 } // namespace webkit_blob | |
| 19 | |
| 20 namespace fileapi { | |
| 21 | |
| 22 typedef base::Callback< | |
| 23 void(base::PlatformFileError result, | |
| 24 const base::FilePath& platform_path, | |
| 25 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)> | |
| 26 WritableSnapshotFile; | |
| 27 | |
| 28 // The interface class for remote file system proxy. | |
| 29 class RemoteFileSystemProxyInterface : | |
| 30 public base::RefCountedThreadSafe<RemoteFileSystemProxyInterface> { | |
| 31 public: | |
| 32 // Used for OpenFile(). |result| is the return code of the operation. | |
| 33 typedef base::Callback< | |
| 34 void(base::PlatformFileError result, | |
| 35 base::PlatformFile file, | |
| 36 base::ProcessHandle peer_handle)> OpenFileCallback; | |
| 37 | |
| 38 | |
| 39 // Gets the file or directory info for given|path|. | |
| 40 virtual void GetFileInfo(const FileSystemURL& url, | |
| 41 const FileSystemOperation::GetMetadataCallback& callback) = 0; | |
| 42 | |
| 43 // Copies a file or directory from |src_url| to |dest_url|. If | |
| 44 // |src_url| is a directory, the contents of |src_url| are copied to | |
| 45 // |dest_url| recursively. A new file or directory is created at | |
| 46 // |dest_url| as needed. | |
| 47 virtual void Copy( | |
| 48 const FileSystemURL& src_url, | |
| 49 const FileSystemURL& dest_url, | |
| 50 const FileSystemOperation::StatusCallback& callback) = 0; | |
| 51 | |
| 52 // Moves a file or directory from |src_url| to |dest_url|. A new file | |
| 53 // or directory is created at |dest_url| as needed. | |
| 54 virtual void Move( | |
| 55 const FileSystemURL& src_url, | |
| 56 const FileSystemURL& dest_url, | |
| 57 const FileSystemOperation::StatusCallback& callback) = 0; | |
| 58 | |
| 59 // Reads contents of a directory at |url|. | |
| 60 virtual void ReadDirectory(const FileSystemURL& url, | |
| 61 const FileSystemOperation::ReadDirectoryCallback& callback) = 0; | |
| 62 | |
| 63 // Removes a file or directory at |url|. If |recursive| is true, remove | |
| 64 // all files and directories under the directory at |url| recursively. | |
| 65 virtual void Remove(const FileSystemURL& url, bool recursive, | |
| 66 const FileSystemOperation::StatusCallback& callback) = 0; | |
| 67 | |
| 68 // Creates a directory at |url|. If |exclusive| is true, an error is | |
| 69 // raised in case a directory is already present at the URL. If | |
| 70 // |recursive| is true, create parent directories as needed just like | |
| 71 // mkdir -p does. | |
| 72 virtual void CreateDirectory( | |
| 73 const FileSystemURL& url, | |
| 74 bool exclusive, | |
| 75 bool recursive, | |
| 76 const FileSystemOperation::StatusCallback& callback) = 0; | |
| 77 | |
| 78 // Creates a file at |url|. If the flag |is_exclusive| is true, an | |
| 79 // error is raised when a file already exists at the path. It is | |
| 80 // an error if a directory or a hosted document is already present at the | |
| 81 // path, or the parent directory of the path is not present yet. | |
| 82 virtual void CreateFile( | |
| 83 const FileSystemURL& url, | |
| 84 bool exclusive, | |
| 85 const FileSystemOperation::StatusCallback& callback) = 0; | |
| 86 | |
| 87 // Changes the length of an existing file at |url| to |length|. If |length| | |
| 88 // is negative, an error is raised. If |length| is more than the current size | |
| 89 // of the file, zero is padded for the extended part. | |
| 90 virtual void Truncate( | |
| 91 const FileSystemURL& url, | |
| 92 int64 length, | |
| 93 const FileSystemOperation::StatusCallback& callback) = 0; | |
| 94 | |
| 95 // Creates a local snapshot file for a given |url| and returns the | |
| 96 // metadata and platform path of the snapshot file via |callback|. | |
| 97 // See also FileSystemOperation::CreateSnapshotFile(). | |
| 98 virtual void CreateSnapshotFile( | |
| 99 const FileSystemURL& url, | |
| 100 const FileSystemOperation::SnapshotFileCallback& callback) = 0; | |
| 101 | |
| 102 // Creates a local snapshot file for a given |url| and marks it for | |
| 103 // modification. A webkit_blob::ShareableFileReference is passed to | |
| 104 // |callback|, and when the reference is released, modification to the | |
| 105 // snapshot is marked for uploading to the remote file system. | |
| 106 virtual void CreateWritableSnapshotFile( | |
| 107 const FileSystemURL& url, | |
| 108 const WritableSnapshotFile& callback) = 0; | |
| 109 | |
| 110 // Opens file for a given |url| with specified |flags| (see | |
| 111 // base::PlatformFileFlags for details). | |
| 112 virtual void OpenFile( | |
| 113 const FileSystemURL& url, | |
| 114 int flags, | |
| 115 base::ProcessHandle peer_handle, | |
| 116 const OpenFileCallback& callback) = 0; | |
| 117 | |
| 118 // Notifies that a file opened by OpenFile (at |path|) is closed. | |
| 119 virtual void NotifyCloseFile(const FileSystemURL& url) = 0; | |
| 120 | |
| 121 // Modifies the timestamp of a given |url| to |last_access_time| and | |
| 122 // |last_modified_time|. Note that unlike 'touch' command of Linux, it | |
| 123 // does not create a new file. | |
| 124 virtual void TouchFile( | |
| 125 const FileSystemURL& url, | |
| 126 const base::Time& last_access_time, | |
| 127 const base::Time& last_modified_time, | |
| 128 const FileSystemOperation::StatusCallback& callback) = 0; | |
| 129 | |
| 130 // Creates a new file stream reader for the file at |url| with an |offset|. | |
| 131 // |expected_modification_time| specifies the expected last modification | |
| 132 // if it isn't null, and the reader will return ERR_UPLOAD_FILE_CHANGED error | |
| 133 // if the file has been modified. | |
| 134 // The error will be notified via error code of FileStreamReader's methods, | |
| 135 // and this method itself doesn't check if the file exists and is a regular | |
| 136 // file. | |
| 137 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader( | |
| 138 base::SequencedTaskRunner* file_task_runner, | |
| 139 const FileSystemURL& url, | |
| 140 int64 offset, | |
| 141 const base::Time& expected_modification_time) = 0; | |
| 142 | |
| 143 protected: | |
| 144 friend class base::RefCountedThreadSafe<RemoteFileSystemProxyInterface>; | |
| 145 virtual ~RemoteFileSystemProxyInterface() {} | |
| 146 }; | |
| 147 | |
| 148 } // namespace fileapi | |
| 149 | |
| 150 #endif // WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ | |
| OLD | NEW |