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/fileapi/provider_async_fi
le_util.h" | 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi
le_util.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" | 11 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "storage/browser/blob/shareable_file_reference.h" | 14 #include "storage/browser/blob/shareable_file_reference.h" |
15 #include "storage/browser/fileapi/file_system_operation_context.h" | 15 #include "storage/browser/fileapi/file_system_operation_context.h" |
16 #include "storage/browser/fileapi/file_system_url.h" | 16 #include "storage/browser/fileapi/file_system_url.h" |
17 | 17 |
18 using content::BrowserThread; | 18 using content::BrowserThread; |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 namespace file_system_provider { | 21 namespace file_system_provider { |
22 namespace internal { | 22 namespace internal { |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Executes GetFileInfo on the UI thread. | 25 // Executes GetFileInfo on the UI thread. |
26 void GetFileInfoOnUIThread( | 26 void GetFileInfoOnUIThread( |
27 scoped_ptr<storage::FileSystemOperationContext> context, | 27 scoped_ptr<storage::FileSystemOperationContext> context, |
28 const storage::FileSystemURL& url, | 28 const storage::FileSystemURL& url, |
| 29 int /* fields */, |
29 const ProvidedFileSystemInterface::GetMetadataCallback& callback) { | 30 const ProvidedFileSystemInterface::GetMetadataCallback& callback) { |
30 util::FileSystemURLParser parser(url); | 31 util::FileSystemURLParser parser(url); |
31 if (!parser.Parse()) { | 32 if (!parser.Parse()) { |
32 callback.Run(make_scoped_ptr<EntryMetadata>(NULL), | 33 callback.Run(make_scoped_ptr<EntryMetadata>(NULL), |
33 base::File::FILE_ERROR_INVALID_OPERATION); | 34 base::File::FILE_ERROR_INVALID_OPERATION); |
34 return; | 35 return; |
35 } | 36 } |
36 | 37 |
| 38 // TODO(mtomasz): Pass fields to FSP extensions so only requested fields are |
| 39 // returned. |
37 parser.file_system()->GetMetadata( | 40 parser.file_system()->GetMetadata( |
38 parser.file_path(), | 41 parser.file_path(), |
39 ProvidedFileSystemInterface::METADATA_FIELD_DEFAULT, | 42 ProvidedFileSystemInterface::METADATA_FIELD_DEFAULT, |
40 callback); | 43 callback); |
41 } | 44 } |
42 | 45 |
43 // Routes the response of GetFileInfo back to the IO thread with a type | 46 // Routes the response of GetFileInfo back to the IO thread with a type |
44 // conversion. | 47 // conversion. |
45 void OnGetFileInfo(const storage::AsyncFileUtil::GetFileInfoCallback& callback, | 48 void OnGetFileInfo(const storage::AsyncFileUtil::GetFileInfoCallback& callback, |
46 scoped_ptr<EntryMetadata> metadata, | 49 scoped_ptr<EntryMetadata> metadata, |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 base::Passed(&context), | 313 base::Passed(&context), |
311 url, | 314 url, |
312 exclusive, | 315 exclusive, |
313 recursive, | 316 recursive, |
314 base::Bind(&OnCreateDirectory, exclusive, callback))); | 317 base::Bind(&OnCreateDirectory, exclusive, callback))); |
315 } | 318 } |
316 | 319 |
317 void ProviderAsyncFileUtil::GetFileInfo( | 320 void ProviderAsyncFileUtil::GetFileInfo( |
318 scoped_ptr<storage::FileSystemOperationContext> context, | 321 scoped_ptr<storage::FileSystemOperationContext> context, |
319 const storage::FileSystemURL& url, | 322 const storage::FileSystemURL& url, |
| 323 int fields, |
320 const GetFileInfoCallback& callback) { | 324 const GetFileInfoCallback& callback) { |
321 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 325 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
322 BrowserThread::PostTask(BrowserThread::UI, | 326 BrowserThread::PostTask( |
323 FROM_HERE, | 327 BrowserThread::UI, FROM_HERE, |
324 base::Bind(&GetFileInfoOnUIThread, | 328 base::Bind(&GetFileInfoOnUIThread, base::Passed(&context), url, fields, |
325 base::Passed(&context), | 329 base::Bind(&OnGetFileInfo, callback))); |
326 url, | |
327 base::Bind(&OnGetFileInfo, callback))); | |
328 } | 330 } |
329 | 331 |
330 void ProviderAsyncFileUtil::ReadDirectory( | 332 void ProviderAsyncFileUtil::ReadDirectory( |
331 scoped_ptr<storage::FileSystemOperationContext> context, | 333 scoped_ptr<storage::FileSystemOperationContext> context, |
332 const storage::FileSystemURL& url, | 334 const storage::FileSystemURL& url, |
333 const ReadDirectoryCallback& callback) { | 335 const ReadDirectoryCallback& callback) { |
334 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 336 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
335 BrowserThread::PostTask(BrowserThread::UI, | 337 BrowserThread::PostTask(BrowserThread::UI, |
336 FROM_HERE, | 338 FROM_HERE, |
337 base::Bind(&ReadDirectoryOnUIThread, | 339 base::Bind(&ReadDirectoryOnUIThread, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 NOTIMPLEMENTED(); | 463 NOTIMPLEMENTED(); |
462 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 464 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
463 base::File::Info(), | 465 base::File::Info(), |
464 base::FilePath(), | 466 base::FilePath(), |
465 scoped_refptr<storage::ShareableFileReference>()); | 467 scoped_refptr<storage::ShareableFileReference>()); |
466 } | 468 } |
467 | 469 |
468 } // namespace internal | 470 } // namespace internal |
469 } // namespace file_system_provider | 471 } // namespace file_system_provider |
470 } // namespace chromeos | 472 } // namespace chromeos |
OLD | NEW |