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

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

Issue 2180373003: Adding reporting of metrics sampling rate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 4 years, 4 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
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 for in-sample clients. If the sample rate is not
35 // defined, returns false, and |rate| is unchanged, otherwise returns true,
36 // and |rate| contains the sample rate. If the client isn't in-sample, the
37 // sample rate is undefined. It is also undefined for clients that are not
38 // eligible for sampling.
39 static bool GetSamplingRatePerMille(int* rate);
40
35 private: 41 private:
36 // This is defined as a member class to get access to 42 // This is defined as a member class to get access to
37 // ChromeMetricsServiceAccessor through ChromeMetricsServicesManagerClient's 43 // ChromeMetricsServiceAccessor through ChromeMetricsServicesManagerClient's
38 // friendship. 44 // friendship.
39 class ChromeEnabledStateProvider; 45 class ChromeEnabledStateProvider;
40 46
41 // metrics_services_manager::MetricsServicesManagerClient: 47 // metrics_services_manager::MetricsServicesManagerClient:
42 std::unique_ptr<rappor::RapporService> CreateRapporService() override; 48 std::unique_ptr<rappor::RapporService> CreateRapporService() override;
43 std::unique_ptr<variations::VariationsService> CreateVariationsService() 49 std::unique_ptr<variations::VariationsService> CreateVariationsService()
44 override; 50 override;
(...skipping 22 matching lines...) Expand all
67 PrefService* local_state_; 73 PrefService* local_state_;
68 74
69 // Subscription to SafeBrowsing service state changes. 75 // Subscription to SafeBrowsing service state changes.
70 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> 76 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription>
71 sb_state_subscription_; 77 sb_state_subscription_;
72 78
73 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); 79 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient);
74 }; 80 };
75 81
76 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ 82 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698