summaryrefslogtreecommitdiffstats
path: root/chrome/utility/media_galleries/media_metadata_parser.h
diff options
context:
space:
mode:
authortommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 04:04:11 +0000
committertommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 04:04:11 +0000
commit78b6faa9b24a3ef18c116b955d5dfbcd11109cb0 (patch)
treed5cc1cf7271d4754c550c5eb478c22619be100b2 /chrome/utility/media_galleries/media_metadata_parser.h
parent244932d545ce1bea5e1724d3a77c5064fa567eb2 (diff)
downloadchromium_src-78b6faa9b24a3ef18c116b955d5dfbcd11109cb0.zip
chromium_src-78b6faa9b24a3ef18c116b955d5dfbcd11109cb0.tar.gz
chromium_src-78b6faa9b24a3ef18c116b955d5dfbcd11109cb0.tar.bz2
Media Galleries API Metadata: Utility process media metadata parser stub.
BUG=318450 Review URL: https://codereview.chromium.org/86373004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/utility/media_galleries/media_metadata_parser.h')
-rw-r--r--chrome/utility/media_galleries/media_metadata_parser.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome/utility/media_galleries/media_metadata_parser.h b/chrome/utility/media_galleries/media_metadata_parser.h
new file mode 100644
index 0000000..5a0573a
--- /dev/null
+++ b/chrome/utility/media_galleries/media_metadata_parser.h
@@ -0,0 +1,58 @@
+// Copyright 2013 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_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
+#define CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/extensions/api/media_galleries.h"
+
+namespace metadata {
+
+// This interface provides bytes needed by MediaMetadataParser.
+class DataReader {
+ public:
+ typedef base::Callback<void(const std::string& bytes)> ReadBytesCallback;
+
+ virtual ~DataReader() {}
+
+ // Called on the utility thread.
+ virtual void ReadBytes(int64 offset, int64 length,
+ const ReadBytesCallback& callback) = 0;
+};
+
+// This class takes a MIME type and data source and parses its metadata. It
+// handles audio, video, and images. It delegates its operations to FFMPEG,
+// libexif, etc. This class lives and operates on the utility thread of the
+// utility process, as we wish to sandbox potentially dangerous operations
+// on user-provided data.
+class MediaMetadataParser {
+ public:
+ typedef extensions::api::media_galleries::MediaMetadata MediaMetadata;
+ typedef base::Callback<void(scoped_ptr<MediaMetadata>)> MetadataCallback;
+
+ // Takes ownership of |reader|. The MIME type is always sniffed in the browser
+ // process, as it's faster (and safe enough) to sniff it there. When the user
+ // wants more metadata than just the MIME type, this class provides it.
+ MediaMetadataParser(DataReader* reader, const std::string& mime_type);
+
+ ~MediaMetadataParser();
+
+ // |callback| is called on same message loop.
+ void Start(const MetadataCallback& callback);
+
+ private:
+ scoped_ptr<DataReader> reader_;
+
+ MetadataCallback callback_;
+
+ scoped_ptr<MediaMetadata> metadata_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaMetadataParser);
+};
+
+} // namespace metadata
+
+#endif // CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_