blob: 6e16b162bca16cb5cddce4580eb04d973c7892cc [file] [log] [blame]
[email protected]c3cac952014-05-09 01:51:181// 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.
4
5#ifndef CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_
6#define CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_
7
8#include "base/basictypes.h"
9#include "base/memory/scoped_ptr.h"
10#include "base/threading/thread_checker.h"
11
[email protected]037642f2014-05-29 20:40:5012class ChromeMetricsServiceClient;
[email protected]c3cac952014-05-09 01:51:1813class MetricsService;
14class PrefService;
15
16namespace metrics {
17class MetricsStateManager;
18}
19
20namespace rappor {
21class RapporService;
22}
23
24namespace chrome_variations {
25class VariationsService;
26}
27
28// MetricsServicesManager is a helper class that has ownership over the various
[email protected]037642f2014-05-29 20:40:5029// metrics-related services in Chrome: MetricsService (via its client),
30// RapporService and VariationsService.
[email protected]c3cac952014-05-09 01:51:1831class MetricsServicesManager {
32 public:
33 // Creates the MetricsServicesManager with the |local_state| prefs service.
34 explicit MetricsServicesManager(PrefService* local_state);
35 virtual ~MetricsServicesManager();
36
37 // Returns the MetricsService, creating it if it hasn't been created yet.
38 MetricsService* GetMetricsService();
39
40 // Returns the GetRapporService, creating it if it hasn't been created yet.
41 rappor::RapporService* GetRapporService();
42
43 // Returns the VariationsService, creating it if it hasn't been created yet.
44 chrome_variations::VariationsService* GetVariationsService();
45
[email protected]c3cac952014-05-09 01:51:1846 private:
47 metrics::MetricsStateManager* GetMetricsStateManager();
48
[email protected]3c70256f2014-05-22 03:02:1249 // Returns true iff metrics reporting is enabled.
50 bool IsMetricsReportingEnabled() const;
51
[email protected]c3cac952014-05-09 01:51:1852 // Ensures that all functions are called from the same thread.
53 base::ThreadChecker thread_checker_;
54
55 // Weak pointer to the local state prefs store.
56 PrefService* local_state_;
57
58 // MetricsStateManager which is passed as a parameter to service constructors.
59 scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_;
60
[email protected]037642f2014-05-29 20:40:5061 // Chrome embedder implementation of the MetricsServiceClient. Owns the
62 // MetricsService.
63 scoped_ptr<ChromeMetricsServiceClient> metrics_service_client_;
[email protected]c3cac952014-05-09 01:51:1864
65 // The RapporService, for RAPPOR metric uploads.
66 scoped_ptr<rappor::RapporService> rappor_service_;
67
68 // The VariationsService, for server-side experiments infrastructure.
69 scoped_ptr<chrome_variations::VariationsService> variations_service_;
70
71 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager);
72};
73
74#endif // CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_