| 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 content::BrowserThread::PostTask( |
| 290 content::BrowserThread::IO, |
| 291 FROM_HERE, |
| 292 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, |
| 293 base::PlatformFileInfo())); |
| 294 return; |
| 295 } |
| 285 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url, | 296 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url, |
| 286 callback); | 297 callback); |
| 287 } | 298 } |
| 288 | 299 |
| 289 void PicasaFileUtil::ReadDirectoryWithFreshDataProvider( | 300 void PicasaFileUtil::ReadDirectoryWithFreshDataProvider( |
| 290 scoped_ptr<fileapi::FileSystemOperationContext> context, | 301 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 291 const fileapi::FileSystemURL& url, | 302 const fileapi::FileSystemURL& url, |
| 292 const ReadDirectoryCallback& callback) { | 303 const ReadDirectoryCallback& callback, |
| 304 bool success) { |
| 305 if (!success) { |
| 306 content::BrowserThread::PostTask( |
| 307 content::BrowserThread::IO, |
| 308 FROM_HERE, |
| 309 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, |
| 310 base::PlatformFileInfo())); |
| 311 return; |
| 312 } |
| 293 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url, | 313 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url, |
| 294 callback); | 314 callback); |
| 295 } | 315 } |
| 296 | 316 |
| 297 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { | 317 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { |
| 298 return chrome::ImportedMediaGalleryRegistry::PicasaDataProvider(); | 318 return chrome::ImportedMediaGalleryRegistry::PicasaDataProvider(); |
| 299 } | 319 } |
| 300 | 320 |
| 301 } // namespace picasa | 321 } // namespace picasa |
| OLD | NEW |