| 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 // 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 // Unconditionally attempts to create a field trial to control client side |
| 31 // metrics/crash sampling to use as a fallback when one hasn't been |
| 32 // provided. This is expected to occur on first-run on platforms that don't |
| 33 // have first-run variations support. This should only be called when there is |
| 34 // no existing field trial controlling the sampling feature, and on the |
| 35 // correct platform and channel. |
| 36 static void CreateFallbackSamplingTrial(base::FeatureList* feature_list); |
| 37 |
| 30 // Determines if this client is eligible to send metrics. If they are, and | 38 // 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. | 39 // there was user consent, then metrics and crashes would be reported. |
| 32 static bool IsClientInSample(); | 40 static bool IsClientInSample(); |
| 33 | 41 |
| 34 // Gets the sample rate for in-sample clients. If the sample rate is not | 42 // 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, | 43 // 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 | 44 // 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 | 45 // sample rate is undefined. It is also undefined for clients that are not |
| 38 // eligible for sampling. | 46 // eligible for sampling. |
| 39 static bool GetSamplingRatePerMille(int* rate); | 47 static bool GetSamplingRatePerMille(int* rate); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 PrefService* local_state_; | 86 PrefService* local_state_; |
| 79 | 87 |
| 80 // Subscription to SafeBrowsing service state changes. | 88 // Subscription to SafeBrowsing service state changes. |
| 81 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> | 89 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> |
| 82 sb_state_subscription_; | 90 sb_state_subscription_; |
| 83 | 91 |
| 84 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); | 92 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); |
| 85 }; | 93 }; |
| 86 | 94 |
| 87 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ | 95 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ |
| OLD | NEW |