| 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/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // Get the list of input devices. We can cheat in the unit test and | 256 // Get the list of input devices. We can cheat in the unit test and |
| 257 // run this on the main thread since nobody else will be running at | 257 // run this on the main thread since nobody else will be running at |
| 258 // the same time. | 258 // the same time. |
| 259 AudioDeviceNames devices; | 259 AudioDeviceNames devices; |
| 260 GetAudioDeviceNames(&AudioManager::GetAudioInputDeviceNames, &devices); | 260 GetAudioDeviceNames(&AudioManager::GetAudioInputDeviceNames, &devices); |
| 261 | 261 |
| 262 // Try to get an associated sink for each source. | 262 // Try to get an associated sink for each source. |
| 263 for (AudioDeviceNames::const_iterator device = devices.begin(); | 263 for (AudioDeviceNames::const_iterator device = devices.begin(); |
| 264 device != devices.end(); | 264 device != devices.end(); |
| 265 ++device) { | 265 ++device) { |
| 266 |
| 267 scoped_refptr<WebrtcAudioPrivateGetAssociatedSinkFunction> function = |
| 268 new WebrtcAudioPrivateGetAssociatedSinkFunction(); |
| 269 |
| 266 std::string raw_source_id = device->unique_id; | 270 std::string raw_source_id = device->unique_id; |
| 267 VLOG(2) << "Trying to find associated sink for device " << raw_source_id; | 271 VLOG(2) << "Trying to find associated sink for device " << raw_source_id; |
| 268 GURL origin(GURL("http://www.google.com/").GetOrigin()); | 272 GURL origin(GURL("http://www.google.com/").GetOrigin()); |
| 269 std::string source_id_in_origin = | 273 std::string source_id_in_origin = content::GetHMACForMediaDeviceID( |
| 270 content::GetHMACForMediaDeviceID(origin, raw_source_id); | 274 profile()->GetResourceContext(), |
| 275 origin, |
| 276 raw_source_id); |
| 271 | 277 |
| 272 ListValue parameters; | 278 ListValue parameters; |
| 273 parameters.AppendString(origin.spec()); | 279 parameters.AppendString(origin.spec()); |
| 274 parameters.AppendString(source_id_in_origin); | 280 parameters.AppendString(source_id_in_origin); |
| 275 std::string parameter_string; | 281 std::string parameter_string; |
| 276 JSONWriter::Write(¶meters, ¶meter_string); | 282 JSONWriter::Write(¶meters, ¶meter_string); |
| 277 | 283 |
| 278 scoped_refptr<WebrtcAudioPrivateGetAssociatedSinkFunction> function = | 284 |
| 279 new WebrtcAudioPrivateGetAssociatedSinkFunction(); | |
| 280 scoped_ptr<base::Value> result( | 285 scoped_ptr<base::Value> result( |
| 281 RunFunctionAndReturnSingleResult(function.get(), | 286 RunFunctionAndReturnSingleResult(function.get(), |
| 282 parameter_string, | 287 parameter_string, |
| 283 browser())); | 288 browser())); |
| 284 std::string result_string; | 289 std::string result_string; |
| 285 JSONWriter::Write(result.get(), &result_string); | 290 JSONWriter::Write(result.get(), &result_string); |
| 286 VLOG(2) << "Results: " << result_string; | 291 VLOG(2) << "Results: " << result_string; |
| 287 } | 292 } |
| 288 } | 293 } |
| 289 | 294 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 347 |
| 343 ASSERT_TRUE(content::ExecuteScript(tab, "browsertestRunAllTests();")); | 348 ASSERT_TRUE(content::ExecuteScript(tab, "browsertestRunAllTests();")); |
| 344 | 349 |
| 345 content::TitleWatcher title_watcher(tab, ASCIIToUTF16("success")); | 350 content::TitleWatcher title_watcher(tab, ASCIIToUTF16("success")); |
| 346 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("failure")); | 351 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("failure")); |
| 347 string16 result = title_watcher.WaitAndGetTitle(); | 352 string16 result = title_watcher.WaitAndGetTitle(); |
| 348 EXPECT_EQ(ASCIIToUTF16("success"), result); | 353 EXPECT_EQ(ASCIIToUTF16("success"), result); |
| 349 } | 354 } |
| 350 | 355 |
| 351 } // namespace extensions | 356 } // namespace extensions |
| OLD | NEW |