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

Unified Diff: chrome/utility/media_galleries/media_metadata_parser.cc

Issue 2667443002: Convert utility process ParseMediaMetadata blob reading IPC to mojo (Closed)
Patch Set: Sync to ToT and merge in dependent patch changes. Created 3 years, 10 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
« no previous file with comments | « chrome/utility/media_galleries/media_metadata_parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/utility/media_galleries/media_metadata_parser.cc
diff --git a/chrome/utility/media_galleries/media_metadata_parser.cc b/chrome/utility/media_galleries/media_metadata_parser.cc
index 7085cb6ae0750258d8e204a1be1589cba3a1e0f1..236ad2aeb618285f00c63484e3ccb29d916732d1 100644
--- a/chrome/utility/media_galleries/media_metadata_parser.cc
+++ b/chrome/utility/media_galleries/media_metadata_parser.cc
@@ -112,37 +112,44 @@ void FinishParseAudioVideoMetadata(
callback.Run(*metadata, *attached_images);
}
+bool IsSupportedMetadataMimetype(const std::string& mime_type) {
+ if (base::StartsWith(mime_type, "audio/", base::CompareCase::SENSITIVE))
+ return true;
+ if (base::StartsWith(mime_type, "video/", base::CompareCase::SENSITIVE))
+ return true;
+ return false;
+}
+
} // namespace
-MediaMetadataParser::MediaMetadataParser(media::DataSource* source,
- const std::string& mime_type,
- bool get_attached_images)
- : source_(source),
+MediaMetadataParser::MediaMetadataParser(
+ std::unique_ptr<media::DataSource> source,
+ const std::string& mime_type,
+ bool get_attached_images)
+ : source_(std::move(source)),
mime_type_(mime_type),
- get_attached_images_(get_attached_images) {
-}
+ get_attached_images_(get_attached_images) {}
-MediaMetadataParser::~MediaMetadataParser() {}
+MediaMetadataParser::~MediaMetadataParser() = default;
void MediaMetadataParser::Start(const MetadataCallback& callback) {
- if (base::StartsWith(mime_type_, "audio/", base::CompareCase::SENSITIVE) ||
- base::StartsWith(mime_type_, "video/", base::CompareCase::SENSITIVE)) {
- MediaMetadata* metadata = new MediaMetadata;
- metadata->mime_type = mime_type_;
- std::vector<AttachedImage>* attached_images =
- new std::vector<AttachedImage>;
-
- media_thread_.reset(new base::Thread("media_thread"));
- CHECK(media_thread_->Start());
- media_thread_->task_runner()->PostTaskAndReply(
- FROM_HERE, base::Bind(&ParseAudioVideoMetadata, source_,
- get_attached_images_, metadata, attached_images),
- base::Bind(&FinishParseAudioVideoMetadata, callback,
- base::Owned(metadata), base::Owned(attached_images)));
+ if (!IsSupportedMetadataMimetype(mime_type_)) {
+ callback.Run(MediaMetadata(), std::vector<AttachedImage>());
return;
}
- callback.Run(MediaMetadata(), std::vector<AttachedImage>());
+ MediaMetadata* metadata = new MediaMetadata();
+ metadata->mime_type = mime_type_;
+ std::vector<AttachedImage>* images = new std::vector<AttachedImage>();
+
+ media_thread_.reset(new base::Thread("media_thread"));
+ CHECK(media_thread_->Start());
+
+ media_thread_->task_runner()->PostTaskAndReply(
+ FROM_HERE, base::Bind(&ParseAudioVideoMetadata, source_.get(),
+ get_attached_images_, metadata, images),
+ base::Bind(&FinishParseAudioVideoMetadata, callback,
+ base::Owned(metadata), base::Owned(images)));
}
} // namespace metadata
« no previous file with comments | « chrome/utility/media_galleries/media_metadata_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698