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

Side by Side Diff: chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc

Issue 2152373003: [Extensions] Code Cleanup - Remove redundant smart-ptr get()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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
OLDNEW
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 #include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_privat e_api.h" 5 #include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_privat e_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 std::unique_ptr<AudioDeviceNames> device_names) { 133 std::unique_ptr<AudioDeviceNames> device_names) {
134 NOTREACHED(); 134 NOTREACHED();
135 } 135 }
136 136
137 bool WebrtcAudioPrivateFunction::GetControllerList(const RequestInfo& request) { 137 bool WebrtcAudioPrivateFunction::GetControllerList(const RequestInfo& request) {
138 content::RenderProcessHost* rph = nullptr; 138 content::RenderProcessHost* rph = nullptr;
139 139
140 // If |guest_process_id| is defined, directly use this id to find the 140 // If |guest_process_id| is defined, directly use this id to find the
141 // corresponding RenderProcessHost. 141 // corresponding RenderProcessHost.
142 if (request.guest_process_id.get()) { 142 if (request.guest_process_id.get()) {
143 rph = content::RenderProcessHost::FromID(*request.guest_process_id.get()); 143 rph = content::RenderProcessHost::FromID(*request.guest_process_id);
144 } else if (request.tab_id.get()) { 144 } else if (request.tab_id.get()) {
145 int tab_id = *request.tab_id.get(); 145 int tab_id = *request.tab_id;
146 content::WebContents* contents = NULL; 146 content::WebContents* contents = NULL;
147 if (!ExtensionTabUtil::GetTabById(tab_id, GetProfile(), true, NULL, NULL, 147 if (!ExtensionTabUtil::GetTabById(tab_id, GetProfile(), true, NULL, NULL,
148 &contents, NULL)) { 148 &contents, NULL)) {
149 error_ = extensions::ErrorUtils::FormatErrorMessage( 149 error_ = extensions::ErrorUtils::FormatErrorMessage(
150 extensions::tabs_constants::kTabNotFoundError, 150 extensions::tabs_constants::kTabNotFoundError,
151 base::IntToString(tab_id)); 151 base::IntToString(tab_id));
152 return false; 152 return false;
153 } 153 }
154 rph = contents->GetRenderProcessHost(); 154 rph = contents->GetRenderProcessHost();
155 } else { 155 } else {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 bool WebrtcAudioPrivateSetActiveSinkFunction::RunAsync() { 316 bool WebrtcAudioPrivateSetActiveSinkFunction::RunAsync() {
317 DCHECK_CURRENTLY_ON(BrowserThread::UI); 317 DCHECK_CURRENTLY_ON(BrowserThread::UI);
318 std::unique_ptr<wap::SetActiveSink::Params> params( 318 std::unique_ptr<wap::SetActiveSink::Params> params(
319 wap::SetActiveSink::Params::Create(*args_)); 319 wap::SetActiveSink::Params::Create(*args_));
320 EXTENSION_FUNCTION_VALIDATE(params.get()); 320 EXTENSION_FUNCTION_VALIDATE(params.get());
321 321
322 InitDeviceIDSalt(); 322 InitDeviceIDSalt();
323 323
324 if (params->request.guest_process_id.get()) { 324 if (params->request.guest_process_id.get()) {
325 request_info_.guest_process_id.reset( 325 request_info_.guest_process_id.reset(
326 new int(*params->request.guest_process_id.get())); 326 new int(*params->request.guest_process_id));
327 } else if (params->request.tab_id.get()) { 327 } else if (params->request.tab_id.get()) {
328 request_info_.tab_id.reset(new int(*params->request.tab_id.get())); 328 request_info_.tab_id.reset(new int(*params->request.tab_id));
329 } else { 329 } else {
330 return false; 330 return false;
331 } 331 }
332 332
333 sink_id_ = params->sink_id; 333 sink_id_ = params->sink_id;
334 334
335 return GetControllerList(request_info_); 335 return GetControllerList(request_info_);
336 } 336 }
337 337
338 void WebrtcAudioPrivateSetActiveSinkFunction::OnControllerList( 338 void WebrtcAudioPrivateSetActiveSinkFunction::OnControllerList(
339 const RenderProcessHost::AudioOutputControllerList& controllers) { 339 const RenderProcessHost::AudioOutputControllerList& controllers) {
340 DCHECK_CURRENTLY_ON(BrowserThread::UI); 340 DCHECK_CURRENTLY_ON(BrowserThread::UI);
341 341
342 std::string requested_process_type; 342 std::string requested_process_type;
343 int requested_process_id; 343 int requested_process_id;
344 if (request_info_.guest_process_id.get()) { 344 if (request_info_.guest_process_id.get()) {
345 requested_process_type = "guestProcessId"; 345 requested_process_type = "guestProcessId";
346 requested_process_id = *request_info_.guest_process_id.get(); 346 requested_process_id = *request_info_.guest_process_id;
347 } else { 347 } else {
348 requested_process_type = "tabId"; 348 requested_process_type = "tabId";
349 requested_process_id = *request_info_.tab_id.get(); 349 requested_process_id = *request_info_.tab_id;
350 } 350 }
351 351
352 controllers_ = controllers; 352 controllers_ = controllers;
353 num_remaining_sink_ids_ = controllers_.size(); 353 num_remaining_sink_ids_ = controllers_.size();
354 if (num_remaining_sink_ids_ == 0) { 354 if (num_remaining_sink_ids_ == 0) {
355 error_ = extensions::ErrorUtils::FormatErrorMessage( 355 error_ = extensions::ErrorUtils::FormatErrorMessage(
356 "No active stream for " + requested_process_type + " *", 356 "No active stream for " + requested_process_type + " *",
357 base::IntToString(requested_process_id)); 357 base::IntToString(requested_process_id));
358 SendResponse(false); 358 SendResponse(false);
359 } else { 359 } else {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 results_.reset(wap::GetAssociatedSink::Results::Create("").release()); 497 results_.reset(wap::GetAssociatedSink::Results::Create("").release());
498 } else { 498 } else {
499 results_.reset( 499 results_.reset(
500 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); 500 wap::GetAssociatedSink::Results::Create(associated_sink_id).release());
501 } 501 }
502 502
503 SendResponse(true); 503 SendResponse(true);
504 } 504 }
505 505
506 } // namespace extensions 506 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698