Update V8 to version 4.7.52.
[chromium-blink-merge.git] / chrome / utility / media_galleries / media_metadata_parser.h
blob5477f7bb8818daff002f095210e172045604c32e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
6 #define CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/common/extensions/api/media_galleries.h"
14 #include "chrome/common/media_galleries/metadata_types.h"
16 namespace base {
17 class Thread;
20 namespace media {
21 class DataSource;
24 namespace metadata {
26 // This class takes a MIME type and data source and parses its metadata. It
27 // handles audio, video, and images. It delegates its operations to FFMPEG,
28 // libexif, etc. This class lives and operates on the utility thread of the
29 // utility process, as we wish to sandbox potentially dangerous operations
30 // on user-provided data.
31 class MediaMetadataParser {
32 public:
33 typedef extensions::api::media_galleries::MediaMetadata MediaMetadata;
34 typedef base::Callback<
35 void(const MediaMetadata& metadata,
36 const std::vector<AttachedImage>& attached_images)>
37 MetadataCallback;
39 // Does not take ownership of |source|. Caller is responsible for ensuring
40 // that |source| outlives this object.
41 MediaMetadataParser(media::DataSource* source, const std::string& mime_type,
42 bool get_attached_images);
44 ~MediaMetadataParser();
46 // |callback| is called on same message loop.
47 void Start(const MetadataCallback& callback);
49 private:
50 // Only accessed on |media_thread_| from this class.
51 media::DataSource* const source_;
53 const std::string mime_type_;
55 bool get_attached_images_;
57 // Thread that blocking media parsing operations run on while the main thread
58 // handles messages from the browser process.
59 // TODO(tommycli): Replace with a reference to a WorkerPool if we ever use
60 // this class in batch mode.
61 scoped_ptr<base::Thread> media_thread_;
63 DISALLOW_COPY_AND_ASSIGN(MediaMetadataParser);
66 } // namespace metadata
68 #endif // CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_