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

Side by Side Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 11737025: Add a switch for faking channels for Variations filtering. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Honour set channels Created 7 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/variations/variations_service.h" 5 #include "chrome/browser/metrics/variations/variations_service.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/build_time.h" 10 #include "base/build_time.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 271
272 local_prefs->SetString(prefs::kVariationsSeed, base64_seed_data); 272 local_prefs->SetString(prefs::kVariationsSeed, base64_seed_data);
273 local_prefs->SetInt64(prefs::kVariationsSeedDate, 273 local_prefs->SetInt64(prefs::kVariationsSeedDate,
274 seed_date.ToInternalValue()); 274 seed_date.ToInternalValue());
275 variations_serial_number_ = seed.serial_number(); 275 variations_serial_number_ = seed.serial_number();
276 return true; 276 return true;
277 } 277 }
278 278
279 // static 279 // static
280 chrome::VersionInfo::Channel VariationsService::GetChannelForVariations() {
281 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
282 if (channel != chrome::VersionInfo::CHANNEL_UNKNOWN)
283 return channel;
284 std::string forced_channel =
285 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
286 switches::kFakeVariationsChannel);
287 if (!forced_channel.empty()) {
288 if (forced_channel == "stable")
289 channel = chrome::VersionInfo::CHANNEL_STABLE;
290 else if (forced_channel == "beta")
291 channel = chrome::VersionInfo::CHANNEL_BETA;
292 else if (forced_channel == "dev")
293 channel = chrome::VersionInfo::CHANNEL_DEV;
294 else if (forced_channel == "canary")
295 channel = chrome::VersionInfo::CHANNEL_CANARY;
296 else
297 NOTREACHED();
298 }
299 return channel;
300 }
301
302 // static
280 bool VariationsService::ShouldAddStudy( 303 bool VariationsService::ShouldAddStudy(
281 const Study& study, 304 const Study& study,
282 const chrome::VersionInfo& version_info, 305 const chrome::VersionInfo& version_info,
283 const base::Time& reference_date) { 306 const base::Time& reference_date) {
284 if (study.has_filter()) { 307 if (study.has_filter()) {
285 if (!CheckStudyChannel(study.filter(), chrome::VersionInfo::GetChannel())) { 308 if (!CheckStudyChannel(study.filter(), GetChannelForVariations())) {
286 DVLOG(1) << "Filtered out study " << study.name() << " due to channel."; 309 DVLOG(1) << "Filtered out study " << study.name() << " due to channel.";
287 return false; 310 return false;
288 } 311 }
289 312
290 if (!CheckStudyLocale(study.filter(), 313 if (!CheckStudyLocale(study.filter(),
291 g_browser_process->GetApplicationLocale())) { 314 g_browser_process->GetApplicationLocale())) {
292 DVLOG(1) << "Filtered out study " << study.name() << " due to locale."; 315 DVLOG(1) << "Filtered out study " << study.name() << " due to locale.";
293 return false; 316 return false;
294 } 317 }
295 318
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 variation_id); 534 variation_id);
512 } 535 }
513 } 536 }
514 537
515 trial->SetForced(); 538 trial->SetForced();
516 if (IsStudyExpired(study, reference_date)) 539 if (IsStudyExpired(study, reference_date))
517 trial->Disable(); 540 trial->Disable();
518 } 541 }
519 542
520 } // namespace chrome_variations 543 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698