blob: 8634005dc84b60044902af71437998cab8f72f9b [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
blundell695d61f2015-10-21 11:25:535#ifndef COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_
6#define COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_
[email protected]c3cac952014-05-09 01:51:187
8#include "base/basictypes.h"
9#include "base/memory/scoped_ptr.h"
10#include "base/threading/thread_checker.h"
[email protected]c3cac952014-05-09 01:51:1811
[email protected]544246e2014-06-06 11:22:2812namespace base {
13class FilePath;
14}
15
[email protected]c3cac952014-05-09 01:51:1816namespace metrics {
asvitkinecbd420732014-08-26 22:15:4017class MetricsService;
blundellfecea528d2015-10-21 10:10:2218class MetricsServiceClient;
[email protected]c3cac952014-05-09 01:51:1819class MetricsStateManager;
20}
21
22namespace rappor {
23class RapporService;
24}
25
blundell57bcfed2015-09-04 08:44:4526namespace variations {
[email protected]c3cac952014-05-09 01:51:1827class VariationsService;
28}
29
blundell695d61f2015-10-21 11:25:5330namespace metrics_services_manager {
31
32class MetricsServicesManagerClient;
33
blundellfecea528d2015-10-21 10:10:2234// MetricsServicesManager is a helper class for embedders that use the various
35// metrics-related services in a Chrome-like fashion: MetricsService (via its
36// client), RapporService and VariationsService.
[email protected]c3cac952014-05-09 01:51:1837class MetricsServicesManager {
38 public:
blundellfecea528d2015-10-21 10:10:2239 // Creates the MetricsServicesManager with the given client.
40 explicit MetricsServicesManager(
41 scoped_ptr<MetricsServicesManagerClient> client);
[email protected]c3cac952014-05-09 01:51:1842 virtual ~MetricsServicesManager();
43
[email protected]4a55a712014-06-08 16:50:3444 // Returns the MetricsService, creating it if it hasn't been created yet (and
blundellfecea528d2015-10-21 10:10:2245 // additionally creating the MetricsServiceClient in that case).
asvitkinecbd420732014-08-26 22:15:4046 metrics::MetricsService* GetMetricsService();
[email protected]c3cac952014-05-09 01:51:1847
blundellfecea528d2015-10-21 10:10:2248 // Returns the RapporService, creating it if it hasn't been created yet.
[email protected]c3cac952014-05-09 01:51:1849 rappor::RapporService* GetRapporService();
50
51 // Returns the VariationsService, creating it if it hasn't been created yet.
blundell57bcfed2015-09-04 08:44:4552 variations::VariationsService* GetVariationsService();
[email protected]c3cac952014-05-09 01:51:1853
[email protected]544246e2014-06-06 11:22:2854 // Should be called when a plugin loading error occurs.
55 void OnPluginLoadingError(const base::FilePath& plugin_path);
56
holte5a7ed7c2015-01-09 23:52:4657 // Update the managed services when permissions for recording/uploading
58 // metrics change.
59 void UpdatePermissions(bool may_record, bool may_upload);
60
anthonyvd40dd0302015-02-19 16:11:3461 // Update the managed services when permissions for uploading metrics change.
62 void UpdateUploadPermissions(bool may_upload);
holte5a7ed7c2015-01-09 23:52:4663
[email protected]c3cac952014-05-09 01:51:1864 private:
holte873fb7c92015-02-19 23:41:2665 // Update the managed services when permissions for recording/uploading
66 // metrics change.
67 void UpdateRapporService();
68
blundellfecea528d2015-10-21 10:10:2269 // Returns the MetricsServiceClient, creating it if it hasn't been
[email protected]4a55a712014-06-08 16:50:3470 // created yet (and additionally creating the MetricsService in that case).
blundellfecea528d2015-10-21 10:10:2271 metrics::MetricsServiceClient* GetMetricsServiceClient();
[email protected]4a55a712014-06-08 16:50:3472
[email protected]c3cac952014-05-09 01:51:1873 metrics::MetricsStateManager* GetMetricsStateManager();
74
holte585f4662015-06-18 19:13:5275 // Update which services are running to match current permissions.
76 void UpdateRunningServices();
77
blundellfecea528d2015-10-21 10:10:2278 // The client passed in from the embedder.
79 scoped_ptr<MetricsServicesManagerClient> client_;
80
[email protected]c3cac952014-05-09 01:51:1881 // Ensures that all functions are called from the same thread.
82 base::ThreadChecker thread_checker_;
83
holte873fb7c92015-02-19 23:41:2684 // The current metrics reporting setting.
85 bool may_upload_;
86
87 // The current metrics recording setting.
88 bool may_record_;
89
blundellfecea528d2015-10-21 10:10:2290 // The MetricsServiceClient. Owns the MetricsService.
91 scoped_ptr<metrics::MetricsServiceClient> metrics_service_client_;
[email protected]c3cac952014-05-09 01:51:1892
93 // The RapporService, for RAPPOR metric uploads.
94 scoped_ptr<rappor::RapporService> rappor_service_;
95
96 // The VariationsService, for server-side experiments infrastructure.
blundell57bcfed2015-09-04 08:44:4597 scoped_ptr<variations::VariationsService> variations_service_;
[email protected]c3cac952014-05-09 01:51:1898
99 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager);
100};
101
blundell695d61f2015-10-21 11:25:53102} // namespace metrics_services_manager
103
104#endif // COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_