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

Side by Side Diff: chromecast/browser/cast_browser_main_parts.cc

Issue 1113053002: Set the AudioManager factory before the browser main loop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add getter for factory. Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/browser/cast_browser_main_parts.h" 5 #include "chromecast/browser/cast_browser_main_parts.h"
6 6
7 #include <string>
7 #if !defined(OS_ANDROID) 8 #if !defined(OS_ANDROID)
8 #include <signal.h> 9 #include <signal.h>
9 #include <sys/prctl.h> 10 #include <sys/prctl.h>
10 #endif 11 #endif
11 12
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "base/prefs/pref_registry_simple.h" 17 #include "base/prefs/pref_registry_simple.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "cc/base/switches.h" 19 #include "cc/base/switches.h"
19 #include "chromecast/base/cast_paths.h" 20 #include "chromecast/base/cast_paths.h"
20 #include "chromecast/base/metrics/cast_metrics_helper.h" 21 #include "chromecast/base/metrics/cast_metrics_helper.h"
21 #include "chromecast/base/metrics/grouped_histogram.h" 22 #include "chromecast/base/metrics/grouped_histogram.h"
22 #include "chromecast/browser/cast_browser_context.h" 23 #include "chromecast/browser/cast_browser_context.h"
23 #include "chromecast/browser/cast_browser_process.h" 24 #include "chromecast/browser/cast_browser_process.h"
24 #include "chromecast/browser/devtools/remote_debugging_server.h" 25 #include "chromecast/browser/devtools/remote_debugging_server.h"
25 #include "chromecast/browser/metrics/cast_metrics_prefs.h" 26 #include "chromecast/browser/metrics/cast_metrics_prefs.h"
26 #include "chromecast/browser/metrics/cast_metrics_service_client.h" 27 #include "chromecast/browser/metrics/cast_metrics_service_client.h"
27 #include "chromecast/browser/pref_service_helper.h" 28 #include "chromecast/browser/pref_service_helper.h"
28 #include "chromecast/browser/service/cast_service.h" 29 #include "chromecast/browser/service/cast_service.h"
29 #include "chromecast/browser/url_request_context_factory.h" 30 #include "chromecast/browser/url_request_context_factory.h"
30 #include "chromecast/common/chromecast_switches.h" 31 #include "chromecast/common/chromecast_switches.h"
31 #include "chromecast/common/platform_client_auth.h" 32 #include "chromecast/common/platform_client_auth.h"
32 #include "chromecast/media/base/key_systems_common.h" 33 #include "chromecast/media/base/key_systems_common.h"
33 #include "chromecast/net/connectivity_checker.h" 34 #include "chromecast/net/connectivity_checker.h"
34 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
35 #include "content/public/common/content_switches.h" 36 #include "content/public/common/content_switches.h"
37 #include "media/audio/audio_manager.h"
36 #include "media/base/browser_cdm_factory.h" 38 #include "media/base/browser_cdm_factory.h"
37 #include "media/base/media_switches.h" 39 #include "media/base/media_switches.h"
38 40
39 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
40 #include "chromecast/browser/media/cast_media_client_android.h" 42 #include "chromecast/browser/media/cast_media_client_android.h"
41 #include "chromecast/crash/android/crash_handler.h" 43 #include "chromecast/crash/android/crash_handler.h"
42 #include "components/crash/browser/crash_dump_manager_android.h" 44 #include "components/crash/browser/crash_dump_manager_android.h"
43 #include "media/base/android/media_client_android.h" 45 #include "media/base/android/media_client_android.h"
44 #include "net/android/network_change_notifier_factory_android.h" 46 #include "net/android/network_change_notifier_factory_android.h"
45 #else 47 #else
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 std::string(g_default_switches[i].switch_name), 187 std::string(g_default_switches[i].switch_name),
186 std::string(g_default_switches[i].switch_value)); 188 std::string(g_default_switches[i].switch_value));
187 ++i; 189 ++i;
188 } 190 }
189 } 191 }
190 192
191 } // namespace 193 } // namespace
192 194
193 CastBrowserMainParts::CastBrowserMainParts( 195 CastBrowserMainParts::CastBrowserMainParts(
194 const content::MainFunctionParams& parameters, 196 const content::MainFunctionParams& parameters,
195 URLRequestContextFactory* url_request_context_factory) 197 URLRequestContextFactory* url_request_context_factory,
198 scoped_ptr<::media::AudioManagerFactory> audio_manager_factory)
196 : BrowserMainParts(), 199 : BrowserMainParts(),
197 cast_browser_process_(new CastBrowserProcess()), 200 cast_browser_process_(new CastBrowserProcess()),
198 parameters_(parameters), 201 parameters_(parameters),
199 url_request_context_factory_(url_request_context_factory) { 202 url_request_context_factory_(url_request_context_factory),
203 audio_manager_factory_(audio_manager_factory.Pass()) {
200 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 204 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
201 AddDefaultCommandLineSwitches(command_line); 205 AddDefaultCommandLineSwitches(command_line);
202 } 206 }
203 207
204 CastBrowserMainParts::~CastBrowserMainParts() { 208 CastBrowserMainParts::~CastBrowserMainParts() {
205 } 209 }
206 210
207 void CastBrowserMainParts::PreMainMessageLoopStart() { 211 void CastBrowserMainParts::PreMainMessageLoopStart() {
208 // GroupedHistograms needs to be initialized before any threads are created 212 // GroupedHistograms needs to be initialized before any threads are created
209 // to prevent race conditions between calls to Preregister and those threads 213 // to prevent race conditions between calls to Preregister and those threads
210 // attempting to collect metrics. 214 // attempting to collect metrics.
211 // This call must also be before NetworkChangeNotifier, as it generates 215 // This call must also be before NetworkChangeNotifier, as it generates
212 // Net/DNS metrics. 216 // Net/DNS metrics.
213 metrics::PreregisterAllGroupedHistograms(); 217 metrics::PreregisterAllGroupedHistograms();
214 218
219 // Set the platform's implementation of AudioManagerFactory.
220 if (audio_manager_factory_)
221 ::media::AudioManager::SetFactory(audio_manager_factory_.release());
222
215 #if defined(OS_ANDROID) 223 #if defined(OS_ANDROID)
216 net::NetworkChangeNotifier::SetFactory( 224 net::NetworkChangeNotifier::SetFactory(
217 new net::NetworkChangeNotifierFactoryAndroid()); 225 new net::NetworkChangeNotifierFactoryAndroid());
218 #endif // defined(OS_ANDROID) 226 #endif // defined(OS_ANDROID)
219 } 227 }
220 228
221 void CastBrowserMainParts::PostMainMessageLoopStart() { 229 void CastBrowserMainParts::PostMainMessageLoopStart() {
222 cast_browser_process_->SetMetricsHelper(make_scoped_ptr( 230 cast_browser_process_->SetMetricsHelper(make_scoped_ptr(
223 new metrics::CastMetricsHelper(base::MessageLoopProxy::current()))); 231 new metrics::CastMetricsHelper(base::MessageLoopProxy::current())));
224 232
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 #else 353 #else
346 cast_browser_process_->cast_service()->Finalize(); 354 cast_browser_process_->cast_service()->Finalize();
347 cast_browser_process_->metrics_service_client()->Finalize(); 355 cast_browser_process_->metrics_service_client()->Finalize();
348 cast_browser_process_.reset(); 356 cast_browser_process_.reset();
349 DeregisterKillOnAlarm(); 357 DeregisterKillOnAlarm();
350 #endif 358 #endif
351 } 359 }
352 360
353 } // namespace shell 361 } // namespace shell
354 } // namespace chromecast 362 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698