Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2869)

Unified Diff: chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc

Issue 251723004: No media-file validation mode for DeviceMediaAsyncUtil. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review #2 Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 9ca5faa5666629aab1716916516a56d8da987518..18f3018cfc29eab86ee1e56364411c36c02b439b 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
@@ -64,9 +64,10 @@ DeviceMediaAsyncFileUtil::~DeviceMediaAsyncFileUtil() {
// static
DeviceMediaAsyncFileUtil* DeviceMediaAsyncFileUtil::Create(
- const base::FilePath& profile_path) {
+ const base::FilePath& profile_path,
+ MediaFileValidationType validation_type) {
DCHECK(!profile_path.empty());
- return new DeviceMediaAsyncFileUtil(profile_path);
+ return new DeviceMediaAsyncFileUtil(profile_path, validation_type);
}
bool DeviceMediaAsyncFileUtil::SupportsStreaming(
@@ -283,12 +284,15 @@ DeviceMediaAsyncFileUtil::GetFileStreamReader(
DCHECK(delegate->IsStreaming());
return scoped_ptr<webkit_blob::FileStreamReader>(
new ReadaheadFileStreamReader(new MTPFileStreamReader(
- context, url, offset, expected_modification_time)));
+ context, url, offset, expected_modification_time,
+ validation_type_ == APPLY_MEDIA_FILE_VALIDATION)));
}
DeviceMediaAsyncFileUtil::DeviceMediaAsyncFileUtil(
- const base::FilePath& profile_path)
+ const base::FilePath& profile_path,
+ MediaFileValidationType validation_type)
: profile_path_(profile_path),
+ validation_type_(validation_type),
weak_ptr_factory_(this) {
}
@@ -322,18 +326,25 @@ void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile(
base::SequencedTaskRunner* media_task_runner,
const base::File::Info& file_info,
const base::FilePath& platform_path) {
- base::PostTaskAndReplyWithResult(
- media_task_runner,
- FROM_HERE,
- base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path),
- base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia,
- weak_ptr_factory_.GetWeakPtr(),
- callback,
- file_info,
- ShareableFileReference::GetOrCreate(
- platform_path,
- ShareableFileReference::DELETE_ON_FINAL_RELEASE,
- media_task_runner)));
+ scoped_refptr<webkit_blob::ShareableFileReference> file =
+ ShareableFileReference::GetOrCreate(
+ platform_path,
+ ShareableFileReference::DELETE_ON_FINAL_RELEASE,
+ media_task_runner);
+
+ if (validation_type_ == APPLY_MEDIA_FILE_VALIDATION) {
+ base::PostTaskAndReplyWithResult(
+ media_task_runner,
+ FROM_HERE,
+ base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path),
+ base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback,
+ file_info,
+ file));
+ } else {
+ OnDidCheckMedia(callback, file_info, file, base::File::FILE_OK);
+ }
}
void DeviceMediaAsyncFileUtil::OnDidCheckMedia(

Powered by Google App Engine
This is Rietveld 408576698