Chromium Code Reviews| 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 #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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 | 286 |
| 287 void WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetDevicesDone() { | 287 void WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetDevicesDone() { |
| 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 289 BrowserThread::PostTaskAndReplyWithResult( | 289 BrowserThread::PostTaskAndReplyWithResult( |
| 290 BrowserThread::IO, | 290 BrowserThread::IO, |
| 291 FROM_HERE, | 291 FROM_HERE, |
| 292 base::Bind(&WebrtcAudioPrivateGetAssociatedSinkFunction:: | 292 base::Bind(&WebrtcAudioPrivateGetAssociatedSinkFunction:: |
| 293 GetRawSourceIDOnIOThread, | 293 GetRawSourceIDOnIOThread, |
| 294 this, | 294 this, |
| 295 GURL(params_->security_origin), | 295 GURL(params_->security_origin), |
| 296 GetProfile()->GetResourceContext(), | |
|
Jói
2013/12/02 10:05:53
nit: I would group the two explicit parameters tog
perkj_chrome
2013/12/02 13:26:48
Done.
| |
| 296 params_->source_id_in_origin), | 297 params_->source_id_in_origin), |
| 297 base::Bind( | 298 base::Bind( |
| 298 &WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetRawSourceIDDone, | 299 &WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetRawSourceIDDone, |
| 299 this)); | 300 this)); |
| 300 } | 301 } |
| 301 | 302 |
| 302 std::string | 303 std::string |
| 303 WebrtcAudioPrivateGetAssociatedSinkFunction::GetRawSourceIDOnIOThread( | 304 WebrtcAudioPrivateGetAssociatedSinkFunction::GetRawSourceIDOnIOThread( |
| 304 GURL security_origin, const std::string& source_id_in_origin) { | 305 GURL security_origin, |
| 306 content::ResourceContext* context, | |
| 307 const std::string& source_id_in_origin) { | |
| 305 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 306 | 309 |
| 307 // Find the raw source ID for source_id_in_origin. | 310 // Find the raw source ID for source_id_in_origin. |
| 308 std::string raw_source_id; | 311 std::string raw_source_id; |
| 309 for (AudioDeviceNames::const_iterator it = source_devices_.begin(); | 312 for (AudioDeviceNames::const_iterator it = source_devices_.begin(); |
| 310 it != source_devices_.end(); | 313 it != source_devices_.end(); |
| 311 ++it) { | 314 ++it) { |
| 312 const std::string& id = it->unique_id; | 315 const std::string& id = it->unique_id; |
| 313 if (content::DoesMediaDeviceIDMatchHMAC( | 316 if (content::DoesMediaDeviceIDMatchHMAC( |
| 314 security_origin, source_id_in_origin, id)) { | 317 context, |
| 318 security_origin, | |
| 319 source_id_in_origin, | |
| 320 id)) { | |
| 315 raw_source_id = id; | 321 raw_source_id = id; |
| 316 DVLOG(2) << "Found raw ID " << raw_source_id | 322 DVLOG(2) << "Found raw ID " << raw_source_id |
| 317 << " for source ID in origin " << source_id_in_origin; | 323 << " for source ID in origin " << source_id_in_origin; |
| 318 break; | 324 break; |
| 319 } | 325 } |
| 320 } | 326 } |
| 321 | 327 |
| 322 return raw_source_id; | 328 return raw_source_id; |
| 323 } | 329 } |
| 324 | 330 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 354 void WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetAssociatedSinkDone( | 360 void WebrtcAudioPrivateGetAssociatedSinkFunction::OnGetAssociatedSinkDone( |
| 355 const std::string& associated_sink_id) { | 361 const std::string& associated_sink_id) { |
| 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 357 | 363 |
| 358 results_.reset( | 364 results_.reset( |
| 359 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); | 365 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); |
| 360 SendResponse(true); | 366 SendResponse(true); |
| 361 } | 367 } |
| 362 | 368 |
| 363 } // namespace extensions | 369 } // namespace extensions |
| OLD | NEW |