| 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/utility/media_galleries/media_metadata_parser.h" | 5 #include "chrome/utility/media_galleries/media_metadata_parser.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 std::vector<AttachedImage>* attached_images) { | 107 std::vector<AttachedImage>* attached_images) { |
| 108 DCHECK(!callback.is_null()); | 108 DCHECK(!callback.is_null()); |
| 109 DCHECK(metadata); | 109 DCHECK(metadata); |
| 110 DCHECK(attached_images); | 110 DCHECK(attached_images); |
| 111 | 111 |
| 112 callback.Run(*metadata, *attached_images); | 112 callback.Run(*metadata, *attached_images); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace | 115 } // namespace |
| 116 | 116 |
| 117 MediaMetadataParser::MediaMetadataParser(media::DataSource* source, | 117 MediaMetadataParser::MediaMetadataParser( |
| 118 const std::string& mime_type, | 118 std::unique_ptr<media::DataSource> source, |
| 119 bool get_attached_images) | 119 const std::string& mime_type, |
| 120 : source_(source), | 120 bool get_attached_images) |
| 121 : source_(std::move(source)), |
| 121 mime_type_(mime_type), | 122 mime_type_(mime_type), |
| 122 get_attached_images_(get_attached_images) { | 123 get_attached_images_(get_attached_images) {} |
| 123 } | |
| 124 | 124 |
| 125 MediaMetadataParser::~MediaMetadataParser() {} | 125 MediaMetadataParser::~MediaMetadataParser() = default; |
| 126 | 126 |
| 127 void MediaMetadataParser::Start(const MetadataCallback& callback) { | 127 void MediaMetadataParser::Start(const MetadataCallback& callback) { |
| 128 if (base::StartsWith(mime_type_, "audio/", base::CompareCase::SENSITIVE) || | 128 if (base::StartsWith(mime_type_, "audio/", base::CompareCase::SENSITIVE) || |
| 129 base::StartsWith(mime_type_, "video/", base::CompareCase::SENSITIVE)) { | 129 base::StartsWith(mime_type_, "video/", base::CompareCase::SENSITIVE)) { |
| 130 MediaMetadata* metadata = new MediaMetadata; | 130 MediaMetadata* metadata = new MediaMetadata; |
| 131 metadata->mime_type = mime_type_; | 131 metadata->mime_type = mime_type_; |
| 132 std::vector<AttachedImage>* attached_images = | 132 std::vector<AttachedImage>* attached_images = |
| 133 new std::vector<AttachedImage>; | 133 new std::vector<AttachedImage>; |
| 134 | 134 |
| 135 media_thread_.reset(new base::Thread("media_thread")); | 135 media_thread_.reset(new base::Thread("media_thread")); |
| 136 CHECK(media_thread_->Start()); | 136 CHECK(media_thread_->Start()); |
| 137 media_thread_->task_runner()->PostTaskAndReply( | 137 media_thread_->task_runner()->PostTaskAndReply( |
| 138 FROM_HERE, base::Bind(&ParseAudioVideoMetadata, source_, | 138 FROM_HERE, base::Bind(&ParseAudioVideoMetadata, source_.get(), |
| 139 get_attached_images_, metadata, attached_images), | 139 get_attached_images_, metadata, attached_images), |
| 140 base::Bind(&FinishParseAudioVideoMetadata, callback, | 140 base::Bind(&FinishParseAudioVideoMetadata, callback, |
| 141 base::Owned(metadata), base::Owned(attached_images))); | 141 base::Owned(metadata), base::Owned(attached_images))); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 callback.Run(MediaMetadata(), std::vector<AttachedImage>()); | 145 callback.Run(MediaMetadata(), std::vector<AttachedImage>()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace metadata | 148 } // namespace metadata |
| OLD | NEW |