| 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 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_ | 5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_ |
| 6 #define CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_ | 6 #define CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // This class lives and operates on the utility thread of the utility process, | 29 // This class lives and operates on the utility thread of the utility process, |
| 30 // as we wish to sandbox potentially dangerous operations on user-provided data. | 30 // as we wish to sandbox potentially dangerous operations on user-provided data. |
| 31 class MediaMetadataParser { | 31 class MediaMetadataParser { |
| 32 public: | 32 public: |
| 33 typedef extensions::api::media_galleries::MediaMetadata MediaMetadata; | 33 typedef extensions::api::media_galleries::MediaMetadata MediaMetadata; |
| 34 typedef base::Callback< | 34 typedef base::Callback< |
| 35 void(const MediaMetadata& metadata, | 35 void(const MediaMetadata& metadata, |
| 36 const std::vector<AttachedImage>& attached_images)> | 36 const std::vector<AttachedImage>& attached_images)> |
| 37 MetadataCallback; | 37 MetadataCallback; |
| 38 | 38 |
| 39 // Does not take ownership of |source|. Caller is responsible for ensuring | 39 MediaMetadataParser(std::unique_ptr<media::DataSource> source, |
| 40 // that |source| outlives this object. | 40 const std::string& mime_type, |
| 41 MediaMetadataParser(media::DataSource* source, const std::string& mime_type, | |
| 42 bool get_attached_images); | 41 bool get_attached_images); |
| 43 | 42 |
| 44 ~MediaMetadataParser(); | 43 ~MediaMetadataParser(); |
| 45 | 44 |
| 46 // |callback| is called on same message loop. | 45 // |callback| is called on same message loop. |
| 47 void Start(const MetadataCallback& callback); | 46 void Start(const MetadataCallback& callback); |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 // Only accessed on |media_thread_| from this class. | 49 // Only accessed on |media_thread_| from this class. |
| 51 media::DataSource* const source_; | 50 std::unique_ptr<media::DataSource> source_; |
| 52 | 51 |
| 53 const std::string mime_type_; | 52 const std::string mime_type_; |
| 54 | 53 |
| 55 bool get_attached_images_; | 54 bool get_attached_images_; |
| 56 | 55 |
| 57 // Thread that blocking media parsing operations run on while the main thread | 56 // Thread that blocking media parsing operations run on while the main thread |
| 58 // handles messages from the browser process. | 57 // handles messages from the browser process. |
| 59 // TODO(tommycli): Replace with a reference to a WorkerPool if we ever use | 58 // TODO(tommycli): Replace with a reference to a WorkerPool if we ever use |
| 60 // this class in batch mode. | 59 // this class in batch mode. |
| 61 std::unique_ptr<base::Thread> media_thread_; | 60 std::unique_ptr<base::Thread> media_thread_; |
| 62 | 61 |
| 63 DISALLOW_COPY_AND_ASSIGN(MediaMetadataParser); | 62 DISALLOW_COPY_AND_ASSIGN(MediaMetadataParser); |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 } // namespace metadata | 65 } // namespace metadata |
| 67 | 66 |
| 68 #endif // CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_ | 67 #endif // CHROME_UTILITY_MEDIA_GALLERIES_MEDIA_METADATA_PARSER_H_ |
| OLD | NEW |