| 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_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ | 5 #ifndef WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ |
| 6 #define WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ | 6 #define WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "webkit/fileapi/file_system_operation_interface.h" | 10 #include "webkit/fileapi/file_system_operation.h" |
| 11 | 11 |
| 12 namespace fileapi { | 12 namespace fileapi { |
| 13 | 13 |
| 14 typedef base::Callback< | 14 typedef base::Callback< |
| 15 void(base::PlatformFileError result, | 15 void(base::PlatformFileError result, |
| 16 const FilePath& platform_path, | 16 const FilePath& platform_path, |
| 17 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)> | 17 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)> |
| 18 WritableSnapshotFile; | 18 WritableSnapshotFile; |
| 19 | 19 |
| 20 // The interface class for remote file system proxy. | 20 // The interface class for remote file system proxy. |
| 21 class RemoteFileSystemProxyInterface : | 21 class RemoteFileSystemProxyInterface : |
| 22 public base::RefCountedThreadSafe<RemoteFileSystemProxyInterface> { | 22 public base::RefCountedThreadSafe<RemoteFileSystemProxyInterface> { |
| 23 public: | 23 public: |
| 24 // Gets the file or directory info for given|path|. | 24 // Gets the file or directory info for given|path|. |
| 25 virtual void GetFileInfo(const FileSystemURL& url, | 25 virtual void GetFileInfo(const FileSystemURL& url, |
| 26 const FileSystemOperationInterface::GetMetadataCallback& callback) = 0; | 26 const FileSystemOperation::GetMetadataCallback& callback) = 0; |
| 27 | 27 |
| 28 // Copies a file or directory from |src_url| to |dest_url|. If | 28 // Copies a file or directory from |src_url| to |dest_url|. If |
| 29 // |src_url| is a directory, the contents of |src_url| are copied to | 29 // |src_url| is a directory, the contents of |src_url| are copied to |
| 30 // |dest_url| recursively. A new file or directory is created at | 30 // |dest_url| recursively. A new file or directory is created at |
| 31 // |dest_url| as needed. | 31 // |dest_url| as needed. |
| 32 virtual void Copy( | 32 virtual void Copy( |
| 33 const FileSystemURL& src_url, | 33 const FileSystemURL& src_url, |
| 34 const FileSystemURL& dest_url, | 34 const FileSystemURL& dest_url, |
| 35 const FileSystemOperationInterface::StatusCallback& callback) = 0; | 35 const FileSystemOperation::StatusCallback& callback) = 0; |
| 36 | 36 |
| 37 // Moves a file or directory from |src_url| to |dest_url|. A new file | 37 // Moves a file or directory from |src_url| to |dest_url|. A new file |
| 38 // or directory is created at |dest_url| as needed. | 38 // or directory is created at |dest_url| as needed. |
| 39 virtual void Move( | 39 virtual void Move( |
| 40 const FileSystemURL& src_url, | 40 const FileSystemURL& src_url, |
| 41 const FileSystemURL& dest_url, | 41 const FileSystemURL& dest_url, |
| 42 const FileSystemOperationInterface::StatusCallback& callback) = 0; | 42 const FileSystemOperation::StatusCallback& callback) = 0; |
| 43 | 43 |
| 44 // Reads contents of a directory at |url|. | 44 // Reads contents of a directory at |url|. |
| 45 virtual void ReadDirectory(const FileSystemURL& url, | 45 virtual void ReadDirectory(const FileSystemURL& url, |
| 46 const FileSystemOperationInterface::ReadDirectoryCallback& callback) = 0; | 46 const FileSystemOperation::ReadDirectoryCallback& callback) = 0; |
| 47 | 47 |
| 48 // Removes a file or directory at |url|. If |recursive| is true, remove | 48 // Removes a file or directory at |url|. If |recursive| is true, remove |
| 49 // all files and directories under the directory at |url| recursively. | 49 // all files and directories under the directory at |url| recursively. |
| 50 virtual void Remove(const FileSystemURL& url, bool recursive, | 50 virtual void Remove(const FileSystemURL& url, bool recursive, |
| 51 const FileSystemOperationInterface::StatusCallback& callback) = 0; | 51 const FileSystemOperation::StatusCallback& callback) = 0; |
| 52 | 52 |
| 53 // Creates a directory at |url|. If |exclusive| is true, an error is | 53 // Creates a directory at |url|. If |exclusive| is true, an error is |
| 54 // raised in case a directory is already present at the URL. If | 54 // raised in case a directory is already present at the URL. If |
| 55 // |recursive| is true, create parent directories as needed just like | 55 // |recursive| is true, create parent directories as needed just like |
| 56 // mkdir -p does. | 56 // mkdir -p does. |
| 57 virtual void CreateDirectory( | 57 virtual void CreateDirectory( |
| 58 const FileSystemURL& url, | 58 const FileSystemURL& url, |
| 59 bool exclusive, | 59 bool exclusive, |
| 60 bool recursive, | 60 bool recursive, |
| 61 const FileSystemOperationInterface::StatusCallback& callback) = 0; | 61 const FileSystemOperation::StatusCallback& callback) = 0; |
| 62 | 62 |
| 63 // Creates a file at |url|. If the flag |is_exclusive| is true, an | 63 // Creates a file at |url|. If the flag |is_exclusive| is true, an |
| 64 // error is raised when a file already exists at the path. It is | 64 // error is raised when a file already exists at the path. It is |
| 65 // an error if a directory or a hosted document is already present at the | 65 // an error if a directory or a hosted document is already present at the |
| 66 // path, or the parent directory of the path is not present yet. | 66 // path, or the parent directory of the path is not present yet. |
| 67 virtual void CreateFile( | 67 virtual void CreateFile( |
| 68 const FileSystemURL& url, | 68 const FileSystemURL& url, |
| 69 bool exclusive, | 69 bool exclusive, |
| 70 const FileSystemOperationInterface::StatusCallback& callback) = 0; | 70 const FileSystemOperation::StatusCallback& callback) = 0; |
| 71 | 71 |
| 72 // Changes the length of an existing file at |url| to |length|. If |length| | 72 // Changes the length of an existing file at |url| to |length|. If |length| |
| 73 // is negative, an error is raised. If |length| is more than the current size | 73 // is negative, an error is raised. If |length| is more than the current size |
| 74 // of the file, zero is padded for the extended part. | 74 // of the file, zero is padded for the extended part. |
| 75 virtual void Truncate( | 75 virtual void Truncate( |
| 76 const FileSystemURL& url, | 76 const FileSystemURL& url, |
| 77 int64 length, | 77 int64 length, |
| 78 const FileSystemOperationInterface::StatusCallback& callback) = 0; | 78 const FileSystemOperation::StatusCallback& callback) = 0; |
| 79 | 79 |
| 80 // Creates a local snapshot file for a given |url| and returns the | 80 // Creates a local snapshot file for a given |url| and returns the |
| 81 // metadata and platform path of the snapshot file via |callback|. | 81 // metadata and platform path of the snapshot file via |callback|. |
| 82 // See also FileSystemOperationInterface::CreateSnapshotFile(). | 82 // See also FileSystemOperation::CreateSnapshotFile(). |
| 83 virtual void CreateSnapshotFile( | 83 virtual void CreateSnapshotFile( |
| 84 const FileSystemURL& url, | 84 const FileSystemURL& url, |
| 85 const FileSystemOperationInterface::SnapshotFileCallback& callback) = 0; | 85 const FileSystemOperation::SnapshotFileCallback& callback) = 0; |
| 86 | 86 |
| 87 // Creates a local snapshot file for a given |url| and marks it for | 87 // Creates a local snapshot file for a given |url| and marks it for |
| 88 // modification. A webkit_blob::ShareableFileReference is passed to | 88 // modification. A webkit_blob::ShareableFileReference is passed to |
| 89 // |callback|, and when the reference is released, modification to the | 89 // |callback|, and when the reference is released, modification to the |
| 90 // snapshot is marked for uploading to the remote file system. | 90 // snapshot is marked for uploading to the remote file system. |
| 91 virtual void CreateWritableSnapshotFile( | 91 virtual void CreateWritableSnapshotFile( |
| 92 const FileSystemURL& url, | 92 const FileSystemURL& url, |
| 93 const WritableSnapshotFile& callback) = 0; | 93 const WritableSnapshotFile& callback) = 0; |
| 94 | 94 |
| 95 // Opens file for a given |url| with specified |flags| (see | 95 // Opens file for a given |url| with specified |flags| (see |
| 96 // base::PlatformFileFlags for details). | 96 // base::PlatformFileFlags for details). |
| 97 virtual void OpenFile( | 97 virtual void OpenFile( |
| 98 const FileSystemURL& url, | 98 const FileSystemURL& url, |
| 99 int flags, | 99 int flags, |
| 100 base::ProcessHandle peer_handle, | 100 base::ProcessHandle peer_handle, |
| 101 const FileSystemOperationInterface::OpenFileCallback& callback) = 0; | 101 const FileSystemOperation::OpenFileCallback& callback) = 0; |
| 102 | 102 |
| 103 // Notifies that a file opened by OpenFile (at |path|) is closed. | 103 // Notifies that a file opened by OpenFile (at |path|) is closed. |
| 104 virtual void NotifyCloseFile(const FileSystemURL& url) = 0; | 104 virtual void NotifyCloseFile(const FileSystemURL& url) = 0; |
| 105 | 105 |
| 106 // TODO(zelidrag): More methods to follow as we implement other parts of FSO. | 106 // TODO(zelidrag): More methods to follow as we implement other parts of FSO. |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 friend class base::RefCountedThreadSafe<RemoteFileSystemProxyInterface>; | 109 friend class base::RefCountedThreadSafe<RemoteFileSystemProxyInterface>; |
| 110 virtual ~RemoteFileSystemProxyInterface() {} | 110 virtual ~RemoteFileSystemProxyInterface() {} |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 } // namespace fileapi | 113 } // namespace fileapi |
| 114 | 114 |
| 115 #endif // WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ | 115 #endif // WEBKIT_CHROMEOS_FILEAPI_REMOTE_FILE_SYSTEM_PROXY_H_ |
| OLD | NEW |