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

Side by Side Diff: ios/chrome/browser/ios_chrome_main_parts.mm

Issue 2333283005: Move EntropyProvider Source From MetricsService to MetricsServicesManager (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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ios_chrome_main_parts.h" 5 #include "ios/chrome/browser/ios_chrome_main_parts.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 void IOSChromeMainParts::PostDestroyThreads() { 187 void IOSChromeMainParts::PostDestroyThreads() {
188 application_context_->PostDestroyThreads(); 188 application_context_->PostDestroyThreads();
189 } 189 }
190 190
191 // This will be called after the command-line has been mutated by about:flags 191 // This will be called after the command-line has been mutated by about:flags
192 void IOSChromeMainParts::SetUpMetricsAndFieldTrials() { 192 void IOSChromeMainParts::SetUpMetricsAndFieldTrials() {
193 base::SetRecordActionTaskRunner( 193 base::SetRecordActionTaskRunner(
194 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI)); 194 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI));
195 195
196 // Must initialize metrics after labs have been converted into switches,
197 // but before field trials are set up (so that client ID is available for
198 // one-time randomized field trials).
199 metrics::MetricsService* metrics = application_context_->GetMetricsService();
200
201 // Initialize FieldTrialList to support FieldTrials that use one-time 196 // Initialize FieldTrialList to support FieldTrials that use one-time
202 // randomization. 197 // randomization.
Alexei Svitkine (slow) 2016/09/14 20:26:37 Can you add the DCHECK() that's in the non-iOS cod
robliao 2016/09/14 20:54:42 Done.
203 field_trial_list_.reset( 198 field_trial_list_.reset(
204 new base::FieldTrialList(metrics->CreateEntropyProvider().release())); 199 new base::FieldTrialList(application_context_->GetMetricsServicesManager()
200 ->CreateEntropyProvider()
201 .release()));
205 202
206 const base::CommandLine* command_line = 203 const base::CommandLine* command_line =
207 base::CommandLine::ForCurrentProcess(); 204 base::CommandLine::ForCurrentProcess();
208 // Ensure any field trials specified on the command line are initialized. 205 // Ensure any field trials specified on the command line are initialized.
209 // Also stop the metrics service so that we don't pollute UMA. 206 // Also stop the metrics service so that we don't pollute UMA.
210 if (command_line->HasSwitch(switches::kForceFieldTrials)) { 207 if (command_line->HasSwitch(switches::kForceFieldTrials)) {
211 // Create field trials without activating them, so that this behaves in a 208 // Create field trials without activating them, so that this behaves in a
212 // consistent manner with field trials created from the server. 209 // consistent manner with field trials created from the server.
213 bool result = base::FieldTrialList::CreateTrialsFromString( 210 bool result = base::FieldTrialList::CreateTrialsFromString(
214 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), 211 command_line->GetSwitchValueASCII(switches::kForceFieldTrials),
215 std::set<std::string>()); 212 std::set<std::string>());
216 CHECK(result) << "Invalid --" << switches::kForceFieldTrials 213 CHECK(result) << "Invalid --" << switches::kForceFieldTrials
217 << " list specified."; 214 << " list specified.";
218 } 215 }
219 216
220 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 217 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
221 218
222 // Associate parameters chosen in about:flags and create trial/group for them. 219 // Associate parameters chosen in about:flags and create trial/group for them.
223 flags_ui::PrefServiceFlagsStorage flags_storage( 220 flags_ui::PrefServiceFlagsStorage flags_storage(
224 application_context_->GetLocalState()); 221 application_context_->GetLocalState());
225 std::vector<std::string> variation_ids = 222 std::vector<std::string> variation_ids =
226 RegisterAllFeatureVariationParameters(&flags_storage, feature_list.get()); 223 RegisterAllFeatureVariationParameters(&flags_storage, feature_list.get());
227 224
225 // Must initialize metrics after labs have been converted into switches,
Alexei Svitkine (slow) 2016/09/14 20:26:38 Nit: "labs" terminology is pretty outdated. Given
robliao 2016/09/14 20:54:42 Done.
226 // but before field trials are set up (so that client ID is available for
227 // one-time randomized field trials).
228 metrics::MetricsService* metrics = application_context_->GetMetricsService();
229
Alexei Svitkine (slow) 2016/09/14 20:26:38 Nit: Make it consistent with the non-iOS code - ei
robliao 2016/09/14 20:54:42 This was lost in a file I forgot to save! It's the
228 variations::VariationsHttpHeaderProvider* http_header_provider = 230 variations::VariationsHttpHeaderProvider* http_header_provider =
229 variations::VariationsHttpHeaderProvider::GetInstance(); 231 variations::VariationsHttpHeaderProvider::GetInstance();
230 // Force the variation ids selected in chrome://flags and/or specified using 232 // Force the variation ids selected in chrome://flags and/or specified using
231 // the command-line flag. 233 // the command-line flag.
232 bool result = http_header_provider->ForceVariationIds( 234 bool result = http_header_provider->ForceVariationIds(
233 command_line->GetSwitchValueASCII(switches::kIOSForceVariationIds), 235 command_line->GetSwitchValueASCII(switches::kIOSForceVariationIds),
234 &variation_ids); 236 &variation_ids);
235 CHECK(result) << "Invalid list of variation ids specified (either in --" 237 CHECK(result) << "Invalid list of variation ids specified (either in --"
236 << switches::kIOSForceVariationIds << " or in chrome://flags)"; 238 << switches::kIOSForceVariationIds << " or in chrome://flags)";
237 metrics->AddSyntheticTrialObserver(http_header_provider); 239 metrics->AddSyntheticTrialObserver(http_header_provider);
(...skipping 18 matching lines...) Expand all
256 258
257 void IOSChromeMainParts::StartMetricsRecording() { 259 void IOSChromeMainParts::StartMetricsRecording() {
258 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); 260 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly);
259 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( 261 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular(
260 net::NetworkChangeNotifier::GetConnectionType()); 262 net::NetworkChangeNotifier::GetConnectionType());
261 bool mayUpload = !wifiOnly || !isConnectionCellular; 263 bool mayUpload = !wifiOnly || !isConnectionCellular;
262 264
263 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( 265 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions(
264 mayUpload); 266 mayUpload);
265 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698