| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 disable_deltas_for_next_request_(false), | 216 disable_deltas_for_next_request_(false), |
| 217 resource_request_allowed_notifier_(notifier.Pass()), | 217 resource_request_allowed_notifier_(notifier.Pass()), |
| 218 request_count_(0), | 218 request_count_(0), |
| 219 weak_ptr_factory_(this) { | 219 weak_ptr_factory_(this) { |
| 220 resource_request_allowed_notifier_->Init(this); | 220 resource_request_allowed_notifier_->Init(this); |
| 221 } | 221 } |
| 222 | 222 |
| 223 VariationsService::~VariationsService() { | 223 VariationsService::~VariationsService() { |
| 224 } | 224 } |
| 225 | 225 |
| 226 bool VariationsService::CreateTrialsFromSeed() { | 226 bool VariationsService::CreateTrialsFromSeed(base::FeatureList* feature_list) { |
| 227 DCHECK(thread_checker_.CalledOnValidThread()); | 227 DCHECK(thread_checker_.CalledOnValidThread()); |
| 228 | 228 |
| 229 create_trials_from_seed_called_ = true; | 229 create_trials_from_seed_called_ = true; |
| 230 | 230 |
| 231 variations::VariationsSeed seed; | 231 variations::VariationsSeed seed; |
| 232 if (!seed_store_.LoadSeed(&seed)) | 232 if (!seed_store_.LoadSeed(&seed)) |
| 233 return false; | 233 return false; |
| 234 | 234 |
| 235 const base::Version current_version(version_info::GetVersionNumber()); | 235 const base::Version current_version(version_info::GetVersionNumber()); |
| 236 if (!current_version.IsValid()) | 236 if (!current_version.IsValid()) |
| 237 return false; | 237 return false; |
| 238 | 238 |
| 239 variations::Study_Channel channel = | 239 variations::Study_Channel channel = |
| 240 GetChannelForVariations(client_->GetChannel()); | 240 GetChannelForVariations(client_->GetChannel()); |
| 241 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); | 241 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); |
| 242 | 242 |
| 243 const std::string latest_country = | 243 const std::string latest_country = |
| 244 local_state_->GetString(prefs::kVariationsCountry); | 244 local_state_->GetString(prefs::kVariationsCountry); |
| 245 // Note that passing |&ui_string_overrider_| via base::Unretained below is | 245 // Note that passing |&ui_string_overrider_| via base::Unretained below is |
| 246 // safe because the callback is executed synchronously. It is not possible | 246 // safe because the callback is executed synchronously. It is not possible |
| 247 // to pass UIStringOverrider itself to VariationSeedProcesor as variations | 247 // to pass UIStringOverrider itself to VariationSeedProcesor as variations |
| 248 // components should not depends on //ui/base. | 248 // components should not depends on //ui/base. |
| 249 variations::VariationsSeedProcessor().CreateTrialsFromSeed( | 249 variations::VariationsSeedProcessor().CreateTrialsFromSeed( |
| 250 seed, client_->GetApplicationLocale(), | 250 seed, client_->GetApplicationLocale(), |
| 251 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, | 251 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, |
| 252 GetCurrentFormFactor(), GetHardwareClass(), latest_country, | 252 GetCurrentFormFactor(), GetHardwareClass(), latest_country, |
| 253 LoadPermanentConsistencyCountry(current_version, latest_country), | 253 LoadPermanentConsistencyCountry(current_version, latest_country), |
| 254 base::Bind(&UIStringOverrider::OverrideUIString, | 254 base::Bind(&UIStringOverrider::OverrideUIString, |
| 255 base::Unretained(&ui_string_overrider_))); | 255 base::Unretained(&ui_string_overrider_)), |
| 256 feature_list); |
| 256 | 257 |
| 257 const base::Time now = base::Time::Now(); | 258 const base::Time now = base::Time::Now(); |
| 258 | 259 |
| 259 // Log the "freshness" of the seed that was just used. The freshness is the | 260 // Log the "freshness" of the seed that was just used. The freshness is the |
| 260 // time between the last successful seed download and now. | 261 // time between the last successful seed download and now. |
| 261 const int64 last_fetch_time_internal = | 262 const int64 last_fetch_time_internal = |
| 262 local_state_->GetInt64(prefs::kVariationsLastFetchTime); | 263 local_state_->GetInt64(prefs::kVariationsLastFetchTime); |
| 263 if (last_fetch_time_internal) { | 264 if (last_fetch_time_internal) { |
| 264 const base::TimeDelta delta = | 265 const base::TimeDelta delta = |
| 265 now - base::Time::FromInternalValue(last_fetch_time_internal); | 266 now - base::Time::FromInternalValue(last_fetch_time_internal); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 // Otherwise, update the pref with the current Chrome version and country. | 761 // Otherwise, update the pref with the current Chrome version and country. |
| 761 base::ListValue new_list_value; | 762 base::ListValue new_list_value; |
| 762 new_list_value.AppendString(version.GetString()); | 763 new_list_value.AppendString(version.GetString()); |
| 763 new_list_value.AppendString(latest_country); | 764 new_list_value.AppendString(latest_country); |
| 764 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 765 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
| 765 new_list_value); | 766 new_list_value); |
| 766 return latest_country; | 767 return latest_country; |
| 767 } | 768 } |
| 768 | 769 |
| 769 } // namespace variations | 770 } // namespace variations |
| OLD | NEW |