summaryrefslogtreecommitdiffstats
path: root/chromecast/browser/cast_browser_process.h
blob: f4bec89e7a167caf155a91418e61ec8f149d50af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMECAST_BROWSER_CAST_BROWSER_PROCESS_H_
#define CHROMECAST_BROWSER_CAST_BROWSER_PROCESS_H_

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"

class PrefService;

namespace breakpad {
class CrashDumpManager;
}  // namespace breakpad

namespace chromecast {
class CastService;
class ConnectivityChecker;

namespace metrics {
class CastMetricsHelper;
class CastMetricsServiceClient;
}  // namespace metrics

namespace shell {
class CastBrowserContext;
class CastResourceDispatcherHostDelegate;
class RemoteDebuggingServer;

class CastBrowserProcess {
 public:
  // Gets the global instance of CastBrowserProcess. Does not create lazily and
  // assumes the instance already exists.
  static CastBrowserProcess* GetInstance();

  CastBrowserProcess();
  virtual ~CastBrowserProcess();

  void SetBrowserContext(scoped_ptr<CastBrowserContext> browser_context);
  void SetCastService(scoped_ptr<CastService> cast_service);
  void SetMetricsHelper(scoped_ptr<metrics::CastMetricsHelper> metrics_helper);
  void SetMetricsServiceClient(
      scoped_ptr<metrics::CastMetricsServiceClient> metrics_service_client);
  void SetPrefService(scoped_ptr<PrefService> pref_service);
  void SetRemoteDebuggingServer(
      scoped_ptr<RemoteDebuggingServer> remote_debugging_server);
  void SetResourceDispatcherHostDelegate(
      scoped_ptr<CastResourceDispatcherHostDelegate> delegate);
#if defined(OS_ANDROID)
  void SetCrashDumpManager(
      scoped_ptr<breakpad::CrashDumpManager> crash_dump_manager);
#endif  // defined(OS_ANDROID)
  void SetConnectivityChecker(
      scoped_refptr<ConnectivityChecker> connectivity_checker);

  CastBrowserContext* browser_context() const { return browser_context_.get(); }
  CastService* cast_service() const { return cast_service_.get(); }
  metrics::CastMetricsServiceClient* metrics_service_client() const {
    return metrics_service_client_.get();
  }
  PrefService* pref_service() const { return pref_service_.get(); }
  CastResourceDispatcherHostDelegate* resource_dispatcher_host_delegate()
      const {
    return resource_dispatcher_host_delegate_.get();
  }
  ConnectivityChecker* connectivity_checker() const {
    return connectivity_checker_.get();
  }

 private:
  // Note: The following order should match the order they are set in
  // CastBrowserMainParts.
  scoped_ptr<metrics::CastMetricsHelper> metrics_helper_;
  scoped_ptr<PrefService> pref_service_;
  scoped_refptr<ConnectivityChecker> connectivity_checker_;
  scoped_ptr<CastBrowserContext> browser_context_;
  scoped_ptr<metrics::CastMetricsServiceClient> metrics_service_client_;
  scoped_ptr<CastResourceDispatcherHostDelegate>
      resource_dispatcher_host_delegate_;
#if defined(OS_ANDROID)
  scoped_ptr<breakpad::CrashDumpManager> crash_dump_manager_;
#endif  // defined(OS_ANDROID)
  scoped_ptr<RemoteDebuggingServer> remote_debugging_server_;

  // Note: CastService must be destroyed before others.
  scoped_ptr<CastService> cast_service_;

  DISALLOW_COPY_AND_ASSIGN(CastBrowserProcess);
};

}  // namespace shell
}  // namespace chromecast

#endif  // CHROMECAST_BROWSER_CAST_BROWSER_PROCESS_H_