OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/media_galleries/fileapi/safe_media_metadata_parser.h" | 5 #include "chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "chrome/browser/extensions/blob_reader.h" | 10 #include "chrome/browser/extensions/blob_reader.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 base::MakeUnique<std::vector<metadata::AttachedImage>>(); | 98 base::MakeUnique<std::vector<metadata::AttachedImage>>(); |
99 | 99 |
100 content::BrowserThread::PostTask( | 100 content::BrowserThread::PostTask( |
101 content::BrowserThread::UI, FROM_HERE, | 101 content::BrowserThread::UI, FROM_HERE, |
102 base::Bind(callback_, false, base::Passed(&metadata_dictionary), | 102 base::Bind(callback_, false, base::Passed(&metadata_dictionary), |
103 base::Passed(&attached_images))); | 103 base::Passed(&attached_images))); |
104 } | 104 } |
105 | 105 |
106 void SafeMediaMetadataParser::ParseMediaMetadataDone( | 106 void SafeMediaMetadataParser::ParseMediaMetadataDone( |
107 bool parse_success, | 107 bool parse_success, |
108 std::unique_ptr<base::DictionaryValue> metadata_dictionary, | 108 const base::DictionaryValue& metadata_dictionary, |
109 const std::vector<AttachedImage>& attached_images) { | 109 const std::vector<AttachedImage>& attached_images) { |
110 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 110 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
111 | 111 |
112 utility_process_mojo_client_.reset(); // Terminate the utility process. | 112 utility_process_mojo_client_.reset(); // Terminate the utility process. |
113 media_data_source_.reset(); | 113 media_data_source_.reset(); |
114 | 114 |
115 // We need to make a scoped copy of this vector since it will be destroyed | 115 // We need to make a scoped copy of this vector since it will be destroyed |
116 // at the end of the handler. | 116 // at the end of the handler. |
117 std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images_copy = | 117 std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images_copy = |
118 base::MakeUnique<std::vector<metadata::AttachedImage>>(attached_images); | 118 base::MakeUnique<std::vector<metadata::AttachedImage>>(attached_images); |
119 | 119 |
120 content::BrowserThread::PostTask( | 120 content::BrowserThread::PostTask( |
121 content::BrowserThread::UI, FROM_HERE, | 121 content::BrowserThread::UI, FROM_HERE, |
122 base::Bind(callback_, parse_success, base::Passed(&metadata_dictionary), | 122 base::Bind(callback_, parse_success, |
| 123 base::Passed(metadata_dictionary.CreateDeepCopy()), |
123 base::Passed(&attached_images_copy))); | 124 base::Passed(&attached_images_copy))); |
124 } | 125 } |
125 | 126 |
126 void SafeMediaMetadataParser::StartBlobRequest( | 127 void SafeMediaMetadataParser::StartBlobRequest( |
127 const extensions::mojom::MediaDataSource::ReadBlobCallback& callback, | 128 const extensions::mojom::MediaDataSource::ReadBlobCallback& callback, |
128 int64_t position, | 129 int64_t position, |
129 int64_t length) { | 130 int64_t length) { |
130 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 131 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
131 | 132 |
132 content::BrowserThread::PostTask( | 133 content::BrowserThread::PostTask( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 void SafeMediaMetadataParser::FinishBlobRequest( | 165 void SafeMediaMetadataParser::FinishBlobRequest( |
165 const extensions::mojom::MediaDataSource::ReadBlobCallback& callback, | 166 const extensions::mojom::MediaDataSource::ReadBlobCallback& callback, |
166 std::unique_ptr<std::string> data) { | 167 std::unique_ptr<std::string> data) { |
167 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 168 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
168 | 169 |
169 if (utility_process_mojo_client_) | 170 if (utility_process_mojo_client_) |
170 callback.Run(std::vector<uint8_t>(data->begin(), data->end())); | 171 callback.Run(std::vector<uint8_t>(data->begin(), data->end())); |
171 } | 172 } |
172 | 173 |
173 } // namespace metadata | 174 } // namespace metadata |
OLD | NEW |