OLD | NEW |
---|---|
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 case Study_Channel_BETA: | 53 case Study_Channel_BETA: |
54 return chrome::VersionInfo::CHANNEL_BETA; | 54 return chrome::VersionInfo::CHANNEL_BETA; |
55 case Study_Channel_STABLE: | 55 case Study_Channel_STABLE: |
56 return chrome::VersionInfo::CHANNEL_STABLE; | 56 return chrome::VersionInfo::CHANNEL_STABLE; |
57 } | 57 } |
58 // All enum values of |study_channel| were handled above. | 58 // All enum values of |study_channel| were handled above. |
59 NOTREACHED(); | 59 NOTREACHED(); |
60 return chrome::VersionInfo::CHANNEL_UNKNOWN; | 60 return chrome::VersionInfo::CHANNEL_UNKNOWN; |
61 } | 61 } |
62 | 62 |
63 // Wrapper around channel checking, used to enable channel mocking for | |
64 // testing. If the current browser channel is not UNKNOWN, this will return | |
65 // that channel value. Otherwise, if the fake channel flag is provided, this | |
66 // will return the fake channel. Failing that, this will return the UNKNOWN | |
67 // channel. | |
68 chrome::VersionInfo::Channel GetChannelForVariations() { | |
69 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
70 if (channel != chrome::VersionInfo::CHANNEL_UNKNOWN) | |
71 return channel; | |
72 std::string forced_channel = | |
73 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
74 switches::kFakeVariationsChannel); | |
75 if (forced_channel == "stable") | |
76 channel = chrome::VersionInfo::CHANNEL_STABLE; | |
77 else if (forced_channel == "beta") | |
78 channel = chrome::VersionInfo::CHANNEL_BETA; | |
79 else if (forced_channel == "dev") | |
80 channel = chrome::VersionInfo::CHANNEL_DEV; | |
81 else if (forced_channel == "canary") | |
82 channel = chrome::VersionInfo::CHANNEL_CANARY; | |
83 else | |
84 DVLOG(1) << "Invalid channel provided: " << forced_channel; | |
85 return channel; | |
86 } | |
87 | |
63 Study_Platform GetCurrentPlatform() { | 88 Study_Platform GetCurrentPlatform() { |
64 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
65 return Study_Platform_PLATFORM_WINDOWS; | 90 return Study_Platform_PLATFORM_WINDOWS; |
66 #elif defined(OS_MACOSX) | 91 #elif defined(OS_MACOSX) |
67 return Study_Platform_PLATFORM_MAC; | 92 return Study_Platform_PLATFORM_MAC; |
68 #elif defined(OS_CHROMEOS) | 93 #elif defined(OS_CHROMEOS) |
69 return Study_Platform_PLATFORM_CHROMEOS; | 94 return Study_Platform_PLATFORM_CHROMEOS; |
70 #elif defined(OS_ANDROID) | 95 #elif defined(OS_ANDROID) |
71 return Study_Platform_PLATFORM_ANDROID; | 96 return Study_Platform_PLATFORM_ANDROID; |
72 #elif defined(OS_IOS) | 97 #elif defined(OS_IOS) |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 variations_serial_number_ = seed.serial_number(); | 300 variations_serial_number_ = seed.serial_number(); |
276 return true; | 301 return true; |
277 } | 302 } |
278 | 303 |
279 // static | 304 // static |
280 bool VariationsService::ShouldAddStudy( | 305 bool VariationsService::ShouldAddStudy( |
281 const Study& study, | 306 const Study& study, |
282 const chrome::VersionInfo& version_info, | 307 const chrome::VersionInfo& version_info, |
283 const base::Time& reference_date) { | 308 const base::Time& reference_date) { |
284 if (study.has_filter()) { | 309 if (study.has_filter()) { |
285 if (!CheckStudyChannel(study.filter(), chrome::VersionInfo::GetChannel())) { | 310 if (!CheckStudyChannel(study.filter(), GetChannelForVariations())) { |
Alexei Svitkine (slow)
2013/01/04 20:17:34
VariationsService::CreateTrialsFromSeed() calls th
| |
286 DVLOG(1) << "Filtered out study " << study.name() << " due to channel."; | 311 DVLOG(1) << "Filtered out study " << study.name() << " due to channel."; |
287 return false; | 312 return false; |
288 } | 313 } |
289 | 314 |
290 if (!CheckStudyLocale(study.filter(), | 315 if (!CheckStudyLocale(study.filter(), |
291 g_browser_process->GetApplicationLocale())) { | 316 g_browser_process->GetApplicationLocale())) { |
292 DVLOG(1) << "Filtered out study " << study.name() << " due to locale."; | 317 DVLOG(1) << "Filtered out study " << study.name() << " due to locale."; |
293 return false; | 318 return false; |
294 } | 319 } |
295 | 320 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 variation_id); | 536 variation_id); |
512 } | 537 } |
513 } | 538 } |
514 | 539 |
515 trial->SetForced(); | 540 trial->SetForced(); |
516 if (IsStudyExpired(study, reference_date)) | 541 if (IsStudyExpired(study, reference_date)) |
517 trial->Disable(); | 542 trial->Disable(); |
518 } | 543 } |
519 | 544 |
520 } // namespace chrome_variations | 545 } // namespace chrome_variations |
OLD | NEW |