Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1073)

Side by Side Diff: chrome/browser/metrics/metrics_services_manager.h

Issue 1412113002: Componentize MetricsServicesManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor_metrics_services_manager
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
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
12 class MetricsServicesManagerClient;
13
14 namespace base {
15 class FilePath;
16 }
17
18 namespace metrics {
19 class MetricsService;
20 class MetricsServiceClient;
21 class MetricsStateManager;
22 }
23
24 namespace rappor {
25 class RapporService;
26 }
27
28 namespace variations {
29 class VariationsService;
30 }
31
32 // MetricsServicesManager is a helper class for embedders that use the various
33 // metrics-related services in a Chrome-like fashion: MetricsService (via its
34 // client), RapporService and VariationsService.
35 class MetricsServicesManager {
36 public:
37 // Creates the MetricsServicesManager with the given client.
38 explicit MetricsServicesManager(
39 scoped_ptr<MetricsServicesManagerClient> client);
40 virtual ~MetricsServicesManager();
41
42 // Returns the MetricsService, creating it if it hasn't been created yet (and
43 // additionally creating the MetricsServiceClient in that case).
44 metrics::MetricsService* GetMetricsService();
45
46 // Returns the RapporService, creating it if it hasn't been created yet.
47 rappor::RapporService* GetRapporService();
48
49 // Returns the VariationsService, creating it if it hasn't been created yet.
50 variations::VariationsService* GetVariationsService();
51
52 // Should be called when a plugin loading error occurs.
53 void OnPluginLoadingError(const base::FilePath& plugin_path);
54
55 // Update the managed services when permissions for recording/uploading
56 // metrics change.
57 void UpdatePermissions(bool may_record, bool may_upload);
58
59 // Update the managed services when permissions for uploading metrics change.
60 void UpdateUploadPermissions(bool may_upload);
61
62 private:
63 // Update the managed services when permissions for recording/uploading
64 // metrics change.
65 void UpdateRapporService();
66
67 // Returns the MetricsServiceClient, creating it if it hasn't been
68 // created yet (and additionally creating the MetricsService in that case).
69 metrics::MetricsServiceClient* GetMetricsServiceClient();
70
71 metrics::MetricsStateManager* GetMetricsStateManager();
72
73 // Update which services are running to match current permissions.
74 void UpdateRunningServices();
75
76 // The client passed in from the embedder.
77 scoped_ptr<MetricsServicesManagerClient> client_;
78
79 // Ensures that all functions are called from the same thread.
80 base::ThreadChecker thread_checker_;
81
82 // The current metrics reporting setting.
83 bool may_upload_;
84
85 // The current metrics recording setting.
86 bool may_record_;
87
88 // The MetricsServiceClient. Owns the MetricsService.
89 scoped_ptr<metrics::MetricsServiceClient> metrics_service_client_;
90
91 // The RapporService, for RAPPOR metric uploads.
92 scoped_ptr<rappor::RapporService> rappor_service_;
93
94 // The VariationsService, for server-side experiments infrastructure.
95 scoped_ptr<variations::VariationsService> variations_service_;
96
97 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager);
98 };
99
100 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICES_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698