| 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 namespace version_info { |
| 24 enum class Channel; |
| 25 } |
| 26 |
| 23 // Provides a //chrome-specific implementation of MetricsServicesManagerClient. | 27 // Provides a //chrome-specific implementation of MetricsServicesManagerClient. |
| 24 class ChromeMetricsServicesManagerClient | 28 class ChromeMetricsServicesManagerClient |
| 25 : public metrics_services_manager::MetricsServicesManagerClient { | 29 : public metrics_services_manager::MetricsServicesManagerClient { |
| 26 public: | 30 public: |
| 27 explicit ChromeMetricsServicesManagerClient(PrefService* local_state); | 31 explicit ChromeMetricsServicesManagerClient(PrefService* local_state); |
| 28 ~ChromeMetricsServicesManagerClient() override; | 32 ~ChromeMetricsServicesManagerClient() override; |
| 29 | 33 |
| 30 // Unconditionally attempts to create a field trial to control client side | 34 // 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 | 35 // 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 | 36 // 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 | 37 // 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 | 38 // no existing field trial controlling the sampling feature, and on the |
| 35 // correct platform and channel. | 39 // correct platform. |channel| will affect the sampling rates that are |
| 36 static void CreateFallbackSamplingTrial(base::FeatureList* feature_list); | 40 // applied. Stable will be sampled at 10%, other channels at 99%. |
| 41 static void CreateFallbackSamplingTrial(version_info::Channel channel, |
| 42 base::FeatureList* feature_list); |
| 37 | 43 |
| 38 // Determines if this client is eligible to send metrics. If they are, and | 44 // Determines if this client is eligible to send metrics. If they are, and |
| 39 // there was user consent, then metrics and crashes would be reported. | 45 // there was user consent, then metrics and crashes would be reported. |
| 40 static bool IsClientInSample(); | 46 static bool IsClientInSample(); |
| 41 | 47 |
| 42 // Gets the sample rate for in-sample clients. If the sample rate is not | 48 // Gets the sample rate for in-sample clients. If the sample rate is not |
| 43 // defined, returns false, and |rate| is unchanged, otherwise returns true, | 49 // defined, returns false, and |rate| is unchanged, otherwise returns true, |
| 44 // and |rate| contains the sample rate. If the client isn't in-sample, the | 50 // and |rate| contains the sample rate. If the client isn't in-sample, the |
| 45 // sample rate is undefined. It is also undefined for clients that are not | 51 // sample rate is undefined. It is also undefined for clients that are not |
| 46 // eligible for sampling. | 52 // eligible for sampling. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 PrefService* local_state_; | 92 PrefService* local_state_; |
| 87 | 93 |
| 88 // Subscription to SafeBrowsing service state changes. | 94 // Subscription to SafeBrowsing service state changes. |
| 89 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> | 95 std::unique_ptr<safe_browsing::SafeBrowsingService::StateSubscription> |
| 90 sb_state_subscription_; | 96 sb_state_subscription_; |
| 91 | 97 |
| 92 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); | 98 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServicesManagerClient); |
| 93 }; | 99 }; |
| 94 | 100 |
| 95 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ | 101 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICES_MANAGER_CLIENT_H_ |
| OLD | NEW |