| 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 "components/variations/service/variations_service.h" | 5 #include "components/variations/service/variations_service.h" |
| 6 | 6 |
| 7 #include "base/build_time.h" | 7 #include "base/build_time.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 disable_deltas_for_next_request_(false), | 214 disable_deltas_for_next_request_(false), |
| 215 resource_request_allowed_notifier_(notifier.Pass()), | 215 resource_request_allowed_notifier_(notifier.Pass()), |
| 216 request_count_(0), | 216 request_count_(0), |
| 217 weak_ptr_factory_(this) { | 217 weak_ptr_factory_(this) { |
| 218 resource_request_allowed_notifier_->Init(this); | 218 resource_request_allowed_notifier_->Init(this); |
| 219 } | 219 } |
| 220 | 220 |
| 221 VariationsService::~VariationsService() { | 221 VariationsService::~VariationsService() { |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool VariationsService::CreateTrialsFromSeed() { | 224 bool VariationsService::CreateTrialsFromSeed(base::FeatureList* feature_list) { |
| 225 DCHECK(thread_checker_.CalledOnValidThread()); | 225 DCHECK(thread_checker_.CalledOnValidThread()); |
| 226 | 226 |
| 227 create_trials_from_seed_called_ = true; | 227 create_trials_from_seed_called_ = true; |
| 228 | 228 |
| 229 variations::VariationsSeed seed; | 229 variations::VariationsSeed seed; |
| 230 if (!seed_store_.LoadSeed(&seed)) | 230 if (!seed_store_.LoadSeed(&seed)) |
| 231 return false; | 231 return false; |
| 232 | 232 |
| 233 const base::Version current_version(version_info::GetVersionNumber()); | 233 const base::Version current_version(version_info::GetVersionNumber()); |
| 234 if (!current_version.IsValid()) | 234 if (!current_version.IsValid()) |
| 235 return false; | 235 return false; |
| 236 | 236 |
| 237 variations::Study_Channel channel = | 237 variations::Study_Channel channel = |
| 238 GetChannelForVariations(client_->GetChannel()); | 238 GetChannelForVariations(client_->GetChannel()); |
| 239 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); | 239 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); |
| 240 | 240 |
| 241 const std::string latest_country = | 241 const std::string latest_country = |
| 242 local_state_->GetString(prefs::kVariationsCountry); | 242 local_state_->GetString(prefs::kVariationsCountry); |
| 243 // Note that passing |client_| via base::Unretained below is safe because | 243 // Note that passing |client_| via base::Unretained below is safe because |
| 244 // the callback is executed synchronously. | 244 // the callback is executed synchronously. |
| 245 variations::VariationsSeedProcessor().CreateTrialsFromSeed( | 245 variations::VariationsSeedProcessor().CreateTrialsFromSeed( |
| 246 seed, client_->GetApplicationLocale(), | 246 seed, client_->GetApplicationLocale(), |
| 247 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, | 247 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, |
| 248 GetCurrentFormFactor(), GetHardwareClass(), latest_country, | 248 GetCurrentFormFactor(), GetHardwareClass(), latest_country, |
| 249 LoadPermanentConsistencyCountry(current_version, latest_country), | 249 LoadPermanentConsistencyCountry(current_version, latest_country), |
| 250 base::Bind(&VariationsServiceClient::OverrideUIString, | 250 base::Bind(&VariationsServiceClient::OverrideUIString, |
| 251 base::Unretained(client_.get()))); | 251 base::Unretained(client_.get())), |
| 252 feature_list); |
| 252 | 253 |
| 253 const base::Time now = base::Time::Now(); | 254 const base::Time now = base::Time::Now(); |
| 254 | 255 |
| 255 // Log the "freshness" of the seed that was just used. The freshness is the | 256 // Log the "freshness" of the seed that was just used. The freshness is the |
| 256 // time between the last successful seed download and now. | 257 // time between the last successful seed download and now. |
| 257 const int64 last_fetch_time_internal = | 258 const int64 last_fetch_time_internal = |
| 258 local_state_->GetInt64(prefs::kVariationsLastFetchTime); | 259 local_state_->GetInt64(prefs::kVariationsLastFetchTime); |
| 259 if (last_fetch_time_internal) { | 260 if (last_fetch_time_internal) { |
| 260 const base::TimeDelta delta = | 261 const base::TimeDelta delta = |
| 261 now - base::Time::FromInternalValue(last_fetch_time_internal); | 262 now - base::Time::FromInternalValue(last_fetch_time_internal); |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 // Otherwise, update the pref with the current Chrome version and country. | 756 // Otherwise, update the pref with the current Chrome version and country. |
| 756 base::ListValue new_list_value; | 757 base::ListValue new_list_value; |
| 757 new_list_value.AppendString(version.GetString()); | 758 new_list_value.AppendString(version.GetString()); |
| 758 new_list_value.AppendString(latest_country); | 759 new_list_value.AppendString(latest_country); |
| 759 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 760 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
| 760 new_list_value); | 761 new_list_value); |
| 761 return latest_country; | 762 return latest_country; |
| 762 } | 763 } |
| 763 | 764 |
| 764 } // namespace variations | 765 } // namespace variations |
| OLD | NEW |