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

Side by Side Diff: chrome/browser/search/hotword_service_factory.h

Issue 654613004: [Hotword] Delay checking for audio devices until needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_FACTORY_H_ 5 #ifndef CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_FACTORY_H_ 6 #define CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_FACTORY_H_
7 7
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 9 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
10 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" 10 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
(...skipping 17 matching lines...) Expand all
28 static bool IsHotwordAllowed(content::BrowserContext* context); 28 static bool IsHotwordAllowed(content::BrowserContext* context);
29 29
30 // Returns the current error message for the service for |context|. 30 // Returns the current error message for the service for |context|.
31 // A value of 0 indicates no error. 31 // A value of 0 indicates no error.
32 static int GetCurrentError(content::BrowserContext* context); 32 static int GetCurrentError(content::BrowserContext* context);
33 33
34 // Returns the current known state of the microphone. Since this state 34 // Returns the current known state of the microphone. Since this state
35 // is browser (not profile) specific, it resides in the factory. 35 // is browser (not profile) specific, it resides in the factory.
36 static bool IsMicrophoneAvailable(); 36 static bool IsMicrophoneAvailable();
37 37
38 // Returns whether the state of the audio devices has been updated.
39 // Essentially it indicates the validity of the return value from
40 // IsMicrophoneAvailable().
41 static bool IsAudioDeviceStateUpdated();
42
38 // Overridden from MediaCaptureDevicesDispatcher::Observer 43 // Overridden from MediaCaptureDevicesDispatcher::Observer
39 void OnUpdateAudioDevices( 44 void OnUpdateAudioDevices(
40 const content::MediaStreamDevices& devices) override; 45 const content::MediaStreamDevices& devices) override;
41 46
42 // This will kick off the monitor that calls OnUpdateAudioDevices when the 47 // This will kick off the monitor that calls OnUpdateAudioDevices when the
43 // number of audio devices changes (or is initialized). It needs to be a 48 // number of audio devices changes (or is initialized). It needs to be a
44 // separate function so it can be called after the service is initialized 49 // separate function so it can be called after the service is initialized
45 // (i.e., after startup). The monitor can't be initialized during startup 50 // (i.e., after startup). The monitor can't be initialized during startup
46 // because it would slow down startup too much so it is delayed and not 51 // because it would slow down startup too much so it is delayed and not
47 // called until it's needed by the webui in browser_options_handler. 52 // called until it's needed by the webui in browser_options_handler.
(...skipping 12 matching lines...) Expand all
60 content::BrowserContext* context) const override; 65 content::BrowserContext* context) const override;
61 66
62 // Must be called from the UI thread since the instance of 67 // Must be called from the UI thread since the instance of
63 // MediaCaptureDevicesDispatcher can only be accessed on the UI thread. 68 // MediaCaptureDevicesDispatcher can only be accessed on the UI thread.
64 void InitializeMicrophoneObserver(); 69 void InitializeMicrophoneObserver();
65 70
66 bool microphone_available() { return microphone_available_; } 71 bool microphone_available() { return microphone_available_; }
67 72
68 bool microphone_available_; 73 bool microphone_available_;
69 74
75 // Indicates if the check for audio devices has been run such that it can be
76 // included in the error checking. Audio checking is not done immediately
77 // upon start up because of the negative impact on performance.
78 bool audio_device_state_updated_;
79
80 bool audio_device_state_updated() { return audio_device_state_updated_; }
81
70 DISALLOW_COPY_AND_ASSIGN(HotwordServiceFactory); 82 DISALLOW_COPY_AND_ASSIGN(HotwordServiceFactory);
71 }; 83 };
72 84
73 #endif // CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_FACTORY_H_ 85 #endif // CHROME_BROWSER_SEARCH_HOTWORD_SERVICE_FACTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/search/hotword_service.cc ('k') | chrome/browser/search/hotword_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698