Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/media_galleries/fileapi/picasa/picasa_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_file_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 : weak_factory_(this) { | 57 : weak_factory_(this) { |
| 58 } | 58 } |
| 59 | 59 |
| 60 PicasaFileUtil::~PicasaFileUtil() {} | 60 PicasaFileUtil::~PicasaFileUtil() {} |
| 61 | 61 |
| 62 void PicasaFileUtil::GetFileInfoOnTaskRunnerThread( | 62 void PicasaFileUtil::GetFileInfoOnTaskRunnerThread( |
| 63 scoped_ptr<fileapi::FileSystemOperationContext> context, | 63 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 64 const fileapi::FileSystemURL& url, | 64 const fileapi::FileSystemURL& url, |
| 65 const GetFileInfoCallback& callback) { | 65 const GetFileInfoCallback& callback) { |
| 66 GetDataProvider()->RefreshData( | 66 GetDataProvider()->RefreshData( |
| 67 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA, | |
| 67 base::Bind(&PicasaFileUtil::GetFileInfoWithFreshDataProvider, | 68 base::Bind(&PicasaFileUtil::GetFileInfoWithFreshDataProvider, |
| 68 weak_factory_.GetWeakPtr(), base::Passed(&context), url, | 69 weak_factory_.GetWeakPtr(), base::Passed(&context), url, |
| 69 callback)); | 70 callback)); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void PicasaFileUtil::ReadDirectoryOnTaskRunnerThread( | 73 void PicasaFileUtil::ReadDirectoryOnTaskRunnerThread( |
| 73 scoped_ptr<fileapi::FileSystemOperationContext> context, | 74 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 74 const fileapi::FileSystemURL& url, | 75 const fileapi::FileSystemURL& url, |
| 75 const ReadDirectoryCallback& callback) { | 76 const ReadDirectoryCallback& callback) { |
| 76 GetDataProvider()->RefreshData( | 77 GetDataProvider()->RefreshData( |
| 78 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA, | |
| 77 base::Bind(&PicasaFileUtil::ReadDirectoryWithFreshDataProvider, | 79 base::Bind(&PicasaFileUtil::ReadDirectoryWithFreshDataProvider, |
| 78 weak_factory_.GetWeakPtr(), base::Passed(&context), url, | 80 weak_factory_.GetWeakPtr(), base::Passed(&context), url, |
| 79 callback)); | 81 callback)); |
| 80 } | 82 } |
| 81 | 83 |
| 82 base::PlatformFileError PicasaFileUtil::GetFileInfoSync( | 84 base::PlatformFileError PicasaFileUtil::GetFileInfoSync( |
| 83 FileSystemOperationContext* context, const FileSystemURL& url, | 85 FileSystemOperationContext* context, const FileSystemURL& url, |
| 84 base::PlatformFileInfo* file_info, base::FilePath* platform_path) { | 86 base::PlatformFileInfo* file_info, base::FilePath* platform_path) { |
| 85 DCHECK(context); | 87 DCHECK(context); |
| 86 DCHECK(file_info); | 88 DCHECK(file_info); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 | 276 |
| 275 // All other cases don't have a local path. The valid cases should be | 277 // All other cases don't have a local path. The valid cases should be |
| 276 // intercepted by GetFileInfo()/CreateFileEnumerator(). Invalid cases | 278 // intercepted by GetFileInfo()/CreateFileEnumerator(). Invalid cases |
| 277 // return a NOT_FOUND error. | 279 // return a NOT_FOUND error. |
| 278 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 280 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 279 } | 281 } |
| 280 | 282 |
| 281 void PicasaFileUtil::GetFileInfoWithFreshDataProvider( | 283 void PicasaFileUtil::GetFileInfoWithFreshDataProvider( |
| 282 scoped_ptr<fileapi::FileSystemOperationContext> context, | 284 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 283 const fileapi::FileSystemURL& url, | 285 const fileapi::FileSystemURL& url, |
| 284 const GetFileInfoCallback& callback) { | 286 const GetFileInfoCallback& callback, |
| 287 bool success) { | |
| 288 if (!success) { | |
| 289 if (!callback.is_null()) { | |
|
vandebo (ex-Chrome)
2013/07/12 18:29:59
Upstream changed to ensure that callback can't be
tommycli
2013/07/12 21:37:19
Done.
| |
| 290 content::BrowserThread::PostTask( | |
| 291 content::BrowserThread::IO, | |
| 292 FROM_HERE, | |
| 293 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, | |
| 294 base::PlatformFileInfo())); | |
| 295 } | |
| 296 return; | |
| 297 } | |
| 285 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url, | 298 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url, |
| 286 callback); | 299 callback); |
| 287 } | 300 } |
| 288 | 301 |
| 289 void PicasaFileUtil::ReadDirectoryWithFreshDataProvider( | 302 void PicasaFileUtil::ReadDirectoryWithFreshDataProvider( |
| 290 scoped_ptr<fileapi::FileSystemOperationContext> context, | 303 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 291 const fileapi::FileSystemURL& url, | 304 const fileapi::FileSystemURL& url, |
| 292 const ReadDirectoryCallback& callback) { | 305 const ReadDirectoryCallback& callback, |
| 306 bool success) { | |
| 307 if (!success) { | |
| 308 if (!callback.is_null()) { | |
| 309 content::BrowserThread::PostTask( | |
| 310 content::BrowserThread::IO, | |
| 311 FROM_HERE, | |
| 312 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, | |
| 313 base::PlatformFileInfo())); | |
| 314 } | |
| 315 return; | |
| 316 } | |
| 293 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url, | 317 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url, |
| 294 callback); | 318 callback); |
| 295 } | 319 } |
| 296 | 320 |
| 297 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { | 321 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { |
| 298 return chrome::ImportedMediaGalleryRegistry::PicasaDataProvider(); | 322 return chrome::ImportedMediaGalleryRegistry::PicasaDataProvider(); |
| 299 } | 323 } |
| 300 | 324 |
| 301 } // namespace picasa | 325 } // namespace picasa |
| OLD | NEW |