OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERF
ACE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/files/file.h" | 11 #include "base/files/file.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "webkit/browser/fileapi/async_file_util.h" | 14 #include "storage/browser/fileapi/async_file_util.h" |
15 | 15 |
16 class EventRouter; | 16 class EventRouter; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class Time; | 19 class Time; |
20 } // namespace base | 20 } // namespace base |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 class IOBuffer; | 23 class IOBuffer; |
24 } // namespace net | 24 } // namespace net |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 base::File::Error result)> GetMetadataCallback; | 58 base::File::Error result)> GetMetadataCallback; |
59 | 59 |
60 // Mode of opening a file. Used by OpenFile(). | 60 // Mode of opening a file. Used by OpenFile(). |
61 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE }; | 61 enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE }; |
62 | 62 |
63 virtual ~ProvidedFileSystemInterface() {} | 63 virtual ~ProvidedFileSystemInterface() {} |
64 | 64 |
65 // Requests unmounting of the file system. The callback is called when the | 65 // Requests unmounting of the file system. The callback is called when the |
66 // request is accepted or rejected, with an error code. | 66 // request is accepted or rejected, with an error code. |
67 virtual void RequestUnmount( | 67 virtual void RequestUnmount( |
68 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 68 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
69 | 69 |
70 // Requests metadata of the passed |entry_path|. It can be either a file | 70 // Requests metadata of the passed |entry_path|. It can be either a file |
71 // or a directory. | 71 // or a directory. |
72 virtual void GetMetadata(const base::FilePath& entry_path, | 72 virtual void GetMetadata(const base::FilePath& entry_path, |
73 const GetMetadataCallback& callback) = 0; | 73 const GetMetadataCallback& callback) = 0; |
74 | 74 |
75 // Requests enumerating entries from the passed |directory_path|. The callback | 75 // Requests enumerating entries from the passed |directory_path|. The callback |
76 // can be called multiple times until |has_more| is set to false. | 76 // can be called multiple times until |has_more| is set to false. |
77 virtual void ReadDirectory( | 77 virtual void ReadDirectory( |
78 const base::FilePath& directory_path, | 78 const base::FilePath& directory_path, |
79 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) = 0; | 79 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) = 0; |
80 | 80 |
81 // Requests opening a file at |file_path|. If the file doesn't exist, then the | 81 // Requests opening a file at |file_path|. If the file doesn't exist, then the |
82 // operation will fail. | 82 // operation will fail. |
83 virtual void OpenFile(const base::FilePath& file_path, | 83 virtual void OpenFile(const base::FilePath& file_path, |
84 OpenFileMode mode, | 84 OpenFileMode mode, |
85 const OpenFileCallback& callback) = 0; | 85 const OpenFileCallback& callback) = 0; |
86 | 86 |
87 // Requests closing a file, previously opened with OpenFile() as a file with | 87 // Requests closing a file, previously opened with OpenFile() as a file with |
88 // |file_handle|. For either succes or error |callback| must be called. | 88 // |file_handle|. For either succes or error |callback| must be called. |
89 virtual void CloseFile( | 89 virtual void CloseFile( |
90 int file_handle, | 90 int file_handle, |
91 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 91 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
92 | 92 |
93 // Requests reading a file previously opened with |file_handle|. The callback | 93 // Requests reading a file previously opened with |file_handle|. The callback |
94 // can be called multiple times until |has_more| is set to false. On success | 94 // can be called multiple times until |has_more| is set to false. On success |
95 // it should return |length| bytes starting from |offset| in total. It can | 95 // it should return |length| bytes starting from |offset| in total. It can |
96 // return less only in case EOF is encountered. | 96 // return less only in case EOF is encountered. |
97 virtual void ReadFile(int file_handle, | 97 virtual void ReadFile(int file_handle, |
98 net::IOBuffer* buffer, | 98 net::IOBuffer* buffer, |
99 int64 offset, | 99 int64 offset, |
100 int length, | 100 int length, |
101 const ReadChunkReceivedCallback& callback) = 0; | 101 const ReadChunkReceivedCallback& callback) = 0; |
102 | 102 |
103 // Requests creating a directory. If |recursive| is passed, then all non | 103 // Requests creating a directory. If |recursive| is passed, then all non |
104 // existing directories on the path will be created. If |exclusive| is true, | 104 // existing directories on the path will be created. If |exclusive| is true, |
105 // then creating the directory will fail, if it already exists. | 105 // then creating the directory will fail, if it already exists. |
106 virtual void CreateDirectory( | 106 virtual void CreateDirectory( |
107 const base::FilePath& directory_path, | 107 const base::FilePath& directory_path, |
108 bool exclusive, | 108 bool exclusive, |
109 bool recursive, | 109 bool recursive, |
110 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 110 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
111 | 111 |
112 // Requests creating a file. If the entry already exists, then the | 112 // Requests creating a file. If the entry already exists, then the |
113 // FILE_ERROR_EXISTS error must be returned. | 113 // FILE_ERROR_EXISTS error must be returned. |
114 virtual void CreateFile( | 114 virtual void CreateFile( |
115 const base::FilePath& file_path, | 115 const base::FilePath& file_path, |
116 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 116 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
117 | 117 |
118 // Requests deleting a directory. If |recursive| is passed and the entry is | 118 // Requests deleting a directory. If |recursive| is passed and the entry is |
119 // a directory, then all contents of it (recursively) will be deleted too. | 119 // a directory, then all contents of it (recursively) will be deleted too. |
120 virtual void DeleteEntry( | 120 virtual void DeleteEntry( |
121 const base::FilePath& entry_path, | 121 const base::FilePath& entry_path, |
122 bool recursive, | 122 bool recursive, |
123 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 123 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
124 | 124 |
125 // Requests copying an entry (recursively in case of a directory) within the | 125 // Requests copying an entry (recursively in case of a directory) within the |
126 // same file system. | 126 // same file system. |
127 virtual void CopyEntry( | 127 virtual void CopyEntry( |
128 const base::FilePath& source_path, | 128 const base::FilePath& source_path, |
129 const base::FilePath& target_path, | 129 const base::FilePath& target_path, |
130 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 130 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
131 | 131 |
132 // Requests moving an entry (recursively in case of a directory) within the | 132 // Requests moving an entry (recursively in case of a directory) within the |
133 // same file system. | 133 // same file system. |
134 virtual void MoveEntry( | 134 virtual void MoveEntry( |
135 const base::FilePath& source_path, | 135 const base::FilePath& source_path, |
136 const base::FilePath& target_path, | 136 const base::FilePath& target_path, |
137 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 137 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
138 | 138 |
139 // Requests truncating a file to the desired length. | 139 // Requests truncating a file to the desired length. |
140 virtual void Truncate( | 140 virtual void Truncate( |
141 const base::FilePath& file_path, | 141 const base::FilePath& file_path, |
142 int64 length, | 142 int64 length, |
143 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 143 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
144 | 144 |
145 // Requests writing to a file previously opened with |file_handle|. | 145 // Requests writing to a file previously opened with |file_handle|. |
146 virtual void WriteFile( | 146 virtual void WriteFile( |
147 int file_handle, | 147 int file_handle, |
148 net::IOBuffer* buffer, | 148 net::IOBuffer* buffer, |
149 int64 offset, | 149 int64 offset, |
150 int length, | 150 int length, |
151 const fileapi::AsyncFileUtil::StatusCallback& callback) = 0; | 151 const storage::AsyncFileUtil::StatusCallback& callback) = 0; |
152 | 152 |
153 // Returns a provided file system info for this file system. | 153 // Returns a provided file system info for this file system. |
154 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0; | 154 virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0; |
155 | 155 |
156 // Returns a request manager for the file system. | 156 // Returns a request manager for the file system. |
157 virtual RequestManager* GetRequestManager() = 0; | 157 virtual RequestManager* GetRequestManager() = 0; |
158 | 158 |
159 // Returns a weak pointer to this object. | 159 // Returns a weak pointer to this object. |
160 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() = 0; | 160 virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() = 0; |
161 }; | 161 }; |
162 | 162 |
163 } // namespace file_system_provider | 163 } // namespace file_system_provider |
164 } // namespace chromeos | 164 } // namespace chromeos |
165 | 165 |
166 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT
ERFACE_H_ | 166 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INT
ERFACE_H_ |
OLD | NEW |