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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 // BrowserProcessSubThread::IOThreadPreCleanUp). 1221 // BrowserProcessSubThread::IOThreadPreCleanUp).
1222 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 1222 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
1223 BrowserGpuMemoryBufferManager::current(), "BrowserGpuMemoryBufferManager", 1223 BrowserGpuMemoryBufferManager::current(), "BrowserGpuMemoryBufferManager",
1224 io_thread_->task_runner()); 1224 io_thread_->task_runner());
1225 #if defined(OS_ANDROID) 1225 #if defined(OS_ANDROID)
1226 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 1226 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
1227 tracing::GraphicsMemoryDumpProvider::GetInstance(), "AndroidGraphics", 1227 tracing::GraphicsMemoryDumpProvider::GetInstance(), "AndroidGraphics",
1228 nullptr); 1228 nullptr);
1229 #endif 1229 #endif
1230 1230
1231 #if !defined(OS_ANDROID)
1231 { 1232 {
1232 TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:AudioMan"); 1233 TRACE_EVENT0("startup", "BrowserThreadsStarted::InitMediaComponents");
no sievers 2016/06/20 23:50:58 nit: maybe move the trace event into the function
1233 CreateAudioManager(); 1234 InitializeMediaComponentsIfNeeded();
1234 } 1235 }
1235 1236 #endif
1236 { 1237 {
1237 TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:MidiManager"); 1238 TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:MidiManager");
1238 midi_manager_.reset(media::midi::MidiManager::Create()); 1239 midi_manager_.reset(media::midi::MidiManager::Create());
1239 } 1240 }
1240 1241
1241 #if defined(OS_WIN) 1242 #if defined(OS_WIN)
1242 system_message_window_.reset(new media::SystemMessageWindowWin); 1243 system_message_window_.reset(new media::SystemMessageWindowWin);
1243 #elif defined(OS_LINUX) && defined(USE_UDEV) 1244 #elif defined(OS_LINUX) && defined(USE_UDEV)
1244 device_monitor_linux_.reset( 1245 device_monitor_linux_.reset(
1245 new media::DeviceMonitorLinux(io_thread_->task_runner())); 1246 new media::DeviceMonitorLinux(io_thread_->task_runner()));
1246 #elif defined(OS_MACOSX) 1247 #elif defined(OS_MACOSX)
1247 device_monitor_mac_.reset(new media::DeviceMonitorMac()); 1248 device_monitor_mac_.reset(new media::DeviceMonitorMac());
1248 #endif 1249 #endif
1249 1250
1250 #if defined(OS_WIN) 1251 #if defined(OS_WIN)
1251 UMA_HISTOGRAM_BOOLEAN("Windows.Win32kRendererLockdown", 1252 UMA_HISTOGRAM_BOOLEAN("Windows.Win32kRendererLockdown",
1252 IsWin32kRendererLockdownEnabled()); 1253 IsWin32kRendererLockdownEnabled());
1253 #endif 1254 #endif
1254 // RDH needs the IO thread to be created 1255 // RDH needs the IO thread to be created
1255 { 1256 {
1256 TRACE_EVENT0("startup", 1257 TRACE_EVENT0("startup",
1257 "BrowserMainLoop::BrowserThreadsStarted:InitResourceDispatcherHost"); 1258 "BrowserMainLoop::BrowserThreadsStarted:InitResourceDispatcherHost");
1258 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); 1259 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl());
1259 } 1260 }
1260 1261
1261 // MediaStreamManager needs the IO thread to be created.
1262 {
1263 TRACE_EVENT0("startup",
1264 "BrowserMainLoop::BrowserThreadsStarted:InitMediaStreamManager");
1265 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
1266 }
1267
1268 {
1269 TRACE_EVENT0("startup",
1270 "BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition");
1271 speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
1272 audio_manager_.get(), media_stream_manager_.get()));
1273 }
1274
1275 { 1262 {
1276 TRACE_EVENT0( 1263 TRACE_EVENT0(
1277 "startup", 1264 "startup",
1278 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor"); 1265 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor");
1279 user_input_monitor_ = media::UserInputMonitor::Create( 1266 user_input_monitor_ = media::UserInputMonitor::Create(
1280 io_thread_->task_runner(), main_thread_->task_runner()); 1267 io_thread_->task_runner(), main_thread_->task_runner());
1281 } 1268 }
1282 1269
1283 { 1270 {
1284 TRACE_EVENT0("startup", 1271 TRACE_EVENT0("startup",
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 void BrowserMainLoop::EndStartupTracing() { 1446 void BrowserMainLoop::EndStartupTracing() {
1460 DCHECK(is_tracing_startup_for_duration_); 1447 DCHECK(is_tracing_startup_for_duration_);
1461 1448
1462 is_tracing_startup_for_duration_ = false; 1449 is_tracing_startup_for_duration_ = false;
1463 TracingController::GetInstance()->StopTracing( 1450 TracingController::GetInstance()->StopTracing(
1464 TracingController::CreateFileSink( 1451 TracingController::CreateFileSink(
1465 startup_trace_file_, 1452 startup_trace_file_,
1466 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); 1453 base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
1467 } 1454 }
1468 1455
1469 void BrowserMainLoop::CreateAudioManager() { 1456 void BrowserMainLoop::InitializeMediaComponentsIfNeeded() {
1457 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1458 if (audio_manager_)
1459 return;
1460
1470 DCHECK(!audio_thread_); 1461 DCHECK(!audio_thread_);
1471 DCHECK(!audio_manager_);
1472 1462
1473 bool use_hang_monitor = true; 1463 bool use_hang_monitor = true;
1474 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( 1464 audio_manager_ = GetContentClient()->browser()->CreateAudioManager(
1475 MediaInternals::GetInstance()); 1465 MediaInternals::GetInstance());
1476 if (!audio_manager_) { 1466 if (!audio_manager_) {
1477 audio_thread_.reset(new base::Thread("AudioThread")); 1467 audio_thread_.reset(new base::Thread("AudioThread"));
1478 #if defined(OS_WIN) 1468 #if defined(OS_WIN)
1479 audio_thread_->init_com_with_mta(true); 1469 audio_thread_->init_com_with_mta(true);
1480 #endif // defined(OS_WIN) 1470 #endif // defined(OS_WIN)
1481 CHECK(audio_thread_->Start()); 1471 CHECK(audio_thread_->Start());
(...skipping 12 matching lines...) Expand all
1494 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1484 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1495 audio_thread_->task_runner(); 1485 audio_thread_->task_runner();
1496 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1486 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1497 std::move(worker_task_runner), 1487 std::move(worker_task_runner),
1498 MediaInternals::GetInstance()); 1488 MediaInternals::GetInstance());
1499 } 1489 }
1500 CHECK(audio_manager_); 1490 CHECK(audio_manager_);
1501 1491
1502 if (use_hang_monitor) 1492 if (use_hang_monitor)
1503 media::AudioManager::StartHangMonitor(io_thread_->task_runner()); 1493 media::AudioManager::StartHangMonitor(io_thread_->task_runner());
1494
1495 // MediaStreamManager needs the IO thread to be created.
1496 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
1497 speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
1498 audio_manager_.get(), media_stream_manager_.get()));
1504 } 1499 }
1505 1500
1506 } // namespace content 1501 } // namespace content
OLDNEW
« 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