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

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

Issue 2307953002: Adding client side field trial for sampling on non-stable channels. (Closed)
Patch Set: 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
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_services_manager_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h" 5 #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 13 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
14 #include "chrome/browser/metrics/chrome_metrics_service_client.h" 14 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
15 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h" 15 #include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
16 #include "chrome/browser/metrics/variations/ui_string_overrider_factory.h" 16 #include "chrome/browser/metrics/variations/ui_string_overrider_factory.h"
17 #include "chrome/browser/ui/browser_otr_state.h" 17 #include "chrome/browser/ui/browser_otr_state.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/installer/util/google_update_settings.h" 19 #include "chrome/installer/util/google_update_settings.h"
20 #include "components/metrics/enabled_state_provider.h" 20 #include "components/metrics/enabled_state_provider.h"
21 #include "components/metrics/metrics_state_manager.h" 21 #include "components/metrics/metrics_state_manager.h"
22 #include "components/prefs/pref_service.h" 22 #include "components/prefs/pref_service.h"
23 #include "components/rappor/rappor_service.h" 23 #include "components/rappor/rappor_service.h"
24 #include "components/variations/service/variations_service.h" 24 #include "components/variations/service/variations_service.h"
25 #include "components/variations/variations_associated_data.h" 25 #include "components/variations/variations_associated_data.h"
26 #include "components/version_info/version_info.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 28
28 #if defined(OS_WIN) 29 #if defined(OS_WIN)
29 #include "base/win/registry.h" 30 #include "base/win/registry.h"
30 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
31 #include "chrome/install_static/install_util.h" 32 #include "chrome/install_static/install_util.h"
32 #include "chrome/installer/util/browser_distribution.h" 33 #include "chrome/installer/util/browser_distribution.h"
33 #include "components/crash/content/app/crashpad.h" 34 #include "components/crash/content/app/crashpad.h"
34 #endif // OS_WIN 35 #endif // OS_WIN
35 36
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 local_state_(local_state) { 110 local_state_(local_state) {
110 DCHECK(local_state); 111 DCHECK(local_state);
111 112
112 SetupMetricsStateForChromeOS(); 113 SetupMetricsStateForChromeOS();
113 } 114 }
114 115
115 ChromeMetricsServicesManagerClient::~ChromeMetricsServicesManagerClient() {} 116 ChromeMetricsServicesManagerClient::~ChromeMetricsServicesManagerClient() {}
116 117
117 // static 118 // static
118 void ChromeMetricsServicesManagerClient::CreateFallbackSamplingTrial( 119 void ChromeMetricsServicesManagerClient::CreateFallbackSamplingTrial(
120 version_info::Channel channel,
119 base::FeatureList* feature_list) { 121 base::FeatureList* feature_list) {
120 // The trial name must be kept in sync with the server config controlling 122 // The trial name must be kept in sync with the server config controlling
121 // sampling. If they don't match, then clients will be shuffled into different 123 // sampling. If they don't match, then clients will be shuffled into different
122 // groups when the server config takes over from the fallback trial. 124 // groups when the server config takes over from the fallback trial.
123 static const char kTrialName[] = "MetricsAndCrashSampling"; 125 static const char kTrialName[] = "MetricsAndCrashSampling";
124 scoped_refptr<base::FieldTrial> trial( 126 scoped_refptr<base::FieldTrial> trial(
125 base::FieldTrialList::FactoryGetFieldTrial( 127 base::FieldTrialList::FactoryGetFieldTrial(
126 kTrialName, 1000, "Default", base::FieldTrialList::kNoExpirationYear, 128 kTrialName, 1000, "Default", base::FieldTrialList::kNoExpirationYear,
127 1, 1, base::FieldTrial::ONE_TIME_RANDOMIZED, nullptr)); 129 1, 1, base::FieldTrial::ONE_TIME_RANDOMIZED, nullptr));
128 130
131 // On all channels except stable, we sample out at a minimal rate to ensure
132 // the code paths are exercised in the wild before hitting stable.
133 int sampled_in_rate = 990;
134 int sampled_out_rate = 10;
135 if (channel == version_info::Channel::STABLE) {
136 sampled_in_rate = 100;
137 sampled_out_rate = 900;
138 }
139
129 // Like the trial name, the order that these two groups are added to the trial 140 // Like the trial name, the order that these two groups are added to the trial
130 // must be kept in sync with the order that they appear in the server config. 141 // must be kept in sync with the order that they appear in the server config.
131 142
132 // 100 per-mille sampling rate group. 143 // 100 per-mille sampling rate group.
133 static const char kInSampleGroup[] = "InReportingSample"; 144 static const char kInSampleGroup[] = "InReportingSample";
134 AppendSamplingTrialGroup(kInSampleGroup, 100, trial.get()); 145 AppendSamplingTrialGroup(kInSampleGroup, sampled_in_rate, trial.get());
135 146
136 // 900 per-mille sampled out. 147 // 900 per-mille sampled out.
137 static const char kSampledOutGroup[] = "OutOfReportingSample"; 148 static const char kSampledOutGroup[] = "OutOfReportingSample";
138 AppendSamplingTrialGroup(kSampledOutGroup, 900, trial.get()); 149 AppendSamplingTrialGroup(kSampledOutGroup, sampled_out_rate, trial.get());
139 150
140 // Setup the feature. 151 // Setup the feature.
141 const std::string& group_name = trial->GetGroupNameWithoutActivation(); 152 const std::string& group_name = trial->GetGroupNameWithoutActivation();
142 feature_list->RegisterFieldTrialOverride( 153 feature_list->RegisterFieldTrialOverride(
143 kMetricsReportingFeature.name, 154 kMetricsReportingFeature.name,
144 group_name == kSampledOutGroup 155 group_name == kSampledOutGroup
145 ? base::FeatureList::OVERRIDE_DISABLE_FEATURE 156 ? base::FeatureList::OVERRIDE_DISABLE_FEATURE
146 : base::FeatureList::OVERRIDE_ENABLE_FEATURE, 157 : base::FeatureList::OVERRIDE_ENABLE_FEATURE,
147 trial.get()); 158 trial.get());
148 } 159 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { 273 ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
263 DCHECK(thread_checker_.CalledOnValidThread()); 274 DCHECK(thread_checker_.CalledOnValidThread());
264 if (!metrics_state_manager_) { 275 if (!metrics_state_manager_) {
265 metrics_state_manager_ = metrics::MetricsStateManager::Create( 276 metrics_state_manager_ = metrics::MetricsStateManager::Create(
266 local_state_, enabled_state_provider_.get(), 277 local_state_, enabled_state_provider_.get(),
267 base::Bind(&PostStoreMetricsClientInfo), 278 base::Bind(&PostStoreMetricsClientInfo),
268 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); 279 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo));
269 } 280 }
270 return metrics_state_manager_.get(); 281 return metrics_state_manager_.get();
271 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_services_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698