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

Unified Diff: chrome/browser/search/hotword_service_factory.cc

Issue 654613004: [Hotword] Delay checking for audio devices until needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: redoing logic Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search/hotword_service_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/hotword_service_factory.cc
diff --git a/chrome/browser/search/hotword_service_factory.cc b/chrome/browser/search/hotword_service_factory.cc
index d8a061965324dd2d0c639d501872c3861e660f0e..7d05057c374304a1404b4ccebe0cfe41af6aba8b 100644
--- a/chrome/browser/search/hotword_service_factory.cc
+++ b/chrome/browser/search/hotword_service_factory.cc
@@ -52,11 +52,17 @@ bool HotwordServiceFactory::IsMicrophoneAvailable() {
return GetInstance()->microphone_available();
}
+// static
+bool HotwordServiceFactory::IsAudioDeviceStateUpdated() {
+ return GetInstance()->audio_device_state_updated();
+}
+
HotwordServiceFactory::HotwordServiceFactory()
: BrowserContextKeyedServiceFactory(
"HotwordService",
BrowserContextDependencyManager::GetInstance()),
- microphone_available_(false) {
+ microphone_available_(false),
+ audio_device_state_updated_(false) {
// No dependencies.
// Register with the device observer list to update the microphone
@@ -77,19 +83,13 @@ void HotwordServiceFactory::InitializeMicrophoneObserver() {
void HotwordServiceFactory::OnUpdateAudioDevices(
const content::MediaStreamDevices& devices) {
microphone_available_ = !devices.empty();
+ audio_device_state_updated_ = true;
}
void HotwordServiceFactory::UpdateMicrophoneState() {
// In order to trigger the monitor, just call getAudioCaptureDevices.
content::MediaStreamDevices devices =
- MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
-
- // If the monitor had not previously been started, there may be 0 devices
- // even if that is not accurate. However, we can update the microphone
- // availability state now. Either the number of devices will be correct or
- // we know that the call above will start the monitor and the microphone
- // state will be updated very soon and call OnUpdateAudioDevices.
- OnUpdateAudioDevices(devices);
+ MediaCaptureDevicesDispatcher::GetInstance()->GetAudioCaptureDevices();
Anand Mistry (off Chromium) 2014/10/20 07:09:05 I think you've introduced a race here. If this fac
rpetterson 2014/10/20 17:25:07 I disagree. The factory is initialized on startup
Anand Mistry (off Chromium) 2014/10/20 21:22:54 Thanks for the explanation. This makes a lot more
}
void HotwordServiceFactory::RegisterProfilePrefs(
« no previous file with comments | « chrome/browser/search/hotword_service_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698