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 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" | 5 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 ProvidedFileSystem::~ProvidedFileSystem() { | 57 ProvidedFileSystem::~ProvidedFileSystem() { |
58 const std::vector<int> request_ids = request_manager_.GetActiveRequestIds(); | 58 const std::vector<int> request_ids = request_manager_.GetActiveRequestIds(); |
59 for (size_t i = 0; i < request_ids.size(); ++i) { | 59 for (size_t i = 0; i < request_ids.size(); ++i) { |
60 Abort(request_ids[i], base::Bind(&EmptyStatusCallback)); | 60 Abort(request_ids[i], base::Bind(&EmptyStatusCallback)); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 ProvidedFileSystem::AbortCallback ProvidedFileSystem::RequestUnmount( | 64 ProvidedFileSystem::AbortCallback ProvidedFileSystem::RequestUnmount( |
65 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 65 const storage::AsyncFileUtil::StatusCallback& callback) { |
66 const int request_id = request_manager_.CreateRequest( | 66 const int request_id = request_manager_.CreateRequest( |
67 REQUEST_UNMOUNT, | 67 REQUEST_UNMOUNT, |
68 scoped_ptr<RequestManager::HandlerInterface>( | 68 scoped_ptr<RequestManager::HandlerInterface>( |
69 new operations::Unmount(event_router_, file_system_info_, callback))); | 69 new operations::Unmount(event_router_, file_system_info_, callback))); |
70 if (!request_id) { | 70 if (!request_id) { |
71 callback.Run(base::File::FILE_ERROR_SECURITY); | 71 callback.Run(base::File::FILE_ERROR_SECURITY); |
72 return AbortCallback(); | 72 return AbortCallback(); |
73 } | 73 } |
74 | 74 |
75 return base::Bind( | 75 return base::Bind( |
(...skipping 11 matching lines...) Expand all Loading... |
87 callback.Run(EntryMetadata(), base::File::FILE_ERROR_SECURITY); | 87 callback.Run(EntryMetadata(), base::File::FILE_ERROR_SECURITY); |
88 return AbortCallback(); | 88 return AbortCallback(); |
89 } | 89 } |
90 | 90 |
91 return base::Bind( | 91 return base::Bind( |
92 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 92 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
93 } | 93 } |
94 | 94 |
95 ProvidedFileSystem::AbortCallback ProvidedFileSystem::ReadDirectory( | 95 ProvidedFileSystem::AbortCallback ProvidedFileSystem::ReadDirectory( |
96 const base::FilePath& directory_path, | 96 const base::FilePath& directory_path, |
97 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { | 97 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) { |
98 const int request_id = request_manager_.CreateRequest( | 98 const int request_id = request_manager_.CreateRequest( |
99 READ_DIRECTORY, | 99 READ_DIRECTORY, |
100 scoped_ptr<RequestManager::HandlerInterface>( | 100 scoped_ptr<RequestManager::HandlerInterface>( |
101 new operations::ReadDirectory( | 101 new operations::ReadDirectory( |
102 event_router_, file_system_info_, directory_path, callback))); | 102 event_router_, file_system_info_, directory_path, callback))); |
103 if (!request_id) { | 103 if (!request_id) { |
104 callback.Run(base::File::FILE_ERROR_SECURITY, | 104 callback.Run(base::File::FILE_ERROR_SECURITY, |
105 fileapi::AsyncFileUtil::EntryList(), | 105 storage::AsyncFileUtil::EntryList(), |
106 false /* has_more */); | 106 false /* has_more */); |
107 return AbortCallback(); | 107 return AbortCallback(); |
108 } | 108 } |
109 | 109 |
110 return base::Bind( | 110 return base::Bind( |
111 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 111 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
112 } | 112 } |
113 | 113 |
114 ProvidedFileSystem::AbortCallback ProvidedFileSystem::ReadFile( | 114 ProvidedFileSystem::AbortCallback ProvidedFileSystem::ReadFile( |
115 int file_handle, | 115 int file_handle, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY); | 152 callback.Run(0 /* file_handle */, base::File::FILE_ERROR_SECURITY); |
153 return AbortCallback(); | 153 return AbortCallback(); |
154 } | 154 } |
155 | 155 |
156 return base::Bind( | 156 return base::Bind( |
157 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 157 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
158 } | 158 } |
159 | 159 |
160 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CloseFile( | 160 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CloseFile( |
161 int file_handle, | 161 int file_handle, |
162 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 162 const storage::AsyncFileUtil::StatusCallback& callback) { |
163 const int request_id = request_manager_.CreateRequest( | 163 const int request_id = request_manager_.CreateRequest( |
164 CLOSE_FILE, | 164 CLOSE_FILE, |
165 scoped_ptr<RequestManager::HandlerInterface>(new operations::CloseFile( | 165 scoped_ptr<RequestManager::HandlerInterface>(new operations::CloseFile( |
166 event_router_, file_system_info_, file_handle, callback))); | 166 event_router_, file_system_info_, file_handle, callback))); |
167 if (!request_id) { | 167 if (!request_id) { |
168 callback.Run(base::File::FILE_ERROR_SECURITY); | 168 callback.Run(base::File::FILE_ERROR_SECURITY); |
169 return AbortCallback(); | 169 return AbortCallback(); |
170 } | 170 } |
171 | 171 |
172 return base::Bind( | 172 return base::Bind( |
173 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 173 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
174 } | 174 } |
175 | 175 |
176 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CreateDirectory( | 176 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CreateDirectory( |
177 const base::FilePath& directory_path, | 177 const base::FilePath& directory_path, |
178 bool exclusive, | 178 bool exclusive, |
179 bool recursive, | 179 bool recursive, |
180 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 180 const storage::AsyncFileUtil::StatusCallback& callback) { |
181 const int request_id = request_manager_.CreateRequest( | 181 const int request_id = request_manager_.CreateRequest( |
182 CREATE_DIRECTORY, | 182 CREATE_DIRECTORY, |
183 scoped_ptr<RequestManager::HandlerInterface>( | 183 scoped_ptr<RequestManager::HandlerInterface>( |
184 new operations::CreateDirectory(event_router_, | 184 new operations::CreateDirectory(event_router_, |
185 file_system_info_, | 185 file_system_info_, |
186 directory_path, | 186 directory_path, |
187 exclusive, | 187 exclusive, |
188 recursive, | 188 recursive, |
189 callback))); | 189 callback))); |
190 if (!request_id) { | 190 if (!request_id) { |
191 callback.Run(base::File::FILE_ERROR_SECURITY); | 191 callback.Run(base::File::FILE_ERROR_SECURITY); |
192 return AbortCallback(); | 192 return AbortCallback(); |
193 } | 193 } |
194 | 194 |
195 return base::Bind( | 195 return base::Bind( |
196 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 196 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
197 } | 197 } |
198 | 198 |
199 ProvidedFileSystem::AbortCallback ProvidedFileSystem::DeleteEntry( | 199 ProvidedFileSystem::AbortCallback ProvidedFileSystem::DeleteEntry( |
200 const base::FilePath& entry_path, | 200 const base::FilePath& entry_path, |
201 bool recursive, | 201 bool recursive, |
202 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 202 const storage::AsyncFileUtil::StatusCallback& callback) { |
203 const int request_id = request_manager_.CreateRequest( | 203 const int request_id = request_manager_.CreateRequest( |
204 DELETE_ENTRY, | 204 DELETE_ENTRY, |
205 scoped_ptr<RequestManager::HandlerInterface>(new operations::DeleteEntry( | 205 scoped_ptr<RequestManager::HandlerInterface>(new operations::DeleteEntry( |
206 event_router_, file_system_info_, entry_path, recursive, callback))); | 206 event_router_, file_system_info_, entry_path, recursive, callback))); |
207 if (!request_id) { | 207 if (!request_id) { |
208 callback.Run(base::File::FILE_ERROR_SECURITY); | 208 callback.Run(base::File::FILE_ERROR_SECURITY); |
209 return AbortCallback(); | 209 return AbortCallback(); |
210 } | 210 } |
211 | 211 |
212 return base::Bind( | 212 return base::Bind( |
213 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 213 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
214 } | 214 } |
215 | 215 |
216 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CreateFile( | 216 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CreateFile( |
217 const base::FilePath& file_path, | 217 const base::FilePath& file_path, |
218 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 218 const storage::AsyncFileUtil::StatusCallback& callback) { |
219 const int request_id = request_manager_.CreateRequest( | 219 const int request_id = request_manager_.CreateRequest( |
220 CREATE_FILE, | 220 CREATE_FILE, |
221 scoped_ptr<RequestManager::HandlerInterface>(new operations::CreateFile( | 221 scoped_ptr<RequestManager::HandlerInterface>(new operations::CreateFile( |
222 event_router_, file_system_info_, file_path, callback))); | 222 event_router_, file_system_info_, file_path, callback))); |
223 if (!request_id) { | 223 if (!request_id) { |
224 callback.Run(base::File::FILE_ERROR_SECURITY); | 224 callback.Run(base::File::FILE_ERROR_SECURITY); |
225 return AbortCallback(); | 225 return AbortCallback(); |
226 } | 226 } |
227 | 227 |
228 return base::Bind( | 228 return base::Bind( |
229 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 229 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
230 } | 230 } |
231 | 231 |
232 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CopyEntry( | 232 ProvidedFileSystem::AbortCallback ProvidedFileSystem::CopyEntry( |
233 const base::FilePath& source_path, | 233 const base::FilePath& source_path, |
234 const base::FilePath& target_path, | 234 const base::FilePath& target_path, |
235 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 235 const storage::AsyncFileUtil::StatusCallback& callback) { |
236 const int request_id = request_manager_.CreateRequest( | 236 const int request_id = request_manager_.CreateRequest( |
237 COPY_ENTRY, | 237 COPY_ENTRY, |
238 scoped_ptr<RequestManager::HandlerInterface>( | 238 scoped_ptr<RequestManager::HandlerInterface>( |
239 new operations::CopyEntry(event_router_, | 239 new operations::CopyEntry(event_router_, |
240 file_system_info_, | 240 file_system_info_, |
241 source_path, | 241 source_path, |
242 target_path, | 242 target_path, |
243 callback))); | 243 callback))); |
244 if (!request_id) { | 244 if (!request_id) { |
245 callback.Run(base::File::FILE_ERROR_SECURITY); | 245 callback.Run(base::File::FILE_ERROR_SECURITY); |
246 return AbortCallback(); | 246 return AbortCallback(); |
247 } | 247 } |
248 | 248 |
249 return base::Bind( | 249 return base::Bind( |
250 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 250 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
251 } | 251 } |
252 | 252 |
253 ProvidedFileSystem::AbortCallback ProvidedFileSystem::WriteFile( | 253 ProvidedFileSystem::AbortCallback ProvidedFileSystem::WriteFile( |
254 int file_handle, | 254 int file_handle, |
255 net::IOBuffer* buffer, | 255 net::IOBuffer* buffer, |
256 int64 offset, | 256 int64 offset, |
257 int length, | 257 int length, |
258 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 258 const storage::AsyncFileUtil::StatusCallback& callback) { |
259 TRACE_EVENT1("file_system_provider", | 259 TRACE_EVENT1("file_system_provider", |
260 "ProvidedFileSystem::WriteFile", | 260 "ProvidedFileSystem::WriteFile", |
261 "length", | 261 "length", |
262 length); | 262 length); |
263 const int request_id = request_manager_.CreateRequest( | 263 const int request_id = request_manager_.CreateRequest( |
264 WRITE_FILE, | 264 WRITE_FILE, |
265 make_scoped_ptr<RequestManager::HandlerInterface>( | 265 make_scoped_ptr<RequestManager::HandlerInterface>( |
266 new operations::WriteFile(event_router_, | 266 new operations::WriteFile(event_router_, |
267 file_system_info_, | 267 file_system_info_, |
268 file_handle, | 268 file_handle, |
269 make_scoped_refptr(buffer), | 269 make_scoped_refptr(buffer), |
270 offset, | 270 offset, |
271 length, | 271 length, |
272 callback))); | 272 callback))); |
273 if (!request_id) { | 273 if (!request_id) { |
274 callback.Run(base::File::FILE_ERROR_SECURITY); | 274 callback.Run(base::File::FILE_ERROR_SECURITY); |
275 return AbortCallback(); | 275 return AbortCallback(); |
276 } | 276 } |
277 | 277 |
278 return base::Bind( | 278 return base::Bind( |
279 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 279 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
280 } | 280 } |
281 | 281 |
282 ProvidedFileSystem::AbortCallback ProvidedFileSystem::MoveEntry( | 282 ProvidedFileSystem::AbortCallback ProvidedFileSystem::MoveEntry( |
283 const base::FilePath& source_path, | 283 const base::FilePath& source_path, |
284 const base::FilePath& target_path, | 284 const base::FilePath& target_path, |
285 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 285 const storage::AsyncFileUtil::StatusCallback& callback) { |
286 const int request_id = request_manager_.CreateRequest( | 286 const int request_id = request_manager_.CreateRequest( |
287 MOVE_ENTRY, | 287 MOVE_ENTRY, |
288 scoped_ptr<RequestManager::HandlerInterface>( | 288 scoped_ptr<RequestManager::HandlerInterface>( |
289 new operations::MoveEntry(event_router_, | 289 new operations::MoveEntry(event_router_, |
290 file_system_info_, | 290 file_system_info_, |
291 source_path, | 291 source_path, |
292 target_path, | 292 target_path, |
293 callback))); | 293 callback))); |
294 if (!request_id) { | 294 if (!request_id) { |
295 callback.Run(base::File::FILE_ERROR_SECURITY); | 295 callback.Run(base::File::FILE_ERROR_SECURITY); |
296 return AbortCallback(); | 296 return AbortCallback(); |
297 } | 297 } |
298 | 298 |
299 return base::Bind( | 299 return base::Bind( |
300 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 300 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
301 } | 301 } |
302 | 302 |
303 ProvidedFileSystem::AbortCallback ProvidedFileSystem::Truncate( | 303 ProvidedFileSystem::AbortCallback ProvidedFileSystem::Truncate( |
304 const base::FilePath& file_path, | 304 const base::FilePath& file_path, |
305 int64 length, | 305 int64 length, |
306 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 306 const storage::AsyncFileUtil::StatusCallback& callback) { |
307 const int request_id = request_manager_.CreateRequest( | 307 const int request_id = request_manager_.CreateRequest( |
308 TRUNCATE, | 308 TRUNCATE, |
309 scoped_ptr<RequestManager::HandlerInterface>(new operations::Truncate( | 309 scoped_ptr<RequestManager::HandlerInterface>(new operations::Truncate( |
310 event_router_, file_system_info_, file_path, length, callback))); | 310 event_router_, file_system_info_, file_path, length, callback))); |
311 if (!request_id) { | 311 if (!request_id) { |
312 callback.Run(base::File::FILE_ERROR_SECURITY); | 312 callback.Run(base::File::FILE_ERROR_SECURITY); |
313 return AbortCallback(); | 313 return AbortCallback(); |
314 } | 314 } |
315 | 315 |
316 return base::Bind( | 316 return base::Bind( |
317 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); | 317 &ProvidedFileSystem::Abort, weak_ptr_factory_.GetWeakPtr(), request_id); |
318 } | 318 } |
319 | 319 |
320 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { | 320 const ProvidedFileSystemInfo& ProvidedFileSystem::GetFileSystemInfo() const { |
321 return file_system_info_; | 321 return file_system_info_; |
322 } | 322 } |
323 | 323 |
324 RequestManager* ProvidedFileSystem::GetRequestManager() { | 324 RequestManager* ProvidedFileSystem::GetRequestManager() { |
325 return &request_manager_; | 325 return &request_manager_; |
326 } | 326 } |
327 | 327 |
328 base::WeakPtr<ProvidedFileSystemInterface> ProvidedFileSystem::GetWeakPtr() { | 328 base::WeakPtr<ProvidedFileSystemInterface> ProvidedFileSystem::GetWeakPtr() { |
329 return weak_ptr_factory_.GetWeakPtr(); | 329 return weak_ptr_factory_.GetWeakPtr(); |
330 } | 330 } |
331 | 331 |
332 void ProvidedFileSystem::Abort( | 332 void ProvidedFileSystem::Abort( |
333 int operation_request_id, | 333 int operation_request_id, |
334 const fileapi::AsyncFileUtil::StatusCallback& callback) { | 334 const storage::AsyncFileUtil::StatusCallback& callback) { |
335 request_manager_.RejectRequest(operation_request_id, | 335 request_manager_.RejectRequest(operation_request_id, |
336 make_scoped_ptr(new RequestValue()), | 336 make_scoped_ptr(new RequestValue()), |
337 base::File::FILE_ERROR_ABORT); | 337 base::File::FILE_ERROR_ABORT); |
338 if (!request_manager_.CreateRequest( | 338 if (!request_manager_.CreateRequest( |
339 ABORT, | 339 ABORT, |
340 scoped_ptr<RequestManager::HandlerInterface>( | 340 scoped_ptr<RequestManager::HandlerInterface>( |
341 new operations::Abort(event_router_, | 341 new operations::Abort(event_router_, |
342 file_system_info_, | 342 file_system_info_, |
343 operation_request_id, | 343 operation_request_id, |
344 callback)))) { | 344 callback)))) { |
345 callback.Run(base::File::FILE_ERROR_SECURITY); | 345 callback.Run(base::File::FILE_ERROR_SECURITY); |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 } // namespace file_system_provider | 349 } // namespace file_system_provider |
350 } // namespace chromeos | 350 } // namespace chromeos |
OLD | NEW |