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" |
(...skipping 11 matching lines...) Expand all Loading... |
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 const ProvidedFileSystemInterface::GetMetadataCallback& callback) { | 29 const ProvidedFileSystemInterface::GetMetadataCallback& callback) { |
30 util::FileSystemURLParser parser(url); | 30 util::FileSystemURLParser parser(url); |
31 if (!parser.Parse()) { | 31 if (!parser.Parse()) { |
32 callback.Run(EntryMetadata(), base::File::FILE_ERROR_INVALID_OPERATION); | 32 callback.Run(make_scoped_ptr<EntryMetadata>(NULL), |
| 33 base::File::FILE_ERROR_INVALID_OPERATION); |
33 return; | 34 return; |
34 } | 35 } |
35 | 36 |
36 parser.file_system()->GetMetadata(parser.file_path(), callback); | 37 parser.file_system()->GetMetadata( |
| 38 parser.file_path(), |
| 39 ProvidedFileSystemInterface::METADATA_FIELD_DEFAULT, |
| 40 callback); |
37 } | 41 } |
38 | 42 |
39 // Routes the response of GetFileInfo back to the IO thread with a type | 43 // Routes the response of GetFileInfo back to the IO thread with a type |
40 // conversion. | 44 // conversion. |
41 void OnGetFileInfo(const storage::AsyncFileUtil::GetFileInfoCallback& callback, | 45 void OnGetFileInfo(const storage::AsyncFileUtil::GetFileInfoCallback& callback, |
42 const EntryMetadata& metadata, | 46 scoped_ptr<EntryMetadata> metadata, |
43 base::File::Error result) { | 47 base::File::Error result) { |
| 48 if (result != base::File::FILE_OK) { |
| 49 BrowserThread::PostTask(BrowserThread::IO, |
| 50 FROM_HERE, |
| 51 base::Bind(callback, result, base::File::Info())); |
| 52 return; |
| 53 } |
| 54 |
| 55 DCHECK(metadata.get()); |
44 base::File::Info file_info; | 56 base::File::Info file_info; |
45 | 57 |
46 // TODO(mtomasz): Add support for last modified time and creation time. | 58 // TODO(mtomasz): Add support for last modified time and creation time. |
47 // See: crbug.com/388540. | 59 // See: crbug.com/388540. |
48 file_info.size = metadata.size; | 60 file_info.size = metadata->size; |
49 file_info.is_directory = metadata.is_directory; | 61 file_info.is_directory = metadata->is_directory; |
50 file_info.is_symbolic_link = false; // Not supported. | 62 file_info.is_symbolic_link = false; // Not supported. |
51 file_info.last_modified = metadata.modification_time; | 63 file_info.last_modified = metadata->modification_time; |
52 file_info.last_accessed = metadata.modification_time; // Not supported. | 64 file_info.last_accessed = metadata->modification_time; // Not supported. |
53 file_info.creation_time = metadata.modification_time; // Not supported. | 65 file_info.creation_time = metadata->modification_time; // Not supported. |
54 | 66 |
55 BrowserThread::PostTask( | 67 BrowserThread::PostTask(BrowserThread::IO, |
56 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info)); | 68 FROM_HERE, |
| 69 base::Bind(callback, base::File::FILE_OK, file_info)); |
57 } | 70 } |
58 | 71 |
59 // Executes ReadDirectory on the UI thread. | 72 // Executes ReadDirectory on the UI thread. |
60 void ReadDirectoryOnUIThread( | 73 void ReadDirectoryOnUIThread( |
61 scoped_ptr<storage::FileSystemOperationContext> context, | 74 scoped_ptr<storage::FileSystemOperationContext> context, |
62 const storage::FileSystemURL& url, | 75 const storage::FileSystemURL& url, |
63 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) { | 76 const storage::AsyncFileUtil::ReadDirectoryCallback& callback) { |
64 util::FileSystemURLParser parser(url); | 77 util::FileSystemURLParser parser(url); |
65 if (!parser.Parse()) { | 78 if (!parser.Parse()) { |
66 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 79 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 NOTIMPLEMENTED(); | 452 NOTIMPLEMENTED(); |
440 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, | 453 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, |
441 base::File::Info(), | 454 base::File::Info(), |
442 base::FilePath(), | 455 base::FilePath(), |
443 scoped_refptr<storage::ShareableFileReference>()); | 456 scoped_refptr<storage::ShareableFileReference>()); |
444 } | 457 } |
445 | 458 |
446 } // namespace internal | 459 } // namespace internal |
447 } // namespace file_system_provider | 460 } // namespace file_system_provider |
448 } // namespace chromeos | 461 } // namespace chromeos |
OLD | NEW |