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

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

Issue 2288853003: Adding local field trial for metrics/crash reports sampling. (Closed)
Patch Set: Adding local field trial for sampling. Created 4 years, 3 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 // Provides a //chrome-specific implementation of MetricsServicesManagerClient. 23 // Provides a //chrome-specific implementation of MetricsServicesManagerClient.
24 class ChromeMetricsServicesManagerClient 24 class ChromeMetricsServicesManagerClient
25 : public metrics_services_manager::MetricsServicesManagerClient { 25 : public metrics_services_manager::MetricsServicesManagerClient {
26 public: 26 public:
27 explicit ChromeMetricsServicesManagerClient(PrefService* local_state); 27 explicit ChromeMetricsServicesManagerClient(PrefService* local_state);
28 ~ChromeMetricsServicesManagerClient() override; 28 ~ChromeMetricsServicesManagerClient() override;
29 29
30 #if defined(OS_WIN) || defined(OS_ANDROID)
31 // Unconditionally attempts to create a field trial to controll client side
32 // metrics/crash sampling to use as a fallback when one hasn't been
33 // provided. This is expected to occur on first-run on platforms that don't
34 // have variations first-run support. This should only be called when there is
35 // no existing field trial controlling the sampling feature, and on the
36 // correct platform and channel.
37 static void CreateFallbackSamplingTrial(base::FeatureList* feature_list);
38 #endif // defined(OS_WIN) || defined(OS_ANDROID)
39
30 // Determines if this client is eligible to send metrics. If they are, and 40 // 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. 41 // there was user consent, then metrics and crashes would be reported.
32 static bool IsClientInSample(); 42 static bool IsClientInSample();
33 43
34 // Gets the sample rate for in-sample clients. If the sample rate is not 44 // 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, 45 // 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 46 // 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 47 // sample rate is undefined. It is also undefined for clients that are not
38 // eligible for sampling. 48 // eligible for sampling.
39 static bool GetSamplingRatePerMille(int* rate); 49 static bool GetSamplingRatePerMille(int* rate);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 PrefService* local_state_; 88 PrefService* local_state_;
79 89
80 // Subscription to SafeBrowsing service state changes. 90 // Subscription to SafeBrowsing service state changes.
81 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> 91 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription>
82 sb_state_subscription_; 92 sb_state_subscription_;
83 93
84 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); 94 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient);
85 }; 95 };
86 96
87 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ 97 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698