Chromium Code Reviews| Index: chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc |
| diff --git a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc |
| index 45345e70ef8cdaac52c0e05c00cea7e9c4ca45fa..295b9f7f5b5fb14607aebf87df302dee7ace9311 100644 |
| --- a/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc |
| +++ b/chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc |
| @@ -12,12 +12,14 @@ |
| #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" |
| #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" |
| +#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
| #include "webkit/blob/shareable_file_reference.h" |
| #include "webkit/fileapi/file_system_context.h" |
| #include "webkit/fileapi/file_system_operation_context.h" |
| #include "webkit/fileapi/file_system_task_runners.h" |
| #include "webkit/fileapi/file_system_url.h" |
| #include "webkit/fileapi/isolated_context.h" |
| +#include "webkit/fileapi/native_file_util.h" |
| using fileapi::FileSystemOperationContext; |
| using fileapi::FileSystemURL; |
| @@ -316,11 +318,38 @@ void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile( |
| const base::FilePath& platform_path) { |
| if (callback.is_null()) |
| return; |
| - callback.Run(base::PLATFORM_FILE_OK, file_info, platform_path, |
| - ShareableFileReference::GetOrCreate( |
| - platform_path, |
| - ShareableFileReference::DELETE_ON_FINAL_RELEASE, |
| - media_task_runner)); |
| + base::PlatformFileError* error = new base::PlatformFileError; |
| + media_task_runner->PostTaskAndReply( |
| + FROM_HERE, |
| + base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path, |
| + base::Unretained(error)), |
| + base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + callback, make_scoped_refptr(media_task_runner), |
| + file_info, |
| + ShareableFileReference::GetOrCreate( |
| + platform_path, |
| + ShareableFileReference::DELETE_ON_FINAL_RELEASE, |
| + media_task_runner), |
| + base::Owned(error))); |
| +} |
| + |
| +void DeviceMediaAsyncFileUtil::OnDidCheckMedia( |
| + const AsyncFileUtil::CreateSnapshotFileCallback& callback, |
| + base::SequencedTaskRunner* media_task_runner, |
| + const base::PlatformFileInfo& file_info, |
| + scoped_refptr<webkit_blob::ShareableFileReference> platform_file, |
| + base::PlatformFileError* error) { |
| + if (callback.is_null()) |
| + return; |
| + if (*error == base::PLATFORM_FILE_OK) { |
|
vandebo (ex-Chrome)
2013/05/02 21:58:24
Instead of doing the if else with the callback.Run
Kevin Bailey
2013/05/03 16:52:55
Hope this is what you meant.
|
| + callback.Run(base::PLATFORM_FILE_OK, file_info, platform_file.get()->path(), |
| + platform_file); |
| + } else { |
| + base::FilePath platform_path(platform_file.get()->path()); |
| + callback.Run(*error, file_info, platform_path, |
| + scoped_refptr<ShareableFileReference>()); |
| + } |
| } |
| void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError( |