Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/browser/media_galleries/fileapi/safe_media_metadata_parser.cc

Issue 2746423002: Safe media metadata parser: create mojo client with MakeUnique<> (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 content::BrowserThread::PostTask( 59 content::BrowserThread::PostTask(
60 content::BrowserThread::IO, FROM_HERE, 60 content::BrowserThread::IO, FROM_HERE,
61 base::Bind(&SafeMediaMetadataParser::StartOnIOThread, this, callback)); 61 base::Bind(&SafeMediaMetadataParser::StartOnIOThread, this, callback));
62 } 62 }
63 63
64 SafeMediaMetadataParser::~SafeMediaMetadataParser() = default; 64 SafeMediaMetadataParser::~SafeMediaMetadataParser() = default;
65 65
66 void SafeMediaMetadataParser::StartOnIOThread(const DoneCallback& callback) { 66 void SafeMediaMetadataParser::StartOnIOThread(const DoneCallback& callback) {
67 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 67 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
68 DCHECK(!utility_process_mojo_client_); 68 DCHECK(!utility_process_mojo_client_);
69 DCHECK(!callback.is_null()); 69 DCHECK(callback);
70 70
71 callback_ = callback; 71 callback_ = callback;
72 72
73 const base::string16 utility_process_name = 73 utility_process_mojo_client_ = base::MakeUnique<
74 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_MEDIA_FILE_CHECKER_NAME); 74 content::UtilityProcessMojoClient<extensions::mojom::MediaParser>>(
75 75 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_MEDIA_FILE_CHECKER_NAME));
76 utility_process_mojo_client_.reset(
77 new content::UtilityProcessMojoClient<extensions::mojom::MediaParser>(
78 utility_process_name));
79 utility_process_mojo_client_->set_error_callback( 76 utility_process_mojo_client_->set_error_callback(
80 base::Bind(&SafeMediaMetadataParser::ParseMediaMetadataFailed, this)); 77 base::Bind(&SafeMediaMetadataParser::ParseMediaMetadataFailed, this));
81 78
82 utility_process_mojo_client_->Start(); // Start the utility process. 79 utility_process_mojo_client_->Start(); // Start the utility process.
83 80
84 extensions::mojom::MediaDataSourcePtr source; 81 extensions::mojom::MediaDataSourcePtr source;
85 media_data_source_ = base::MakeUnique<MediaDataSourceImpl>(this, &source); 82 media_data_source_ = base::MakeUnique<MediaDataSourceImpl>(this, &source);
86 83
87 utility_process_mojo_client_->service()->ParseMediaMetadata( 84 utility_process_mojo_client_->service()->ParseMediaMetadata(
88 mime_type_, blob_size_, get_attached_images_, std::move(source), 85 mime_type_, blob_size_, get_attached_images_, std::move(source),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void SafeMediaMetadataParser::FinishBlobRequest( 164 void SafeMediaMetadataParser::FinishBlobRequest(
168 const extensions::mojom::MediaDataSource::ReadBlobCallback& callback, 165 const extensions::mojom::MediaDataSource::ReadBlobCallback& callback,
169 std::unique_ptr<std::string> data) { 166 std::unique_ptr<std::string> data) {
170 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 167 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
171 168
172 if (utility_process_mojo_client_) 169 if (utility_process_mojo_client_)
173 callback.Run(std::vector<uint8_t>(data->begin(), data->end())); 170 callback.Run(std::vector<uint8_t>(data->begin(), data->end()));
174 } 171 }
175 172
176 } // namespace metadata 173 } // namespace metadata
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698