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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 const std::string& mime_type, | 159 const std::string& mime_type, |
160 bool get_attached_images) | 160 bool get_attached_images) |
161 : source_(source), | 161 : source_(source), |
162 mime_type_(mime_type), | 162 mime_type_(mime_type), |
163 get_attached_images_(get_attached_images) { | 163 get_attached_images_(get_attached_images) { |
164 } | 164 } |
165 | 165 |
166 MediaMetadataParser::~MediaMetadataParser() {} | 166 MediaMetadataParser::~MediaMetadataParser() {} |
167 | 167 |
168 void MediaMetadataParser::Start(const MetadataCallback& callback) { | 168 void MediaMetadataParser::Start(const MetadataCallback& callback) { |
169 if (base::StartsWithASCII(mime_type_, "audio/", true) || | 169 if (base::StartsWith(mime_type_, "audio/", base::CompareCase::SENSITIVE) || |
170 base::StartsWithASCII(mime_type_, "video/", true)) { | 170 base::StartsWith(mime_type_, "video/", base::CompareCase::SENSITIVE)) { |
171 MediaMetadata* metadata = new MediaMetadata; | 171 MediaMetadata* metadata = new MediaMetadata; |
172 metadata->mime_type = mime_type_; | 172 metadata->mime_type = mime_type_; |
173 std::vector<AttachedImage>* attached_images = | 173 std::vector<AttachedImage>* attached_images = |
174 new std::vector<AttachedImage>; | 174 new std::vector<AttachedImage>; |
175 | 175 |
176 media_thread_.reset(new base::Thread("media_thread")); | 176 media_thread_.reset(new base::Thread("media_thread")); |
177 CHECK(media_thread_->Start()); | 177 CHECK(media_thread_->Start()); |
178 media_thread_->task_runner()->PostTaskAndReply( | 178 media_thread_->task_runner()->PostTaskAndReply( |
179 FROM_HERE, base::Bind(&ParseAudioVideoMetadata, source_, | 179 FROM_HERE, base::Bind(&ParseAudioVideoMetadata, source_, |
180 get_attached_images_, metadata, attached_images), | 180 get_attached_images_, metadata, attached_images), |
181 base::Bind(&FinishParseAudioVideoMetadata, callback, | 181 base::Bind(&FinishParseAudioVideoMetadata, callback, |
182 base::Owned(metadata), base::Owned(attached_images))); | 182 base::Owned(metadata), base::Owned(attached_images))); |
183 return; | 183 return; |
184 } | 184 } |
185 | 185 |
186 if (base::StartsWithASCII(mime_type_, "image/", true)) { | 186 if (base::StartsWith(mime_type_, "image/", base::CompareCase::SENSITIVE)) { |
187 ImageMetadataExtractor* extractor = new ImageMetadataExtractor; | 187 ImageMetadataExtractor* extractor = new ImageMetadataExtractor; |
188 extractor->Extract( | 188 extractor->Extract( |
189 source_, | 189 source_, |
190 base::Bind(&FinishParseImageMetadata, base::Owned(extractor), | 190 base::Bind(&FinishParseImageMetadata, base::Owned(extractor), |
191 mime_type_, callback)); | 191 mime_type_, callback)); |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 callback.Run(MediaMetadata(), std::vector<AttachedImage>()); | 195 callback.Run(MediaMetadata(), std::vector<AttachedImage>()); |
196 } | 196 } |
197 | 197 |
198 } // namespace metadata | 198 } // namespace metadata |
OLD | NEW |