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

Side by Side Diff: components/variations/service/variations_service.cc

Issue 1306653004: Expand FeatureList to support FieldTrial association. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 unified diff | Download patch
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 disable_deltas_for_next_request_(false), 213 disable_deltas_for_next_request_(false),
214 resource_request_allowed_notifier_(notifier.Pass()), 214 resource_request_allowed_notifier_(notifier.Pass()),
215 request_count_(0), 215 request_count_(0),
216 weak_ptr_factory_(this) { 216 weak_ptr_factory_(this) {
217 resource_request_allowed_notifier_->Init(this); 217 resource_request_allowed_notifier_->Init(this);
218 } 218 }
219 219
220 VariationsService::~VariationsService() { 220 VariationsService::~VariationsService() {
221 } 221 }
222 222
223 bool VariationsService::CreateTrialsFromSeed() { 223 bool VariationsService::CreateTrialsFromSeed(base::FeatureList* feature_list) {
224 DCHECK(thread_checker_.CalledOnValidThread()); 224 DCHECK(thread_checker_.CalledOnValidThread());
225 225
226 create_trials_from_seed_called_ = true; 226 create_trials_from_seed_called_ = true;
227 227
228 variations::VariationsSeed seed; 228 variations::VariationsSeed seed;
229 if (!seed_store_.LoadSeed(&seed)) 229 if (!seed_store_.LoadSeed(&seed))
230 return false; 230 return false;
231 231
232 const base::Version current_version(version_info::GetVersionNumber()); 232 const base::Version current_version(version_info::GetVersionNumber());
233 if (!current_version.IsValid()) 233 if (!current_version.IsValid())
234 return false; 234 return false;
235 235
236 variations::Study_Channel channel = 236 variations::Study_Channel channel =
237 GetChannelForVariations(client_->GetChannel()); 237 GetChannelForVariations(client_->GetChannel());
238 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); 238 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel);
239 239
240 const std::string latest_country = 240 const std::string latest_country =
241 local_state_->GetString(prefs::kVariationsCountry); 241 local_state_->GetString(prefs::kVariationsCountry);
242 // Note that passing |client_| via base::Unretained below is safe because 242 // Note that passing |client_| via base::Unretained below is safe because
243 // the callback is executed synchronously. 243 // the callback is executed synchronously.
244 variations::VariationsSeedProcessor().CreateTrialsFromSeed( 244 variations::VariationsSeedProcessor().CreateTrialsFromSeed(
245 seed, client_->GetApplicationLocale(), 245 seed, client_->GetApplicationLocale(),
246 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, 246 GetReferenceDateForExpiryChecks(local_state_), current_version, channel,
247 GetCurrentFormFactor(), GetHardwareClass(), latest_country, 247 GetCurrentFormFactor(), GetHardwareClass(), latest_country,
248 LoadPermanentConsistencyCountry(current_version, latest_country), 248 LoadPermanentConsistencyCountry(current_version, latest_country),
249 base::Bind(&VariationsServiceClient::OverrideUIString, 249 base::Bind(&VariationsServiceClient::OverrideUIString,
250 base::Unretained(client_.get()))); 250 base::Unretained(client_.get())),
251 feature_list);
251 252
252 const base::Time now = base::Time::Now(); 253 const base::Time now = base::Time::Now();
253 254
254 // Log the "freshness" of the seed that was just used. The freshness is the 255 // Log the "freshness" of the seed that was just used. The freshness is the
255 // time between the last successful seed download and now. 256 // time between the last successful seed download and now.
256 const int64 last_fetch_time_internal = 257 const int64 last_fetch_time_internal =
257 local_state_->GetInt64(prefs::kVariationsLastFetchTime); 258 local_state_->GetInt64(prefs::kVariationsLastFetchTime);
258 if (last_fetch_time_internal) { 259 if (last_fetch_time_internal) {
259 const base::TimeDelta delta = 260 const base::TimeDelta delta =
260 now - base::Time::FromInternalValue(last_fetch_time_internal); 261 now - base::Time::FromInternalValue(last_fetch_time_internal);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 // Otherwise, update the pref with the current Chrome version and country. 752 // Otherwise, update the pref with the current Chrome version and country.
752 base::ListValue new_list_value; 753 base::ListValue new_list_value;
753 new_list_value.AppendString(version.GetString()); 754 new_list_value.AppendString(version.GetString());
754 new_list_value.AppendString(latest_country); 755 new_list_value.AppendString(latest_country);
755 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, 756 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry,
756 new_list_value); 757 new_list_value);
757 return latest_country; 758 return latest_country;
758 } 759 }
759 760
760 } // namespace variations 761 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698