OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ |
6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ | 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
14 #include "components/metrics_services_manager/metrics_services_manager_client.h" | 14 #include "components/metrics_services_manager/metrics_services_manager_client.h" |
15 | 15 |
16 class PrefService; | 16 class PrefService; |
17 | 17 |
18 namespace metrics { | 18 namespace metrics { |
19 class EnabledStateProvider; | 19 class EnabledStateProvider; |
20 class MetricsStateManager; | 20 class MetricsStateManager; |
21 } | 21 } |
22 | 22 |
23 // Metrics reporting feature. This feature, along with user consent, controls if | |
24 // recording and reporting are enabled. If the feature is enabled, but no | |
25 // consent is given, then there will be no recording or reporting. | |
26 extern const base::Feature kMetricsReportingFeature; | |
27 | |
28 // Provides a //chrome-specific implementation of MetricsServicesManagerClient. | 23 // Provides a //chrome-specific implementation of MetricsServicesManagerClient. |
29 class ChromeMetricsServicesManagerClient | 24 class ChromeMetricsServicesManagerClient |
30 : public metrics_services_manager::MetricsServicesManagerClient { | 25 : public metrics_services_manager::MetricsServicesManagerClient { |
31 public: | 26 public: |
32 explicit ChromeMetricsServicesManagerClient(PrefService* local_state); | 27 explicit ChromeMetricsServicesManagerClient(PrefService* local_state); |
33 ~ChromeMetricsServicesManagerClient() override; | 28 ~ChromeMetricsServicesManagerClient() override; |
34 | 29 |
30 // Determines if this client is eligible to send metrics. If they are, and | |
31 // there was user consent, then metrics and crashes would be reported. | |
32 static bool IsClientInSample(); | |
33 | |
34 // Gets the sample rate. If the sample rate is not defined, returns false, and | |
35 // |rate| is unchanged, otherwise returns true, and |rate| contains the sample | |
36 // rate. | |
Alexei Svitkine (slow)
2016/08/01 20:28:27
Nit: Expand comment to explain that if rate is not
jwd
2016/08/02 14:26:38
Done.
| |
37 static bool GetSamplingRatePerMille(int* rate); | |
38 | |
35 private: | 39 private: |
36 // This is defined as a member class to get access to | 40 // This is defined as a member class to get access to |
37 // ChromeMetricsServiceAccessor through ChromeMetricsServicesManagerClient's | 41 // ChromeMetricsServiceAccessor through ChromeMetricsServicesManagerClient's |
38 // friendship. | 42 // friendship. |
39 class ChromeEnabledStateProvider; | 43 class ChromeEnabledStateProvider; |
40 | 44 |
41 // metrics_services_manager::MetricsServicesManagerClient: | 45 // metrics_services_manager::MetricsServicesManagerClient: |
42 std::unique_ptr<rappor::RapporService> CreateRapporService() override; | 46 std::unique_ptr<rappor::RapporService> CreateRapporService() override; |
43 std::unique_ptr<variations::VariationsService> CreateVariationsService() | 47 std::unique_ptr<variations::VariationsService> CreateVariationsService() |
44 override; | 48 override; |
(...skipping 22 matching lines...) Expand all Loading... | |
67 PrefService* local_state_; | 71 PrefService* local_state_; |
68 | 72 |
69 // Subscription to SafeBrowsing service state changes. | 73 // Subscription to SafeBrowsing service state changes. |
70 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> | 74 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> |
71 sb_state_subscription_; | 75 sb_state_subscription_; |
72 | 76 |
73 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); | 77 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); |
74 }; | 78 }; |
75 | 79 |
76 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ | 80 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ |
OLD | NEW |