| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/native_media_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 void HoldFileRef( | 49 void HoldFileRef( |
| 50 const scoped_refptr<storage::ShareableFileReference>& file_ref) { | 50 const scoped_refptr<storage::ShareableFileReference>& file_ref) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 void DidOpenSnapshot( | 53 void DidOpenSnapshot( |
| 54 const storage::AsyncFileUtil::CreateOrOpenCallback& callback, | 54 const storage::AsyncFileUtil::CreateOrOpenCallback& callback, |
| 55 const scoped_refptr<storage::ShareableFileReference>& file_ref, | 55 const scoped_refptr<storage::ShareableFileReference>& file_ref, |
| 56 base::File file) { | 56 base::File file) { |
| 57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 57 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 58 if (!file.IsValid()) { | 58 if (!file.IsValid()) { |
| 59 callback.Run(file.Pass(), base::Closure()); | 59 callback.Run(file.Pass(), base::Closure()); |
| 60 return; | 60 return; |
| 61 } | 61 } |
| 62 callback.Run(file.Pass(), base::Bind(&HoldFileRef, file_ref)); | 62 callback.Run(file.Pass(), base::Bind(&HoldFileRef, file_ref)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 NativeMediaFileUtil::NativeMediaFileUtil(MediaPathFilter* media_path_filter) | 67 NativeMediaFileUtil::NativeMediaFileUtil(MediaPathFilter* media_path_filter) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 97 | 97 |
| 98 // static | 98 // static |
| 99 void NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen( | 99 void NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen( |
| 100 base::SequencedTaskRunner* media_task_runner, | 100 base::SequencedTaskRunner* media_task_runner, |
| 101 int file_flags, | 101 int file_flags, |
| 102 const storage::AsyncFileUtil::CreateOrOpenCallback& callback, | 102 const storage::AsyncFileUtil::CreateOrOpenCallback& callback, |
| 103 base::File::Error result, | 103 base::File::Error result, |
| 104 const base::File::Info& file_info, | 104 const base::File::Info& file_info, |
| 105 const base::FilePath& platform_path, | 105 const base::FilePath& platform_path, |
| 106 const scoped_refptr<storage::ShareableFileReference>& file_ref) { | 106 const scoped_refptr<storage::ShareableFileReference>& file_ref) { |
| 107 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 107 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 108 if (result != base::File::FILE_OK) { | 108 if (result != base::File::FILE_OK) { |
| 109 callback.Run(base::File(), base::Closure()); | 109 callback.Run(base::File(), base::Closure()); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 base::PostTaskAndReplyWithResult( | 112 base::PostTaskAndReplyWithResult( |
| 113 media_task_runner, | 113 media_task_runner, |
| 114 FROM_HERE, | 114 FROM_HERE, |
| 115 base::Bind( | 115 base::Bind( |
| 116 &storage::NativeFileUtil::CreateOrOpen, platform_path, file_flags), | 116 &storage::NativeFileUtil::CreateOrOpen, platform_path, file_flags), |
| 117 base::Bind(&DidOpenSnapshot, callback, file_ref)); | 117 base::Bind(&DidOpenSnapshot, callback, file_ref)); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 return base::File::FILE_ERROR_FAILED; | 671 return base::File::FILE_ERROR_FAILED; |
| 672 | 672 |
| 673 if (!file_info.is_directory && | 673 if (!file_info.is_directory && |
| 674 !media_path_filter_->Match(file_path)) { | 674 !media_path_filter_->Match(file_path)) { |
| 675 return failure_error; | 675 return failure_error; |
| 676 } | 676 } |
| 677 | 677 |
| 678 *local_file_path = file_path; | 678 *local_file_path = file_path; |
| 679 return base::File::FILE_OK; | 679 return base::File::FILE_OK; |
| 680 } | 680 } |
| OLD | NEW |