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

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: 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 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 1231 {
1232 TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:AudioMan");
1233 CreateAudioManager();
1234 }
1235
1236 {
1237 TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:MidiManager"); 1232 TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:MidiManager");
1238 midi_manager_.reset(media::midi::MidiManager::Create()); 1233 midi_manager_.reset(media::midi::MidiManager::Create());
1239 } 1234 }
1240 1235
1241 #if defined(OS_WIN) 1236 #if defined(OS_WIN)
1242 system_message_window_.reset(new media::SystemMessageWindowWin); 1237 system_message_window_.reset(new media::SystemMessageWindowWin);
1243 #elif defined(OS_LINUX) && defined(USE_UDEV) 1238 #elif defined(OS_LINUX) && defined(USE_UDEV)
1244 device_monitor_linux_.reset( 1239 device_monitor_linux_.reset(
1245 new media::DeviceMonitorLinux(io_thread_->task_runner())); 1240 new media::DeviceMonitorLinux(io_thread_->task_runner()));
1246 #elif defined(OS_MACOSX) 1241 #elif defined(OS_MACOSX)
1247 device_monitor_mac_.reset(new media::DeviceMonitorMac()); 1242 device_monitor_mac_.reset(new media::DeviceMonitorMac());
1248 #endif 1243 #endif
1249 1244
1250 #if defined(OS_WIN) 1245 #if defined(OS_WIN)
1251 UMA_HISTOGRAM_BOOLEAN("Windows.Win32kRendererLockdown", 1246 UMA_HISTOGRAM_BOOLEAN("Windows.Win32kRendererLockdown",
1252 IsWin32kRendererLockdownEnabled()); 1247 IsWin32kRendererLockdownEnabled());
1253 #endif 1248 #endif
1254 // RDH needs the IO thread to be created 1249 // RDH needs the IO thread to be created
1255 { 1250 {
1256 TRACE_EVENT0("startup", 1251 TRACE_EVENT0("startup",
1257 "BrowserMainLoop::BrowserThreadsStarted:InitResourceDispatcherHost"); 1252 "BrowserMainLoop::BrowserThreadsStarted:InitResourceDispatcherHost");
1258 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); 1253 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl());
1259 } 1254 }
1260 1255
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 { 1256 {
1276 TRACE_EVENT0( 1257 TRACE_EVENT0(
1277 "startup", 1258 "startup",
1278 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor"); 1259 "BrowserMainLoop::BrowserThreadsStarted::InitUserInputMonitor");
1279 user_input_monitor_ = media::UserInputMonitor::Create( 1260 user_input_monitor_ = media::UserInputMonitor::Create(
1280 io_thread_->task_runner(), main_thread_->task_runner()); 1261 io_thread_->task_runner(), main_thread_->task_runner());
1281 } 1262 }
1282 1263
1283 { 1264 {
1284 TRACE_EVENT0("startup", 1265 TRACE_EVENT0("startup",
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 void BrowserMainLoop::EndStartupTracing() { 1440 void BrowserMainLoop::EndStartupTracing() {
1460 DCHECK(is_tracing_startup_for_duration_); 1441 DCHECK(is_tracing_startup_for_duration_);
1461 1442
1462 is_tracing_startup_for_duration_ = false; 1443 is_tracing_startup_for_duration_ = false;
1463 TracingController::GetInstance()->StopTracing( 1444 TracingController::GetInstance()->StopTracing(
1464 TracingController::CreateFileSink( 1445 TracingController::CreateFileSink(
1465 startup_trace_file_, 1446 startup_trace_file_,
1466 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); 1447 base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
1467 } 1448 }
1468 1449
1469 void BrowserMainLoop::CreateAudioManager() { 1450 media::AudioManager* BrowserMainLoop::GetAudioManager() {
tommi (sloooow) - chröme 2016/06/18 13:49:03 make sure this always runs on the same thread
qinmin 2016/06/20 23:45:29 Done.
1451 if (audio_manager_)
1452 return audio_manager_.get();
1453
1470 DCHECK(!audio_thread_); 1454 DCHECK(!audio_thread_);
1471 DCHECK(!audio_manager_);
1472 1455
1473 bool use_hang_monitor = true; 1456 bool use_hang_monitor = true;
1474 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( 1457 audio_manager_ = GetContentClient()->browser()->CreateAudioManager(
1475 MediaInternals::GetInstance()); 1458 MediaInternals::GetInstance());
1476 if (!audio_manager_) { 1459 if (!audio_manager_) {
1477 audio_thread_.reset(new base::Thread("AudioThread")); 1460 audio_thread_.reset(new base::Thread("AudioThread"));
1478 #if defined(OS_WIN) 1461 #if defined(OS_WIN)
1479 audio_thread_->init_com_with_mta(true); 1462 audio_thread_->init_com_with_mta(true);
1480 #endif // defined(OS_WIN) 1463 #endif // defined(OS_WIN)
1481 CHECK(audio_thread_->Start()); 1464 CHECK(audio_thread_->Start());
(...skipping 12 matching lines...) Expand all
1494 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1477 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1495 audio_thread_->task_runner(); 1478 audio_thread_->task_runner();
1496 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1479 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1497 std::move(worker_task_runner), 1480 std::move(worker_task_runner),
1498 MediaInternals::GetInstance()); 1481 MediaInternals::GetInstance());
1499 } 1482 }
1500 CHECK(audio_manager_); 1483 CHECK(audio_manager_);
1501 1484
1502 if (use_hang_monitor) 1485 if (use_hang_monitor)
1503 media::AudioManager::StartHangMonitor(io_thread_->task_runner()); 1486 media::AudioManager::StartHangMonitor(io_thread_->task_runner());
1487 return audio_manager_.get();
1488 }
1489
1490 MediaStreamManager* BrowserMainLoop::GetMediaStreamManager() {
1491 if (media_stream_manager_)
1492 return media_stream_manager_.get();
1493
1494 GetAudioManager();
1495 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
no sievers 2016/06/18 00:17:20 nit: or just write newMediaStreamManager(GetAudioM
qinmin 2016/06/20 23:45:29 no longer needed with the new patch
1496 return media_stream_manager_.get();
1497 }
1498
1499 void BrowserMainLoop::InitializeSpeechRecognitionManager() {
1500 if (speech_recognition_manager_)
1501 return;
1502
1503 GetMediaStreamManager();
1504 speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
1505 audio_manager_.get(), media_stream_manager_.get()));
no sievers 2016/06/18 00:17:20 nit: same here
qinmin 2016/06/20 23:45:29 no longer needed with the new patch
1504 } 1506 }
1505 1507
1506 } // namespace content 1508 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/media/capture/image_capture_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698