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 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_
6 #define CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h"
12 class ChromeMetricsServiceClient
;
17 class MetricsStateManager
;
24 namespace chrome_variations
{
25 class VariationsService
;
28 // MetricsServicesManager is a helper class that has ownership over the various
29 // metrics-related services in Chrome: MetricsService (via its client),
30 // RapporService and VariationsService.
31 class MetricsServicesManager
{
33 // Creates the MetricsServicesManager with the |local_state| prefs service.
34 explicit MetricsServicesManager(PrefService
* local_state
);
35 virtual ~MetricsServicesManager();
37 // Returns the MetricsService, creating it if it hasn't been created yet.
38 MetricsService
* GetMetricsService();
40 // Returns the GetRapporService, creating it if it hasn't been created yet.
41 rappor::RapporService
* GetRapporService();
43 // Returns the VariationsService, creating it if it hasn't been created yet.
44 chrome_variations::VariationsService
* GetVariationsService();
47 metrics::MetricsStateManager
* GetMetricsStateManager();
49 // Returns true iff metrics reporting is enabled.
50 bool IsMetricsReportingEnabled() const;
52 // Ensures that all functions are called from the same thread.
53 base::ThreadChecker thread_checker_
;
55 // Weak pointer to the local state prefs store.
56 PrefService
* local_state_
;
58 // MetricsStateManager which is passed as a parameter to service constructors.
59 scoped_ptr
<metrics::MetricsStateManager
> metrics_state_manager_
;
61 // Chrome embedder implementation of the MetricsServiceClient. Owns the
63 scoped_ptr
<ChromeMetricsServiceClient
> metrics_service_client_
;
65 // The RapporService, for RAPPOR metric uploads.
66 scoped_ptr
<rappor::RapporService
> rappor_service_
;
68 // The VariationsService, for server-side experiments infrastructure.
69 scoped_ptr
<chrome_variations::VariationsService
> variations_service_
;
71 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager
);
74 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_