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

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: Cleanup + naming 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"
38 #include "media/audio/audio_manager_factory.h"
36 #include "media/base/browser_cdm_factory.h" 39 #include "media/base/browser_cdm_factory.h"
37 #include "media/base/media_switches.h" 40 #include "media/base/media_switches.h"
38 41
39 #if defined(OS_ANDROID) 42 #if defined(OS_ANDROID)
40 #include "chromecast/browser/media/cast_media_client_android.h" 43 #include "chromecast/browser/media/cast_media_client_android.h"
41 #include "chromecast/crash/android/crash_handler.h" 44 #include "chromecast/crash/android/crash_handler.h"
42 #include "components/crash/browser/crash_dump_manager_android.h" 45 #include "components/crash/browser/crash_dump_manager_android.h"
43 #include "media/base/android/media_client_android.h" 46 #include "media/base/android/media_client_android.h"
44 #include "net/android/network_change_notifier_factory_android.h" 47 #include "net/android/network_change_notifier_factory_android.h"
45 #else 48 #else
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 std::string(g_default_switches[i].switch_name), 188 std::string(g_default_switches[i].switch_name),
186 std::string(g_default_switches[i].switch_value)); 189 std::string(g_default_switches[i].switch_value));
187 ++i; 190 ++i;
188 } 191 }
189 } 192 }
190 193
191 } // namespace 194 } // namespace
192 195
193 CastBrowserMainParts::CastBrowserMainParts( 196 CastBrowserMainParts::CastBrowserMainParts(
194 const content::MainFunctionParams& parameters, 197 const content::MainFunctionParams& parameters,
195 URLRequestContextFactory* url_request_context_factory) 198 URLRequestContextFactory* url_request_context_factory,
199 scoped_ptr<::media::AudioManagerFactory> audio_manager_factory)
196 : BrowserMainParts(), 200 : BrowserMainParts(),
197 cast_browser_process_(new CastBrowserProcess()), 201 cast_browser_process_(new CastBrowserProcess()),
198 parameters_(parameters), 202 parameters_(parameters),
199 url_request_context_factory_(url_request_context_factory) { 203 url_request_context_factory_(url_request_context_factory),
204 audio_manager_factory_(audio_manager_factory.Pass()) {
200 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 205 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
201 AddDefaultCommandLineSwitches(command_line); 206 AddDefaultCommandLineSwitches(command_line);
202 } 207 }
203 208
204 CastBrowserMainParts::~CastBrowserMainParts() { 209 CastBrowserMainParts::~CastBrowserMainParts() {
205 } 210 }
206 211
207 void CastBrowserMainParts::PreMainMessageLoopStart() { 212 void CastBrowserMainParts::PreMainMessageLoopStart() {
208 // GroupedHistograms needs to be initialized before any threads are created 213 // GroupedHistograms needs to be initialized before any threads are created
209 // to prevent race conditions between calls to Preregister and those threads 214 // to prevent race conditions between calls to Preregister and those threads
210 // attempting to collect metrics. 215 // attempting to collect metrics.
211 // This call must also be before NetworkChangeNotifier, as it generates 216 // This call must also be before NetworkChangeNotifier, as it generates
212 // Net/DNS metrics. 217 // Net/DNS metrics.
213 metrics::PreregisterAllGroupedHistograms(); 218 metrics::PreregisterAllGroupedHistograms();
214 219
220 // Set the platform's implementation of AudioManagerFactory.
221 if (audio_manager_factory_)
222 ::media::AudioManager::SetFactory(audio_manager_factory_.release());
223
215 #if defined(OS_ANDROID) 224 #if defined(OS_ANDROID)
216 net::NetworkChangeNotifier::SetFactory( 225 net::NetworkChangeNotifier::SetFactory(
217 new net::NetworkChangeNotifierFactoryAndroid()); 226 new net::NetworkChangeNotifierFactoryAndroid());
218 #endif // defined(OS_ANDROID) 227 #endif // defined(OS_ANDROID)
219 } 228 }
220 229
221 void CastBrowserMainParts::PostMainMessageLoopStart() { 230 void CastBrowserMainParts::PostMainMessageLoopStart() {
222 cast_browser_process_->SetMetricsHelper(make_scoped_ptr( 231 cast_browser_process_->SetMetricsHelper(make_scoped_ptr(
223 new metrics::CastMetricsHelper(base::MessageLoopProxy::current()))); 232 new metrics::CastMetricsHelper(base::MessageLoopProxy::current())));
224 233
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 #else 354 #else
346 cast_browser_process_->cast_service()->Finalize(); 355 cast_browser_process_->cast_service()->Finalize();
347 cast_browser_process_->metrics_service_client()->Finalize(); 356 cast_browser_process_->metrics_service_client()->Finalize();
348 cast_browser_process_.reset(); 357 cast_browser_process_.reset();
349 DeregisterKillOnAlarm(); 358 DeregisterKillOnAlarm();
350 #endif 359 #endif
351 } 360 }
352 361
353 } // namespace shell 362 } // namespace shell
354 } // namespace chromecast 363 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_browser_main_parts.h ('k') | chromecast/browser/cast_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698