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

Side by Side Diff: components/metrics_services_manager/metrics_services_manager.h

Issue 2510803003: Pass RapporService to content/browser/ (Closed)
Patch Set: Fix more compile errors in JNI files Created 4 years 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ 5 #ifndef COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_
6 #define COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ 6 #define COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 13
14 namespace base { 14 namespace base {
15 class FilePath; 15 class FilePath;
16 } 16 }
17 17
18 namespace metrics { 18 namespace metrics {
19 class MetricsService; 19 class MetricsService;
20 class MetricsServiceClient; 20 class MetricsServiceClient;
21 class MetricsStateManager; 21 class MetricsStateManager;
22 } 22 }
23 23
24 namespace rappor { 24 namespace rappor {
25 class RapporService; 25 class RapporServiceImpl;
26 } 26 }
27 27
28 namespace variations { 28 namespace variations {
29 class VariationsService; 29 class VariationsService;
30 } 30 }
31 31
32 namespace metrics_services_manager { 32 namespace metrics_services_manager {
33 33
34 class MetricsServicesManagerClient; 34 class MetricsServicesManagerClient;
35 35
36 // MetricsServicesManager is a helper class for embedders that use the various 36 // MetricsServicesManager is a helper class for embedders that use the various
37 // metrics-related services in a Chrome-like fashion: MetricsService (via its 37 // metrics-related services in a Chrome-like fashion: MetricsService (via its
38 // client), RapporService and VariationsService. 38 // client), RapporServiceImpl and VariationsService.
39 class MetricsServicesManager { 39 class MetricsServicesManager {
40 public: 40 public:
41 // Creates the MetricsServicesManager with the given client. 41 // Creates the MetricsServicesManager with the given client.
42 explicit MetricsServicesManager( 42 explicit MetricsServicesManager(
43 std::unique_ptr<MetricsServicesManagerClient> client); 43 std::unique_ptr<MetricsServicesManagerClient> client);
44 virtual ~MetricsServicesManager(); 44 virtual ~MetricsServicesManager();
45 45
46 // Returns the preferred entropy provider used to seed persistent activities 46 // Returns the preferred entropy provider used to seed persistent activities
47 // based on whether or not metrics reporting is permitted on this client. 47 // based on whether or not metrics reporting is permitted on this client.
48 // 48 //
49 // If there's consent to report metrics, this method returns an entropy 49 // If there's consent to report metrics, this method returns an entropy
50 // provider that has a high source of entropy, partially based on the client 50 // provider that has a high source of entropy, partially based on the client
51 // ID. Otherwise, it returns an entropy provider that is based on a low 51 // ID. Otherwise, it returns an entropy provider that is based on a low
52 // entropy source. 52 // entropy source.
53 std::unique_ptr<const base::FieldTrial::EntropyProvider> 53 std::unique_ptr<const base::FieldTrial::EntropyProvider>
54 CreateEntropyProvider(); 54 CreateEntropyProvider();
55 55
56 // Returns the MetricsService, creating it if it hasn't been created yet (and 56 // Returns the MetricsService, creating it if it hasn't been created yet (and
57 // additionally creating the MetricsServiceClient in that case). 57 // additionally creating the MetricsServiceClient in that case).
58 metrics::MetricsService* GetMetricsService(); 58 metrics::MetricsService* GetMetricsService();
59 59
60 // Returns the RapporService, creating it if it hasn't been created yet. 60 // Returns the RapporServiceImpl, creating it if it hasn't been created yet.
61 rappor::RapporService* GetRapporService(); 61 rappor::RapporServiceImpl* GetRapporServiceImpl();
62 62
63 // Returns the VariationsService, creating it if it hasn't been created yet. 63 // Returns the VariationsService, creating it if it hasn't been created yet.
64 variations::VariationsService* GetVariationsService(); 64 variations::VariationsService* GetVariationsService();
65 65
66 // Should be called when a plugin loading error occurs. 66 // Should be called when a plugin loading error occurs.
67 void OnPluginLoadingError(const base::FilePath& plugin_path); 67 void OnPluginLoadingError(const base::FilePath& plugin_path);
68 68
69 // Some embedders use this method to notify the metrics system when a 69 // Some embedders use this method to notify the metrics system when a
70 // renderer process exits unexpectedly. 70 // renderer process exits unexpectedly.
71 void OnRendererProcessCrash(); 71 void OnRendererProcessCrash();
72 72
73 // Update the managed services when permissions for recording/uploading 73 // Update the managed services when permissions for recording/uploading
74 // metrics change. 74 // metrics change.
75 void UpdatePermissions(bool may_record, bool may_upload); 75 void UpdatePermissions(bool may_record, bool may_upload);
76 76
77 // Update the managed services when permissions for uploading metrics change. 77 // Update the managed services when permissions for uploading metrics change.
78 void UpdateUploadPermissions(bool may_upload); 78 void UpdateUploadPermissions(bool may_upload);
79 79
80 private: 80 private:
81 // Update the managed services when permissions for recording/uploading 81 // Update the managed services when permissions for recording/uploading
82 // metrics change. 82 // metrics change.
83 void UpdateRapporService(); 83 void UpdateRapporServiceImpl();
84 84
85 // Returns the MetricsServiceClient, creating it if it hasn't been 85 // Returns the MetricsServiceClient, creating it if it hasn't been
86 // created yet (and additionally creating the MetricsService in that case). 86 // created yet (and additionally creating the MetricsService in that case).
87 metrics::MetricsServiceClient* GetMetricsServiceClient(); 87 metrics::MetricsServiceClient* GetMetricsServiceClient();
88 88
89 metrics::MetricsStateManager* GetMetricsStateManager(); 89 metrics::MetricsStateManager* GetMetricsStateManager();
90 90
91 // Update which services are running to match current permissions. 91 // Update which services are running to match current permissions.
92 void UpdateRunningServices(); 92 void UpdateRunningServices();
93 93
94 // The client passed in from the embedder. 94 // The client passed in from the embedder.
95 std::unique_ptr<MetricsServicesManagerClient> client_; 95 std::unique_ptr<MetricsServicesManagerClient> client_;
96 96
97 // Ensures that all functions are called from the same thread. 97 // Ensures that all functions are called from the same thread.
98 base::ThreadChecker thread_checker_; 98 base::ThreadChecker thread_checker_;
99 99
100 // The current metrics reporting setting. 100 // The current metrics reporting setting.
101 bool may_upload_; 101 bool may_upload_;
102 102
103 // The current metrics recording setting. 103 // The current metrics recording setting.
104 bool may_record_; 104 bool may_record_;
105 105
106 // The MetricsServiceClient. Owns the MetricsService. 106 // The MetricsServiceClient. Owns the MetricsService.
107 std::unique_ptr<metrics::MetricsServiceClient> metrics_service_client_; 107 std::unique_ptr<metrics::MetricsServiceClient> metrics_service_client_;
108 108
109 // The RapporService, for RAPPOR metric uploads. 109 // The RapporServiceImpl, for RAPPOR metric uploads.
110 std::unique_ptr<rappor::RapporService> rappor_service_; 110 std::unique_ptr<rappor::RapporServiceImpl> rappor_service_;
111 111
112 // The VariationsService, for server-side experiments infrastructure. 112 // The VariationsService, for server-side experiments infrastructure.
113 std::unique_ptr<variations::VariationsService> variations_service_; 113 std::unique_ptr<variations::VariationsService> variations_service_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager); 115 DISALLOW_COPY_AND_ASSIGN(MetricsServicesManager);
116 }; 116 };
117 117
118 } // namespace metrics_services_manager 118 } // namespace metrics_services_manager
119 119
120 #endif // COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_ 120 #endif // COMPONENTS_METRICS_SERVICES_MANAGER_METRICS_SERVICES_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698