| 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/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/metrics/variations/generated_resources_map.h" | 21 #include "chrome/browser/metrics/variations/generated_resources_map.h" |
| 22 #include "chrome/browser/metrics/variations/variations_url_constants.h" | 22 #include "chrome/browser/metrics/variations/variations_url_constants.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "components/metrics/metrics_state_manager.h" | 25 #include "components/metrics/metrics_state_manager.h" |
| 26 #include "components/network_time/network_time_tracker.h" | 26 #include "components/network_time/network_time_tracker.h" |
| 27 #include "components/pref_registry/pref_registry_syncable.h" | 27 #include "components/pref_registry/pref_registry_syncable.h" |
| 28 #include "components/variations/proto/variations_seed.pb.h" | 28 #include "components/variations/proto/variations_seed.pb.h" |
| 29 #include "components/variations/variations_seed_processor.h" | 29 #include "components/variations/variations_seed_processor.h" |
| 30 #include "components/variations/variations_seed_simulator.h" | 30 #include "components/variations/variations_seed_simulator.h" |
| 31 #include "components/version_info/version_info.h" |
| 31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 32 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
| 33 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
| 34 #include "net/base/network_change_notifier.h" | 35 #include "net/base/network_change_notifier.h" |
| 35 #include "net/base/url_util.h" | 36 #include "net/base/url_util.h" |
| 36 #include "net/http/http_response_headers.h" | 37 #include "net/http/http_response_headers.h" |
| 37 #include "net/http/http_status_code.h" | 38 #include "net/http/http_status_code.h" |
| 38 #include "net/http/http_util.h" | 39 #include "net/http/http_util.h" |
| 39 #include "net/url_request/url_fetcher.h" | 40 #include "net/url_request/url_fetcher.h" |
| 40 #include "net/url_request/url_request_status.h" | 41 #include "net/url_request/url_request_status.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 59 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker. | 60 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker. |
| 60 // For the HTTP date headers, the resolution of the server time is 1 second. | 61 // For the HTTP date headers, the resolution of the server time is 1 second. |
| 61 const int64 kServerTimeResolutionMs = 1000; | 62 const int64 kServerTimeResolutionMs = 1000; |
| 62 | 63 |
| 63 // Wrapper around channel checking, used to enable channel mocking for | 64 // Wrapper around channel checking, used to enable channel mocking for |
| 64 // testing. If the current browser channel is not UNKNOWN, this will return | 65 // 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 // 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 // will return the fake channel. Failing that, this will return the UNKNOWN |
| 67 // channel. | 68 // channel. |
| 68 variations::Study_Channel GetChannelForVariations() { | 69 variations::Study_Channel GetChannelForVariations() { |
| 69 switch (chrome::VersionInfo::GetChannel()) { | 70 switch (chrome::GetChannel()) { |
| 70 case version_info::Channel::CANARY: | 71 case version_info::Channel::CANARY: |
| 71 return variations::Study_Channel_CANARY; | 72 return variations::Study_Channel_CANARY; |
| 72 case version_info::Channel::DEV: | 73 case version_info::Channel::DEV: |
| 73 return variations::Study_Channel_DEV; | 74 return variations::Study_Channel_DEV; |
| 74 case version_info::Channel::BETA: | 75 case version_info::Channel::BETA: |
| 75 return variations::Study_Channel_BETA; | 76 return variations::Study_Channel_BETA; |
| 76 case version_info::Channel::STABLE: | 77 case version_info::Channel::STABLE: |
| 77 return variations::Study_Channel_STABLE; | 78 return variations::Study_Channel_STABLE; |
| 78 case version_info::Channel::UNKNOWN: | 79 case version_info::Channel::UNKNOWN: |
| 79 break; | 80 break; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 base::Version GetVersionForSimulation() { | 121 base::Version GetVersionForSimulation() { |
| 121 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) | 122 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) |
| 122 const base::Version installed_version = | 123 const base::Version installed_version = |
| 123 UpgradeDetectorImpl::GetCurrentlyInstalledVersion(); | 124 UpgradeDetectorImpl::GetCurrentlyInstalledVersion(); |
| 124 if (installed_version.IsValid()) | 125 if (installed_version.IsValid()) |
| 125 return installed_version; | 126 return installed_version; |
| 126 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) | 127 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) |
| 127 | 128 |
| 128 // TODO(asvitkine): Get the version that will be used on restart instead of | 129 // TODO(asvitkine): Get the version that will be used on restart instead of |
| 129 // the current version on Android, iOS and ChromeOS. | 130 // the current version on Android, iOS and ChromeOS. |
| 130 return base::Version(chrome::VersionInfo().Version()); | 131 return base::Version(version_info::GetVersionNumber()); |
| 131 } | 132 } |
| 132 | 133 |
| 133 // Gets the restrict parameter from |policy_pref_service| or from Chrome OS | 134 // Gets the restrict parameter from |policy_pref_service| or from Chrome OS |
| 134 // settings in the case of that platform. | 135 // settings in the case of that platform. |
| 135 std::string GetRestrictParameterPref(PrefService* policy_pref_service) { | 136 std::string GetRestrictParameterPref(PrefService* policy_pref_service) { |
| 136 std::string parameter; | 137 std::string parameter; |
| 137 #if defined(OS_CHROMEOS) | 138 #if defined(OS_CHROMEOS) |
| 138 chromeos::CrosSettings::Get()->GetString( | 139 chromeos::CrosSettings::Get()->GetString( |
| 139 chromeos::kVariationsRestrictParameter, ¶meter); | 140 chromeos::kVariationsRestrictParameter, ¶meter); |
| 140 #else | 141 #else |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 VariationsService::~VariationsService() { | 253 VariationsService::~VariationsService() { |
| 253 } | 254 } |
| 254 | 255 |
| 255 bool VariationsService::CreateTrialsFromSeed() { | 256 bool VariationsService::CreateTrialsFromSeed() { |
| 256 create_trials_from_seed_called_ = true; | 257 create_trials_from_seed_called_ = true; |
| 257 | 258 |
| 258 variations::VariationsSeed seed; | 259 variations::VariationsSeed seed; |
| 259 if (!seed_store_.LoadSeed(&seed)) | 260 if (!seed_store_.LoadSeed(&seed)) |
| 260 return false; | 261 return false; |
| 261 | 262 |
| 262 const chrome::VersionInfo current_version_info; | 263 const base::Version current_version(version_info::GetVersionNumber()); |
| 263 const base::Version current_version(current_version_info.Version()); | |
| 264 if (!current_version.IsValid()) | 264 if (!current_version.IsValid()) |
| 265 return false; | 265 return false; |
| 266 | 266 |
| 267 variations::Study_Channel channel = GetChannelForVariations(); | 267 variations::Study_Channel channel = GetChannelForVariations(); |
| 268 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); | 268 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); |
| 269 | 269 |
| 270 variations::VariationsSeedProcessor().CreateTrialsFromSeed( | 270 variations::VariationsSeedProcessor().CreateTrialsFromSeed( |
| 271 seed, | 271 seed, |
| 272 g_browser_process->GetApplicationLocale(), | 272 g_browser_process->GetApplicationLocale(), |
| 273 GetReferenceDateForExpiryChecks(local_state_), | 273 GetReferenceDateForExpiryChecks(local_state_), |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 // Otherwise, update the pref with the current Chrome version and country. | 719 // Otherwise, update the pref with the current Chrome version and country. |
| 720 base::ListValue new_list_value; | 720 base::ListValue new_list_value; |
| 721 new_list_value.AppendString(version.GetString()); | 721 new_list_value.AppendString(version.GetString()); |
| 722 new_list_value.AppendString(seed.country_code()); | 722 new_list_value.AppendString(seed.country_code()); |
| 723 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 723 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
| 724 new_list_value); | 724 new_list_value); |
| 725 return seed.country_code(); | 725 return seed.country_code(); |
| 726 } | 726 } |
| 727 | 727 |
| 728 } // namespace chrome_variations | 728 } // namespace chrome_variations |
| OLD | NEW |