Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / chromecast / browser / cast_browser_process.cc
blobccd04ae94847286f6b7f355d6e368ad9d5ca6cc9
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/browser/service/cast_service.h"
15 #include "chromecast/net/connectivity_checker.h"
17 #if defined(OS_ANDROID)
18 #include "components/crash/browser/crash_dump_manager_android.h"
19 #endif // defined(OS_ANDROID)
21 #if defined(USE_AURA)
22 #include "ui/aura/env.h"
23 #endif
25 namespace chromecast {
26 namespace shell {
28 namespace {
29 CastBrowserProcess* g_instance = NULL;
30 } // namespace
32 // static
33 CastBrowserProcess* CastBrowserProcess::GetInstance() {
34 DCHECK(g_instance);
35 return g_instance;
38 CastBrowserProcess::CastBrowserProcess() {
39 DCHECK(!g_instance);
40 g_instance = this;
43 CastBrowserProcess::~CastBrowserProcess() {
44 DCHECK_EQ(g_instance, this);
45 if (pref_service_)
46 pref_service_->CommitPendingWrite();
47 #if defined(USE_AURA)
48 aura::Env::DeleteInstance();
49 #endif
50 g_instance = NULL;
53 void CastBrowserProcess::SetBrowserContext(
54 scoped_ptr<CastBrowserContext> browser_context) {
55 DCHECK(!browser_context_);
56 browser_context_.swap(browser_context);
59 void CastBrowserProcess::SetCastService(scoped_ptr<CastService> cast_service) {
60 DCHECK(!cast_service_);
61 cast_service_.swap(cast_service);
64 void CastBrowserProcess::SetMetricsHelper(
65 scoped_ptr<metrics::CastMetricsHelper> metrics_helper) {
66 DCHECK(!metrics_helper_);
67 metrics_helper_.swap(metrics_helper);
70 void CastBrowserProcess::SetMetricsServiceClient(
71 scoped_ptr<metrics::CastMetricsServiceClient> metrics_service_client) {
72 DCHECK(!metrics_service_client_);
73 metrics_service_client_.swap(metrics_service_client);
76 void CastBrowserProcess::SetPrefService(scoped_ptr<PrefService> pref_service) {
77 DCHECK(!pref_service_);
78 pref_service_.swap(pref_service);
81 void CastBrowserProcess::SetRemoteDebuggingServer(
82 scoped_ptr<RemoteDebuggingServer> remote_debugging_server) {
83 DCHECK(!remote_debugging_server_);
84 remote_debugging_server_.swap(remote_debugging_server);
87 void CastBrowserProcess::SetResourceDispatcherHostDelegate(
88 scoped_ptr<CastResourceDispatcherHostDelegate> delegate) {
89 DCHECK(!resource_dispatcher_host_delegate_);
90 resource_dispatcher_host_delegate_.swap(delegate);
93 #if defined(OS_ANDROID)
94 void CastBrowserProcess::SetCrashDumpManager(
95 scoped_ptr<breakpad::CrashDumpManager> crash_dump_manager) {
96 DCHECK(!crash_dump_manager_);
97 crash_dump_manager_.swap(crash_dump_manager);
99 #endif // defined(OS_ANDROID)
101 void CastBrowserProcess::SetConnectivityChecker(
102 scoped_refptr<ConnectivityChecker> connectivity_checker) {
103 DCHECK(!connectivity_checker_);
104 connectivity_checker_.swap(connectivity_checker);
107 } // namespace shell
108 } // namespace chromecast