summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 22:38:42 +0000
committertommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 22:38:42 +0000
commitc5e85fce6e861f2291ea7462990461aa606152c9 (patch)
tree431f0817a448cd8eb50e6e6a402e69733ace99b9 /chrome
parent7beed4b304055ace4da0fac82a0f88135100fc9b (diff)
downloadchromium_src-c5e85fce6e861f2291ea7462990461aa606152c9.zip
chromium_src-c5e85fce6e861f2291ea7462990461aa606152c9.tar.gz
chromium_src-c5e85fce6e861f2291ea7462990461aa606152c9.tar.bz2
Media Galleries API: Audio/Video attached pictures. IPC portion only.
This is a subset of Patchset 13 of https://codereview.chromium.org/250143002/. Intent is to try to get the less controversial portions of patch reviewed and committed so we can focus on the 'hard' part. Depends on https://codereview.chromium.org/270873003/ landing. BUG=304290 Review URL: https://codereview.chromium.org/278933003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/api/media_galleries/media_galleries_api.cc7
-rw-r--r--chrome/browser/extensions/api/media_galleries/media_galleries_api.h4
-rw-r--r--chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.cc27
-rw-r--r--chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.h16
-rw-r--r--chrome/chrome_common.gypi3
-rw-r--r--chrome/common/chrome_utility_messages.h21
-rw-r--r--chrome/common/media_galleries/metadata_types.h19
-rw-r--r--chrome/utility/chrome_content_utility_client.cc15
-rw-r--r--chrome/utility/chrome_content_utility_client.h3
-rw-r--r--chrome/utility/media_galleries/media_metadata_parser.cc102
-rw-r--r--chrome/utility/media_galleries/media_metadata_parser.h14
11 files changed, 162 insertions, 69 deletions
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
index ffb2cc3..99b9199 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
@@ -865,15 +865,18 @@ void MediaGalleriesGetMetadataFunction::SniffMimeType(
return;
}
+ // TODO(tommycli): Enable getting attached images.
scoped_refptr<metadata::SafeMediaMetadataParser> parser(
new metadata::SafeMediaMetadataParser(GetProfile(), blob_uuid,
- total_blob_length, mime_type));
+ total_blob_length, mime_type,
+ false /* get_attached_images */));
parser->Start(base::Bind(
&MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone, this));
}
void MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone(
- bool parse_success, base::DictionaryValue* metadata_dictionary) {
+ bool parse_success, scoped_ptr<base::DictionaryValue> metadata_dictionary,
+ scoped_ptr<std::vector<metadata::AttachedImage> > attached_images) {
if (!parse_success) {
SendResponse(false);
return;
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.h b/chrome/browser/extensions/api/media_galleries/media_galleries_api.h
index 94762c4..ee876b2 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.h
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.h
@@ -18,6 +18,7 @@
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_scan_manager_observer.h"
#include "chrome/common/extensions/api/media_galleries.h"
+#include "chrome/common/media_galleries/metadata_types.h"
#include "components/storage_monitor/media_storage_util.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
@@ -271,7 +272,8 @@ class MediaGalleriesGetMetadataFunction : public ChromeAsyncExtensionFunction {
int64 total_blob_length);
void OnSafeMediaMetadataParserDone(
- bool parse_success, base::DictionaryValue* metadata_dictionary);
+ bool parse_success, scoped_ptr<base::DictionaryValue> metadata_dictionary,
+ scoped_ptr<std::vector<metadata::AttachedImage> > attached_images);
};
} // namespace extensions
diff --git a/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.cc b/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.cc
index 7bf23e3..4500191 100644
--- a/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.cc
+++ b/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.cc
@@ -14,14 +14,14 @@ using content::BrowserThread;
namespace metadata {
-SafeMediaMetadataParser::SafeMediaMetadataParser(Profile* profile,
- const std::string& blob_uuid,
- int64 blob_size,
- const std::string& mime_type)
+SafeMediaMetadataParser::SafeMediaMetadataParser(
+ Profile* profile, const std::string& blob_uuid, int64 blob_size,
+ const std::string& mime_type, bool get_attached_images)
: profile_(profile),
blob_uuid_(blob_uuid),
blob_size_(blob_size),
mime_type_(mime_type),
+ get_attached_images_(get_attached_images),
parser_state_(INITIAL_STATE) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
@@ -51,24 +51,33 @@ void SafeMediaMetadataParser::StartWorkOnIOThread(
this, base::MessageLoopProxy::current())->AsWeakPtr();
utility_process_host_->Send(
- new ChromeUtilityMsg_ParseMediaMetadata(mime_type_, blob_size_));
+ new ChromeUtilityMsg_ParseMediaMetadata(mime_type_, blob_size_,
+ get_attached_images_));
parser_state_ = STARTED_PARSING_STATE;
}
void SafeMediaMetadataParser::OnParseMediaMetadataFinished(
- bool parse_success, const base::DictionaryValue& metadata_dictionary) {
+ bool parse_success, const base::DictionaryValue& metadata_dictionary,
+ const std::vector<AttachedImage>& attached_images) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!callback_.is_null());
if (parser_state_ != STARTED_PARSING_STATE)
return;
+ // We need to make a scoped copy of this vector since it will be destroyed
+ // at the end of the IPC message handler.
+ scoped_ptr<std::vector<metadata::AttachedImage> > attached_images_copy =
+ make_scoped_ptr(new std::vector<metadata::AttachedImage>(
+ attached_images));
+
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(callback_, parse_success,
- base::Owned(metadata_dictionary.DeepCopy())));
+ base::Passed(make_scoped_ptr(metadata_dictionary.DeepCopy())),
+ base::Passed(&attached_images_copy)));
parser_state_ = FINISHED_PARSING_STATE;
}
@@ -120,7 +129,9 @@ void SafeMediaMetadataParser::OnProcessCrashed(int exit_code) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(callback_, false, base::Owned(new base::DictionaryValue)));
+ base::Bind(callback_, false,
+ base::Passed(scoped_ptr<base::DictionaryValue>()),
+ base::Passed(scoped_ptr<std::vector<AttachedImage> >())));
parser_state_ = FINISHED_PARSING_STATE;
}
diff --git a/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.h b/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.h
index c5022fe..eeada27 100644
--- a/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.h
+++ b/chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.h
@@ -5,11 +5,15 @@
#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_
#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_
+#include <string>
+#include <vector>
+
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/common/extensions/api/media_galleries.h"
+#include "chrome/common/media_galleries/metadata_types.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h"
@@ -29,11 +33,14 @@ class SafeMediaMetadataParser : public content::UtilityProcessHostClient {
public:
// |metadata_dictionary| is owned by the callback.
typedef base::Callback<
- void(bool parse_success, base::DictionaryValue* metadata_dictionary)>
+ void(bool parse_success,
+ scoped_ptr<base::DictionaryValue> metadata_dictionary,
+ scoped_ptr<std::vector<AttachedImage> > attached_images)>
DoneCallback;
SafeMediaMetadataParser(Profile* profile, const std::string& blob_uuid,
- int64 blob_size, const std::string& mime_type);
+ int64 blob_size, const std::string& mime_type,
+ bool get_attached_images);
// Should be called on the UI thread. |callback| also runs on the UI thread.
void Start(const DoneCallback& callback);
@@ -54,8 +61,8 @@ class SafeMediaMetadataParser : public content::UtilityProcessHostClient {
// Notification from the utility process when it finishes parsing metadata.
// Runs on the IO thread.
void OnParseMediaMetadataFinished(
- bool parse_success,
- const base::DictionaryValue& metadata_dictionary);
+ bool parse_success, const base::DictionaryValue& metadata_dictionary,
+ const std::vector<AttachedImage>& attached_images);
// Sequence of functions that bounces from the IO thread to the UI thread to
// read the blob data, then sends the data back to the utility process.
@@ -78,6 +85,7 @@ class SafeMediaMetadataParser : public content::UtilityProcessHostClient {
const std::string blob_uuid_;
const int64 blob_size_;
const std::string mime_type_;
+ bool get_attached_images_;
DoneCallback callback_;
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index eab0246..30785c9 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -252,6 +252,7 @@
'common/media/webrtc_logging_messages.h',
'common/media/webrtc_logging_message_data.cc',
'common/media/webrtc_logging_message_data.h',
+ 'common/media_galleries/metadata_types.h',
'common/metrics/caching_permuted_entropy_provider.cc',
'common/metrics/caching_permuted_entropy_provider.h',
'common/metrics/metrics_service_base.cc',
@@ -390,6 +391,7 @@
['exclude', '^common/custom_handlers/'],
['exclude', '^common/extensions/'],
['exclude', '^common/logging_chrome\\.'],
+ ['exclude', '^common/media_galleries/'],
['exclude', '^common/multi_process_'],
['exclude', '^common/nacl_'],
['exclude', '^common/pepper_flash\\.'],
@@ -435,6 +437,7 @@
['exclude', '^common/importer/'],
['include', '^common/importer/imported_favicon_usage.cc$'],
['include', '^common/importer/imported_favicon_usage.h$'],
+ ['exclude', '^common/media_galleries/'],
['exclude', '^common/service_'],
],
'sources!': [
diff --git a/chrome/common/chrome_utility_messages.h b/chrome/common/chrome_utility_messages.h
index c375565..c6da23b 100644
--- a/chrome/common/chrome_utility_messages.h
+++ b/chrome/common/chrome_utility_messages.h
@@ -16,6 +16,7 @@
#include "chrome/common/extensions/update_manifest.h"
#include "chrome/common/media_galleries/iphoto_library.h"
#include "chrome/common/media_galleries/itunes_library.h"
+#include "chrome/common/media_galleries/metadata_types.h"
#include "chrome/common/media_galleries/picasa_types.h"
#include "chrome/common/safe_browsing/zip_analyzer.h"
#include "ipc/ipc_message_macros.h"
@@ -147,6 +148,13 @@ IPC_STRUCT_TRAITS_BEGIN(picasa::FolderINIContents)
IPC_STRUCT_TRAITS_END()
#endif // defined(OS_WIN) || defined(OS_MACOSX)
+#if !defined(OS_ANDROID) && !defined(OS_IOS)
+IPC_STRUCT_TRAITS_BEGIN(metadata::AttachedImage)
+ IPC_STRUCT_TRAITS_MEMBER(type)
+ IPC_STRUCT_TRAITS_MEMBER(data)
+IPC_STRUCT_TRAITS_END()
+#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
+
//------------------------------------------------------------------------------
// Utility process messages:
// These are messages from the browser to the utility process.
@@ -291,9 +299,10 @@ IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_CheckMediaFile,
int64 /* milliseconds_of_decoding */,
IPC::PlatformFileForTransit /* Media file to parse */)
-IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_ParseMediaMetadata,
+IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_ParseMediaMetadata,
std::string /* mime_type */,
- int64 /* total_size */)
+ int64 /* total_size */,
+ bool /* get_attached_images */)
IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RequestBlobBytes_Finished,
int64 /* request_id */,
@@ -481,9 +490,11 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished,
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_CheckMediaFile_Finished,
bool /* passed_checks */)
-IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_ParseMediaMetadata_Finished,
- bool /* parse_success */,
- base::DictionaryValue /* metadata */)
+IPC_MESSAGE_CONTROL3(
+ ChromeUtilityHostMsg_ParseMediaMetadata_Finished,
+ bool /* parse_success */,
+ base::DictionaryValue /* metadata */,
+ std::vector<metadata::AttachedImage> /* attached_images */)
IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_RequestBlobBytes,
int64 /* request_id */,
diff --git a/chrome/common/media_galleries/metadata_types.h b/chrome/common/media_galleries/metadata_types.h
new file mode 100644
index 0000000..d9aa515
--- /dev/null
+++ b/chrome/common/media_galleries/metadata_types.h
@@ -0,0 +1,19 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_MEDIA_GALLERIES_METADATA_TYPES_H_
+#define CHROME_COMMON_MEDIA_GALLERIES_METADATA_TYPES_H_
+
+#include <string>
+
+namespace metadata {
+
+struct AttachedImage {
+ std::string type;
+ std::string data;
+};
+
+} // namespace metadata
+
+#endif // CHROME_COMMON_MEDIA_GALLERIES_METADATA_TYPES_H_
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index 1ca9c94..777149d 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -68,6 +68,7 @@
#endif // defined(OS_WIN) || defined(OS_MACOSX)
#if !defined(OS_ANDROID) && !defined(OS_IOS)
+#include "chrome/common/media_galleries/metadata_types.h"
#include "chrome/utility/media_galleries/image_metadata_extractor.h"
#include "chrome/utility/media_galleries/ipc_data_source.h"
#include "chrome/utility/media_galleries/media_metadata_parser.h"
@@ -170,7 +171,7 @@ class PdfFunctionsBase {
const base::FilePath& pdf_module_path,
const base::ScopedNativeLibrary& pdf_lib) {
return true;
- };
+ }
private:
// Exported by PDF plugin.
@@ -303,9 +304,10 @@ typedef PdfFunctionsBase PdfFunctions;
#if !defined(OS_ANDROID) && !defined(OS_IOS)
void FinishParseMediaMetadata(
metadata::MediaMetadataParser* parser,
- scoped_ptr<extensions::api::media_galleries::MediaMetadata> metadata) {
+ const extensions::api::media_galleries::MediaMetadata& metadata,
+ const std::vector<metadata::AttachedImage>& attached_images) {
Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished(
- true, *(metadata->ToValue().get())));
+ true, *metadata.ToValue(), attached_images));
ReleaseProcessIfNeeded();
}
#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
@@ -919,14 +921,13 @@ void ChromeContentUtilityClient::OnCheckMediaFile(
}
void ChromeContentUtilityClient::OnParseMediaMetadata(
- const std::string& mime_type,
- int64 total_size) {
+ const std::string& mime_type, int64 total_size, bool get_attached_images) {
// Only one IPCDataSource may be created and added to the list of handlers.
metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
handlers_.push_back(source);
- metadata::MediaMetadataParser* parser =
- new metadata::MediaMetadataParser(source, mime_type);
+ metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser(
+ source, mime_type, get_attached_images);
parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser)));
}
#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
diff --git a/chrome/utility/chrome_content_utility_client.h b/chrome/utility/chrome_content_utility_client.h
index c9e2d0e..8e6ba97 100644
--- a/chrome/utility/chrome_content_utility_client.h
+++ b/chrome/utility/chrome_content_utility_client.h
@@ -107,7 +107,8 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient {
#if !defined(OS_ANDROID) && !defined(OS_IOS)
void OnCheckMediaFile(int64 milliseconds_of_decoding,
const IPC::PlatformFileForTransit& media_file);
- void OnParseMediaMetadata(const std::string& mime_type, int64 total_size);
+ void OnParseMediaMetadata(const std::string& mime_type, int64 total_size,
+ bool get_attached_images);
#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
#if defined(OS_WIN)
diff --git a/chrome/utility/media_galleries/media_metadata_parser.cc b/chrome/utility/media_galleries/media_metadata_parser.cc
index 906ff45..dbce009 100644
--- a/chrome/utility/media_galleries/media_metadata_parser.cc
+++ b/chrome/utility/media_galleries/media_metadata_parser.cc
@@ -15,6 +15,7 @@
#include "chrome/utility/media_galleries/image_metadata_extractor.h"
#include "media/base/audio_video_metadata_extractor.h"
#include "media/base/data_source.h"
+#include "net/base/mime_sniffer.h"
namespace MediaGalleries = extensions::api::media_galleries;
@@ -49,16 +50,16 @@ void SetBoolScopedPtr(bool value, scoped_ptr<bool>* destination) {
// This runs on |media_thread_|, as the underlying FFmpeg operation is
// blocking, and the utility thread must not be blocked, so the media file
// bytes can be sent from the browser process to the utility process.
-scoped_ptr<MediaMetadataParser::MediaMetadata> ParseAudioVideoMetadata(
- media::DataSource* source,
- scoped_ptr<MediaMetadataParser::MediaMetadata> metadata) {
+void ParseAudioVideoMetadata(
+ media::DataSource* source, bool get_attached_images,
+ MediaMetadataParser::MediaMetadata* metadata,
+ std::vector<AttachedImage>* attached_images) {
DCHECK(source);
- DCHECK(metadata.get());
+ DCHECK(metadata);
media::AudioVideoMetadataExtractor extractor;
- // TODO(tommycli): Add attached picture extraction.
- if (!extractor.Extract(source, false /* extract_attached_pics */))
- return metadata.Pass();
+ if (!extractor.Extract(source, get_attached_images))
+ return;
if (extractor.duration() >= 0)
metadata->duration.reset(new double(extractor.duration()));
@@ -97,65 +98,89 @@ scoped_ptr<MediaMetadataParser::MediaMetadata> ParseAudioVideoMetadata(
metadata->raw_tags.push_back(stream_info);
}
- return metadata.Pass();
+ if (get_attached_images) {
+ for (std::vector<std::string>::const_iterator it =
+ extractor.attached_images_bytes().begin();
+ it != extractor.attached_images_bytes().end(); ++it) {
+ attached_images->push_back(AttachedImage());
+ attached_images->back().data = *it;
+ net::SniffMimeTypeFromLocalData(it->c_str(), it->length(),
+ &attached_images->back().type);
+ }
+ }
}
-void FinishParseImageMetadata(
- ImageMetadataExtractor* extractor,
- scoped_ptr<MediaMetadataParser::MediaMetadata> metadata,
+void FinishParseAudioVideoMetadata(
MediaMetadataParser::MetadataCallback callback,
- bool extract_success) {
+ MediaMetadataParser::MediaMetadata* metadata,
+ std::vector<AttachedImage>* attached_images) {
+ DCHECK(!callback.is_null());
+ DCHECK(metadata);
+ DCHECK(attached_images);
+
+ callback.Run(*metadata, *attached_images);
+}
+
+void FinishParseImageMetadata(
+ ImageMetadataExtractor* extractor, const std::string& mime_type,
+ MediaMetadataParser::MetadataCallback callback, bool extract_success) {
DCHECK(extractor);
- DCHECK(metadata.get());
+ MediaMetadataParser::MediaMetadata metadata;
+ metadata.mime_type = mime_type;
if (!extract_success) {
- callback.Run(metadata.Pass());
+ callback.Run(metadata, std::vector<AttachedImage>());
return;
}
- SetIntScopedPtr(extractor->height(), &metadata->height);
- SetIntScopedPtr(extractor->width(), &metadata->width);
+ SetIntScopedPtr(extractor->height(), &metadata.height);
+ SetIntScopedPtr(extractor->width(), &metadata.width);
- SetIntScopedPtr(extractor->rotation(), &metadata->rotation);
+ SetIntScopedPtr(extractor->rotation(), &metadata.rotation);
- SetDoubleScopedPtr(extractor->x_resolution(), &metadata->x_resolution);
- SetDoubleScopedPtr(extractor->y_resolution(), &metadata->y_resolution);
- SetBoolScopedPtr(extractor->flash_fired(), &metadata->flash_fired);
- SetStringScopedPtr(extractor->camera_make(), &metadata->camera_make);
- SetStringScopedPtr(extractor->camera_model(), &metadata->camera_model);
+ SetDoubleScopedPtr(extractor->x_resolution(), &metadata.x_resolution);
+ SetDoubleScopedPtr(extractor->y_resolution(), &metadata.y_resolution);
+ SetBoolScopedPtr(extractor->flash_fired(), &metadata.flash_fired);
+ SetStringScopedPtr(extractor->camera_make(), &metadata.camera_make);
+ SetStringScopedPtr(extractor->camera_model(), &metadata.camera_model);
SetDoubleScopedPtr(extractor->exposure_time_sec(),
- &metadata->exposure_time_seconds);
+ &metadata.exposure_time_seconds);
- SetDoubleScopedPtr(extractor->f_number(), &metadata->f_number);
- SetDoubleScopedPtr(extractor->focal_length_mm(), &metadata->focal_length_mm);
- SetDoubleScopedPtr(extractor->iso_equivalent(), &metadata->iso_equivalent);
+ SetDoubleScopedPtr(extractor->f_number(), &metadata.f_number);
+ SetDoubleScopedPtr(extractor->focal_length_mm(), &metadata.focal_length_mm);
+ SetDoubleScopedPtr(extractor->iso_equivalent(), &metadata.iso_equivalent);
- callback.Run(metadata.Pass());
+ callback.Run(metadata, std::vector<AttachedImage>());
}
} // namespace
MediaMetadataParser::MediaMetadataParser(media::DataSource* source,
- const std::string& mime_type)
+ const std::string& mime_type,
+ bool get_attached_images)
: source_(source),
- mime_type_(mime_type) {
+ mime_type_(mime_type),
+ get_attached_images_(get_attached_images) {
}
MediaMetadataParser::~MediaMetadataParser() {}
void MediaMetadataParser::Start(const MetadataCallback& callback) {
- scoped_ptr<MediaMetadata> metadata(new MediaMetadata);
- metadata->mime_type = mime_type_;
-
if (StartsWithASCII(mime_type_, "audio/", true) ||
StartsWithASCII(mime_type_, "video/", true)) {
+ 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());
- base::PostTaskAndReplyWithResult(
- media_thread_->message_loop_proxy(),
+ media_thread_->message_loop_proxy()->PostTaskAndReply(
FROM_HERE,
- base::Bind(&ParseAudioVideoMetadata, source_, base::Passed(&metadata)),
- callback);
+ base::Bind(&ParseAudioVideoMetadata, source_, get_attached_images_,
+ metadata, attached_images),
+ base::Bind(&FinishParseAudioVideoMetadata, callback,
+ base::Owned(metadata), base::Owned(attached_images)));
return;
}
@@ -164,12 +189,11 @@ void MediaMetadataParser::Start(const MetadataCallback& callback) {
extractor->Extract(
source_,
base::Bind(&FinishParseImageMetadata, base::Owned(extractor),
- base::Passed(&metadata), callback));
+ mime_type_, callback));
return;
}
- // TODO(tommycli): Implement for image mime types.
- callback.Run(metadata.Pass());
+ callback.Run(MediaMetadata(), std::vector<AttachedImage>());
}
} // namespace metadata
diff --git a/chrome/utility/media_galleries/media_metadata_parser.h b/chrome/utility/media_galleries/media_metadata_parser.h
index 980c07a..5477f7b 100644
--- a/chrome/utility/media_galleries/media_metadata_parser.h
+++ b/chrome/utility/media_galleries/media_metadata_parser.h
@@ -5,9 +5,13 @@
#ifndef CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
#define CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
+#include <string>
+#include <vector>
+
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/common/extensions/api/media_galleries.h"
+#include "chrome/common/media_galleries/metadata_types.h"
namespace base {
class Thread;
@@ -27,11 +31,15 @@ namespace metadata {
class MediaMetadataParser {
public:
typedef extensions::api::media_galleries::MediaMetadata MediaMetadata;
- typedef base::Callback<void(scoped_ptr<MediaMetadata>)> MetadataCallback;
+ typedef base::Callback<
+ void(const MediaMetadata& metadata,
+ const std::vector<AttachedImage>& attached_images)>
+ MetadataCallback;
// Does not take ownership of |source|. Caller is responsible for ensuring
// that |source| outlives this object.
- MediaMetadataParser(media::DataSource* source, const std::string& mime_type);
+ MediaMetadataParser(media::DataSource* source, const std::string& mime_type,
+ bool get_attached_images);
~MediaMetadataParser();
@@ -44,6 +52,8 @@ class MediaMetadataParser {
const std::string mime_type_;
+ bool get_attached_images_;
+
// Thread that blocking media parsing operations run on while the main thread
// handles messages from the browser process.
// TODO(tommycli): Replace with a reference to a WorkerPool if we ever use