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

Unified 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: asvit nits Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/variations/variations_service.cc
diff --git a/chrome/browser/metrics/variations/variations_service.cc b/chrome/browser/metrics/variations/variations_service.cc
index b4e12da5b1bb716dbe4b3ddb0f88b9d6b3ae6461..2c3ce903aa460b940fd8b3da973b8c8818077b40 100644
--- a/chrome/browser/metrics/variations/variations_service.cc
+++ b/chrome/browser/metrics/variations/variations_service.cc
@@ -60,6 +60,31 @@ chrome::VersionInfo::Channel ConvertStudyChannelToVersionChannel(
return chrome::VersionInfo::CHANNEL_UNKNOWN;
}
+// Wrapper around channel checking, used to enable channel mocking for
+// testing. If the current browser channel is not UNKNOWN, this will return
+// that channel value. Otherwise, if the fake channel flag is provided, this
+// will return the fake channel. Failing that, this will return the UNKNOWN
+// channel.
+chrome::VersionInfo::Channel GetChannelForVariations() {
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
+ if (channel != chrome::VersionInfo::CHANNEL_UNKNOWN)
+ return channel;
+ std::string forced_channel =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kFakeVariationsChannel);
+ if (forced_channel == "stable")
+ channel = chrome::VersionInfo::CHANNEL_STABLE;
+ else if (forced_channel == "beta")
+ channel = chrome::VersionInfo::CHANNEL_BETA;
+ else if (forced_channel == "dev")
+ channel = chrome::VersionInfo::CHANNEL_DEV;
+ else if (forced_channel == "canary")
+ channel = chrome::VersionInfo::CHANNEL_CANARY;
+ else
+ DVLOG(1) << "Invalid channel provided: " << forced_channel;
+ return channel;
+}
+
Study_Platform GetCurrentPlatform() {
#if defined(OS_WIN)
return Study_Platform_PLATFORM_WINDOWS;
@@ -282,7 +307,7 @@ bool VariationsService::ShouldAddStudy(
const chrome::VersionInfo& version_info,
const base::Time& reference_date) {
if (study.has_filter()) {
- if (!CheckStudyChannel(study.filter(), chrome::VersionInfo::GetChannel())) {
Alexei Svitkine (slow) 2013/01/04 20:17:34 VariationsService::CreateTrialsFromSeed() calls th
+ if (!CheckStudyChannel(study.filter(), GetChannelForVariations())) {
DVLOG(1) << "Filtered out study " << study.name() << " due to channel.";
return false;
}
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698