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
3 // found in the LICENSE file.
5 #include "chromecast/browser/cast_browser_process.h"
7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h"
9 #include "chromecast/base/metrics/cast_metrics_helper.h"
10 #include "chromecast/browser/cast_browser_context.h"
11 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h"
12 #include "chromecast/browser/devtools/remote_debugging_server.h"
13 #include "chromecast/browser/metrics/cast_metrics_service_client.h"
14 #include "chromecast/net/connectivity_checker.h"
15 #include "chromecast/service/cast_service.h"
17 #if defined(OS_ANDROID)
18 #include "components/crash/content/browser/crash_dump_manager_android.h"
19 #endif // defined(OS_ANDROID)
22 #include "chromecast/graphics/cast_screen.h"
23 #endif // defined(USE_AURA)
25 namespace chromecast
{
29 CastBrowserProcess
* g_instance
= NULL
;
33 CastBrowserProcess
* CastBrowserProcess::GetInstance() {
38 CastBrowserProcess::CastBrowserProcess()
39 : cast_content_browser_client_(nullptr),
45 CastBrowserProcess::~CastBrowserProcess() {
46 DCHECK_EQ(g_instance
, this);
48 pref_service_
->CommitPendingWrite();
52 void CastBrowserProcess::SetBrowserContext(
53 scoped_ptr
<CastBrowserContext
> browser_context
) {
54 DCHECK(!browser_context_
);
55 browser_context_
.swap(browser_context
);
58 void CastBrowserProcess::SetCastContentBrowserClient(
59 CastContentBrowserClient
* cast_content_browser_client
) {
60 DCHECK(!cast_content_browser_client_
);
61 cast_content_browser_client_
= cast_content_browser_client
;
64 void CastBrowserProcess::SetCastService(scoped_ptr
<CastService
> cast_service
) {
65 DCHECK(!cast_service_
);
66 cast_service_
.swap(cast_service
);
70 void CastBrowserProcess::SetCastScreen(scoped_ptr
<CastScreen
> cast_screen
) {
71 DCHECK(!cast_screen_
);
72 cast_screen_
= cast_screen
.Pass();
74 #endif // defined(USE_AURA)
76 void CastBrowserProcess::SetMetricsHelper(
77 scoped_ptr
<metrics::CastMetricsHelper
> metrics_helper
) {
78 DCHECK(!metrics_helper_
);
79 metrics_helper_
.swap(metrics_helper
);
82 void CastBrowserProcess::SetMetricsServiceClient(
83 scoped_ptr
<metrics::CastMetricsServiceClient
> metrics_service_client
) {
84 DCHECK(!metrics_service_client_
);
85 metrics_service_client_
.swap(metrics_service_client
);
88 void CastBrowserProcess::SetPrefService(scoped_ptr
<PrefService
> pref_service
) {
89 DCHECK(!pref_service_
);
90 pref_service_
.swap(pref_service
);
93 void CastBrowserProcess::SetRemoteDebuggingServer(
94 scoped_ptr
<RemoteDebuggingServer
> remote_debugging_server
) {
95 DCHECK(!remote_debugging_server_
);
96 remote_debugging_server_
.swap(remote_debugging_server
);
99 void CastBrowserProcess::SetResourceDispatcherHostDelegate(
100 scoped_ptr
<CastResourceDispatcherHostDelegate
> delegate
) {
101 DCHECK(!resource_dispatcher_host_delegate_
);
102 resource_dispatcher_host_delegate_
.swap(delegate
);
105 #if defined(OS_ANDROID)
106 void CastBrowserProcess::SetCrashDumpManager(
107 scoped_ptr
<breakpad::CrashDumpManager
> crash_dump_manager
) {
108 DCHECK(!crash_dump_manager_
);
109 crash_dump_manager_
.swap(crash_dump_manager
);
111 #endif // defined(OS_ANDROID)
113 void CastBrowserProcess::SetConnectivityChecker(
114 scoped_refptr
<ConnectivityChecker
> connectivity_checker
) {
115 DCHECK(!connectivity_checker_
);
116 connectivity_checker_
.swap(connectivity_checker
);
119 void CastBrowserProcess::SetNetLog(net::NetLog
* net_log
) {
125 } // namespace chromecast