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 "base/json/json_writer.h" | 5 #include "base/json/json_writer.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 // Get the list of input devices. We can cheat in the unit test and | 243 // Get the list of input devices. We can cheat in the unit test and |
244 // run this on the main thread since nobody else will be running at | 244 // run this on the main thread since nobody else will be running at |
245 // the same time. | 245 // the same time. |
246 AudioDeviceNames devices; | 246 AudioDeviceNames devices; |
247 GetAudioDeviceNames(&AudioManager::GetAudioInputDeviceNames, &devices); | 247 GetAudioDeviceNames(&AudioManager::GetAudioInputDeviceNames, &devices); |
248 | 248 |
249 // Try to get an associated sink for each source. | 249 // Try to get an associated sink for each source. |
250 for (AudioDeviceNames::const_iterator device = devices.begin(); | 250 for (AudioDeviceNames::const_iterator device = devices.begin(); |
251 device != devices.end(); | 251 device != devices.end(); |
252 ++device) { | 252 ++device) { |
253 | |
254 scoped_refptr<WebrtcAudioPrivateGetAssociatedSinkFunction> function = | |
255 new WebrtcAudioPrivateGetAssociatedSinkFunction(); | |
256 | |
253 std::string raw_source_id = device->unique_id; | 257 std::string raw_source_id = device->unique_id; |
254 VLOG(2) << "Trying to find associated sink for device " << raw_source_id; | 258 VLOG(2) << "Trying to find associated sink for device " << raw_source_id; |
255 GURL origin(GURL("http://www.google.com/").GetOrigin()); | 259 GURL origin(GURL("http://www.google.com/").GetOrigin()); |
256 std::string source_id_in_origin = | 260 std::string source_id_in_origin = content::GetHMACForMediaDeviceID( |
257 content::GetHMACForMediaDeviceID(origin, raw_source_id); | 261 function->GetProfile()->GetResourceContext(), |
Jói
2013/11/05 14:14:08
I don't know for sure, but I would think function-
perkj_chrome
2013/11/05 16:25:06
Done.
| |
262 origin, | |
263 raw_source_id); | |
258 | 264 |
259 ListValue parameters; | 265 ListValue parameters; |
260 parameters.AppendString(origin.spec()); | 266 parameters.AppendString(origin.spec()); |
261 parameters.AppendString(source_id_in_origin); | 267 parameters.AppendString(source_id_in_origin); |
262 std::string parameter_string; | 268 std::string parameter_string; |
263 JSONWriter::Write(¶meters, ¶meter_string); | 269 JSONWriter::Write(¶meters, ¶meter_string); |
264 | 270 |
265 scoped_refptr<WebrtcAudioPrivateGetAssociatedSinkFunction> function = | 271 |
266 new WebrtcAudioPrivateGetAssociatedSinkFunction(); | |
267 scoped_ptr<base::Value> result( | 272 scoped_ptr<base::Value> result( |
268 RunFunctionAndReturnSingleResult(function.get(), | 273 RunFunctionAndReturnSingleResult(function.get(), |
269 parameter_string, | 274 parameter_string, |
270 browser())); | 275 browser())); |
271 std::string result_string; | 276 std::string result_string; |
272 JSONWriter::Write(result.get(), &result_string); | 277 JSONWriter::Write(result.get(), &result_string); |
273 VLOG(2) << "Results: " << result_string; | 278 VLOG(2) << "Results: " << result_string; |
274 } | 279 } |
275 } | 280 } |
276 | 281 |
(...skipping 10 matching lines...) Expand all Loading... | |
287 test_data_dir_.AppendASCII("webrtc_audio_private_event_listener")); | 292 test_data_dir_.AppendASCII("webrtc_audio_private_event_listener")); |
288 service->OnDevicesChanged(base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE); | 293 service->OnDevicesChanged(base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE); |
289 | 294 |
290 // Check that the extension got the notification. | 295 // Check that the extension got the notification. |
291 std::string result = ExecuteScriptInBackgroundPage(extension->id(), | 296 std::string result = ExecuteScriptInBackgroundPage(extension->id(), |
292 "reportIfGot()"); | 297 "reportIfGot()"); |
293 EXPECT_EQ("true", result); | 298 EXPECT_EQ("true", result); |
294 } | 299 } |
295 | 300 |
296 } // namespace extensions | 301 } // namespace extensions |
OLD | NEW |