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

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: defer StartHangMonitor() on all platforms 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 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 TracingController::GetInstance()->StopTracing( 1463 TracingController::GetInstance()->StopTracing(
1464 TracingController::CreateFileSink( 1464 TracingController::CreateFileSink(
1465 startup_trace_file_, 1465 startup_trace_file_,
1466 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); 1466 base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
1467 } 1467 }
1468 1468
1469 void BrowserMainLoop::CreateAudioManager() { 1469 void BrowserMainLoop::CreateAudioManager() {
1470 DCHECK(!audio_thread_); 1470 DCHECK(!audio_thread_);
1471 DCHECK(!audio_manager_); 1471 DCHECK(!audio_manager_);
1472 1472
1473 bool use_hang_monitor = true;
1474 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( 1473 audio_manager_ = GetContentClient()->browser()->CreateAudioManager(
1475 MediaInternals::GetInstance()); 1474 MediaInternals::GetInstance());
1476 if (!audio_manager_) { 1475 if (!audio_manager_) {
1477 audio_thread_.reset(new base::Thread("AudioThread")); 1476 audio_thread_.reset(new base::Thread("AudioThread"));
1478 #if defined(OS_WIN) 1477 #if defined(OS_WIN)
1479 audio_thread_->init_com_with_mta(true); 1478 audio_thread_->init_com_with_mta(true);
1480 #endif // defined(OS_WIN) 1479 #endif // defined(OS_WIN)
1481 CHECK(audio_thread_->Start()); 1480 CHECK(audio_thread_->Start());
1482 #if defined(OS_MACOSX) 1481 #if defined(OS_MACOSX)
1483 // On Mac audio task runner must belong to the main thread. 1482 // On Mac audio task runner must belong to the main thread.
1484 // See http://crbug.com/158170. 1483 // See http://crbug.com/158170.
1485 // Since the audio thread is the UI thread, a hang monitor is not
1486 // necessary or recommended.
1487 use_hang_monitor = false;
1488 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner = 1484 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner =
1489 base::ThreadTaskRunnerHandle::Get(); 1485 base::ThreadTaskRunnerHandle::Get();
1490 #else 1486 #else
1491 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner = 1487 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner =
1492 audio_thread_->task_runner(); 1488 audio_thread_->task_runner();
1493 #endif // defined(OS_MACOSX) 1489 #endif // defined(OS_MACOSX)
1494 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1490 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1495 audio_thread_->task_runner(); 1491 audio_thread_->task_runner();
1496 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1492 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1497 std::move(worker_task_runner), 1493 std::move(worker_task_runner),
1498 MediaInternals::GetInstance()); 1494 MediaInternals::GetInstance());
1499 } 1495 }
1500 CHECK(audio_manager_); 1496 CHECK(audio_manager_);
1501
1502 if (use_hang_monitor)
1503 media::AudioManager::StartHangMonitor(io_thread_->task_runner());
1504 } 1497 }
1505 1498
1506 } // namespace content 1499 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698