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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 using content::RenderViewHost; | 26 using content::RenderViewHost; |
27 using media::AudioDeviceNames; | 27 using media::AudioDeviceNames; |
28 using media::AudioManager; | 28 using media::AudioManager; |
29 | 29 |
30 namespace wap = api::webrtc_audio_private; | 30 namespace wap = api::webrtc_audio_private; |
31 | 31 |
32 static base::LazyInstance< | 32 static base::LazyInstance< |
33 ProfileKeyedAPIFactory<WebrtcAudioPrivateEventService> > g_factory = | 33 BrowserContextKeyedAPIFactory<WebrtcAudioPrivateEventService> > g_factory = |
34 LAZY_INSTANCE_INITIALIZER; | 34 LAZY_INSTANCE_INITIALIZER; |
35 | 35 |
36 WebrtcAudioPrivateEventService::WebrtcAudioPrivateEventService( | 36 WebrtcAudioPrivateEventService::WebrtcAudioPrivateEventService( |
37 content::BrowserContext* context) | 37 content::BrowserContext* context) |
38 : browser_context_(context) { | 38 : browser_context_(context) { |
39 // In unit tests, the SystemMonitor may not be created. | 39 // In unit tests, the SystemMonitor may not be created. |
40 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); | 40 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); |
41 if (system_monitor) | 41 if (system_monitor) |
42 system_monitor->AddDevicesChangedObserver(this); | 42 system_monitor->AddDevicesChangedObserver(this); |
43 } | 43 } |
44 | 44 |
45 WebrtcAudioPrivateEventService::~WebrtcAudioPrivateEventService() { | 45 WebrtcAudioPrivateEventService::~WebrtcAudioPrivateEventService() { |
46 } | 46 } |
47 | 47 |
48 void WebrtcAudioPrivateEventService::Shutdown() { | 48 void WebrtcAudioPrivateEventService::Shutdown() { |
49 // In unit tests, the SystemMonitor may not be created. | 49 // In unit tests, the SystemMonitor may not be created. |
50 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); | 50 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); |
51 if (system_monitor) | 51 if (system_monitor) |
52 system_monitor->RemoveDevicesChangedObserver(this); | 52 system_monitor->RemoveDevicesChangedObserver(this); |
53 } | 53 } |
54 | 54 |
55 // static | 55 // static |
56 ProfileKeyedAPIFactory<WebrtcAudioPrivateEventService>* | 56 BrowserContextKeyedAPIFactory<WebrtcAudioPrivateEventService>* |
57 WebrtcAudioPrivateEventService::GetFactoryInstance() { | 57 WebrtcAudioPrivateEventService::GetFactoryInstance() { |
58 return g_factory.Pointer(); | 58 return g_factory.Pointer(); |
59 } | 59 } |
60 | 60 |
61 // static | 61 // static |
62 const char* WebrtcAudioPrivateEventService::service_name() { | 62 const char* WebrtcAudioPrivateEventService::service_name() { |
63 return "WebrtcAudioPrivateEventService"; | 63 return "WebrtcAudioPrivateEventService"; |
64 } | 64 } |
65 | 65 |
66 void WebrtcAudioPrivateEventService::OnDevicesChanged( | 66 void WebrtcAudioPrivateEventService::OnDevicesChanged( |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 results_.reset(wap::GetAssociatedSink::Results::Create("").release()); | 475 results_.reset(wap::GetAssociatedSink::Results::Create("").release()); |
476 } else { | 476 } else { |
477 results_.reset( | 477 results_.reset( |
478 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); | 478 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); |
479 } | 479 } |
480 | 480 |
481 SendResponse(true); | 481 SendResponse(true); |
482 } | 482 } |
483 | 483 |
484 } // namespace extensions | 484 } // namespace extensions |
OLD | NEW |