blob: 1d7717722a8a5488b91024b5d229762302ffcfdf [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
[email protected]544246e2014-06-06 11:22:2816namespace base {
17class FilePath;
18}
19
[email protected]c3cac952014-05-09 01:51:1820namespace metrics {
21class MetricsStateManager;
22}
23
24namespace rappor {
25class RapporService;
26}
27
28namespace chrome_variations {
29class VariationsService;
30}
31
32// MetricsServicesManager is a helper class that has ownership over the various
[email protected]037642f2014-05-29 20:40:5033// metrics-related services in Chrome: MetricsService (via its client),
34// RapporService and VariationsService.
[email protected]c3cac952014-05-09 01:51:1835class MetricsServicesManager {
36 public:
37 // Creates the MetricsServicesManager with the |local_state| prefs service.
38 explicit MetricsServicesManager(PrefService* local_state);
39 virtual ~MetricsServicesManager();
40
41 // Returns the MetricsService, creating it if it hasn't been created yet.
42 MetricsService* GetMetricsService();
43
44 // Returns the GetRapporService, creating it if it hasn't been created yet.
45 rappor::RapporService* GetRapporService();
46
47 // Returns the VariationsService, creating it if it hasn't been created yet.
48 chrome_variations::VariationsService* GetVariationsService();
49
[email protected]544246e2014-06-06 11:22:2850 // Should be called when a plugin loading error occurs.
51 void OnPluginLoadingError(const base::FilePath& plugin_path);
52
[email protected]c3cac952014-05-09 01:51:1853 private:
54 metrics::MetricsStateManager* GetMetricsStateManager();
55
[email protected]3c70256f2014-05-22 03:02:1256 // Returns true iff metrics reporting is enabled.
57 bool IsMetricsReportingEnabled() const;
58
[email protected]c3cac952014-05-09 01:51:1859 // Ensures that all functions are called from the same thread.
60 base::ThreadChecker thread_checker_;
61
62 // Weak pointer to the local state prefs store.
63 PrefService* local_state_;
64
65 // MetricsStateManager which is passed as a parameter to service constructors.
66 scoped_ptr<metrics::MetricsStateManager> metrics_state_manager_;
67
[email protected]037642f2014-05-29 20:40:5068 // Chrome embedder implementation of the MetricsServiceClient. Owns the
69 // MetricsService.
70 scoped_ptr<ChromeMetricsServiceClient> metrics_service_client_;
[email protected]c3cac952014-05-09 01:51:1871
72 // The RapporService, for RAPPOR metric uploads.
73 scoped_ptr<rappor::RapporService> rappor_service_;
74
75 // The VariationsService, for server-side experiments infrastructure.
76 scoped_ptr<chrome_variations::VariationsService> variations_service_;
77
78 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager);
79};
80
81#endif // CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_