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 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 // Routes the response of GetFileInfo back to the IO thread. | 40 // Routes the response of GetFileInfo back to the IO thread. |
41 void OnGetFileInfo(const fileapi::AsyncFileUtil::GetFileInfoCallback& callback, | 41 void OnGetFileInfo(const fileapi::AsyncFileUtil::GetFileInfoCallback& callback, |
42 base::File::Error result, | 42 base::File::Error result, |
43 const base::File::Info& file_info) { | 43 const base::File::Info& file_info) { |
44 BrowserThread::PostTask( | 44 BrowserThread::PostTask( |
45 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info)); | 45 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info)); |
46 } | 46 } |
47 | 47 |
| 48 // Executes ReadDirectory on the UI thread. |
| 49 void ReadDirectoryOnUIThread( |
| 50 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 51 const fileapi::FileSystemURL& url, |
| 52 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { |
| 53 util::FileSystemURLParser parser(url); |
| 54 if (!parser.Parse()) { |
| 55 callback.Run(base::File::FILE_ERROR_NOT_FOUND, |
| 56 fileapi::AsyncFileUtil::EntryList(), |
| 57 false /* has_more */); |
| 58 return; |
| 59 } |
| 60 |
| 61 parser.file_system()->ReadDirectory(parser.file_path(), callback); |
| 62 } |
| 63 |
| 64 // Routes the response of ReadDirectory back to the IO thread. |
| 65 void OnReadDirectory( |
| 66 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback, |
| 67 base::File::Error result, |
| 68 const fileapi::AsyncFileUtil::EntryList& entry_list, |
| 69 bool has_more) { |
| 70 BrowserThread::PostTask(BrowserThread::IO, |
| 71 FROM_HERE, |
| 72 base::Bind(callback, result, entry_list, has_more)); |
| 73 } |
| 74 |
48 } // namespace | 75 } // namespace |
49 | 76 |
50 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {} | 77 ProviderAsyncFileUtil::ProviderAsyncFileUtil() {} |
51 | 78 |
52 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {} | 79 ProviderAsyncFileUtil::~ProviderAsyncFileUtil() {} |
53 | 80 |
54 void ProviderAsyncFileUtil::CreateOrOpen( | 81 void ProviderAsyncFileUtil::CreateOrOpen( |
55 scoped_ptr<fileapi::FileSystemOperationContext> context, | 82 scoped_ptr<fileapi::FileSystemOperationContext> context, |
56 const fileapi::FileSystemURL& url, | 83 const fileapi::FileSystemURL& url, |
57 int file_flags, | 84 int file_flags, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 base::Passed(&context), | 130 base::Passed(&context), |
104 url, | 131 url, |
105 base::Bind(&OnGetFileInfo, callback))); | 132 base::Bind(&OnGetFileInfo, callback))); |
106 } | 133 } |
107 | 134 |
108 void ProviderAsyncFileUtil::ReadDirectory( | 135 void ProviderAsyncFileUtil::ReadDirectory( |
109 scoped_ptr<fileapi::FileSystemOperationContext> context, | 136 scoped_ptr<fileapi::FileSystemOperationContext> context, |
110 const fileapi::FileSystemURL& url, | 137 const fileapi::FileSystemURL& url, |
111 const ReadDirectoryCallback& callback) { | 138 const ReadDirectoryCallback& callback) { |
112 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 139 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
113 NOTIMPLEMENTED(); | 140 BrowserThread::PostTask(BrowserThread::UI, |
114 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false); | 141 FROM_HERE, |
| 142 base::Bind(&ReadDirectoryOnUIThread, |
| 143 base::Passed(&context), |
| 144 url, |
| 145 base::Bind(&OnReadDirectory, callback))); |
115 } | 146 } |
116 | 147 |
117 void ProviderAsyncFileUtil::Touch( | 148 void ProviderAsyncFileUtil::Touch( |
118 scoped_ptr<fileapi::FileSystemOperationContext> context, | 149 scoped_ptr<fileapi::FileSystemOperationContext> context, |
119 const fileapi::FileSystemURL& url, | 150 const fileapi::FileSystemURL& url, |
120 const base::Time& last_access_time, | 151 const base::Time& last_access_time, |
121 const base::Time& last_modified_time, | 152 const base::Time& last_modified_time, |
122 const StatusCallback& callback) { | 153 const StatusCallback& callback) { |
123 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 154 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
124 callback.Run(base::File::FILE_ERROR_SECURITY); | 155 callback.Run(base::File::FILE_ERROR_SECURITY); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 NOTIMPLEMENTED(); | 226 NOTIMPLEMENTED(); |
196 callback.Run(base::File::FILE_ERROR_NOT_FOUND, | 227 callback.Run(base::File::FILE_ERROR_NOT_FOUND, |
197 base::File::Info(), | 228 base::File::Info(), |
198 base::FilePath(), | 229 base::FilePath(), |
199 scoped_refptr<webkit_blob::ShareableFileReference>()); | 230 scoped_refptr<webkit_blob::ShareableFileReference>()); |
200 } | 231 } |
201 | 232 |
202 } // namespace internal | 233 } // namespace internal |
203 } // namespace file_system_provider | 234 } // namespace file_system_provider |
204 } // namespace chromeos | 235 } // namespace chromeos |
OLD | NEW |