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

Unified Diff: content/browser/browser_main_loop.cc

Issue 2077983003: Intiialize AudioManager and related class lazily (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply the lazy initialization only to Android Created 4 years, 6 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
Index: content/browser/browser_main_loop.cc
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index b53236dd828b8a7eaeffe2e4de7ee55406f8a46b..cef8429785e40b79ee44d37e2fffcd79657e1cb4 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -1228,11 +1228,12 @@ int BrowserMainLoop::BrowserThreadsStarted() {
nullptr);
#endif
+#if !defined(OS_ANDROID)
{
- TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:AudioMan");
- CreateAudioManager();
+ TRACE_EVENT0("startup", "BrowserThreadsStarted::InitMediaComponents");
no sievers 2016/06/20 23:50:58 nit: maybe move the trace event into the function
+ InitializeMediaComponentsIfNeeded();
}
-
+#endif
{
TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:MidiManager");
midi_manager_.reset(media::midi::MidiManager::Create());
@@ -1258,20 +1259,6 @@ int BrowserMainLoop::BrowserThreadsStarted() {
resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl());
}
- // MediaStreamManager needs the IO thread to be created.
- {
- TRACE_EVENT0("startup",
- "BrowserMainLoop::BrowserThreadsStarted:InitMediaStreamManager");
- media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
- }
-
- {
- TRACE_EVENT0("startup",
- "BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition");
- speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
- audio_manager_.get(), media_stream_manager_.get()));
- }
-
{
TRACE_EVENT0(
"startup",
@@ -1466,9 +1453,12 @@ void BrowserMainLoop::EndStartupTracing() {
base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
}
-void BrowserMainLoop::CreateAudioManager() {
+void BrowserMainLoop::InitializeMediaComponentsIfNeeded() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (audio_manager_)
+ return;
+
DCHECK(!audio_thread_);
- DCHECK(!audio_manager_);
bool use_hang_monitor = true;
audio_manager_ = GetContentClient()->browser()->CreateAudioManager(
@@ -1501,6 +1491,11 @@ void BrowserMainLoop::CreateAudioManager() {
if (use_hang_monitor)
media::AudioManager::StartHangMonitor(io_thread_->task_runner());
+
+ // MediaStreamManager needs the IO thread to be created.
+ media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
+ speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
+ audio_manager_.get(), media_stream_manager_.get()));
}
} // namespace content
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/media/webrtc/webrtc_audio_debug_recordings_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698