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

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

Issue 1984003002: Use low entropy for studies that send experiment IDs to Google properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 const base::Version current_version(version_info::GetVersionNumber()); 329 const base::Version current_version(version_info::GetVersionNumber());
330 if (!current_version.IsValid()) 330 if (!current_version.IsValid())
331 return false; 331 return false;
332 332
333 variations::Study_Channel channel = 333 variations::Study_Channel channel =
334 GetChannelForVariations(client_->GetChannel()); 334 GetChannelForVariations(client_->GetChannel());
335 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel); 335 UMA_HISTOGRAM_SPARSE_SLOWLY("Variations.UserChannel", channel);
336 336
337 const std::string latest_country = 337 const std::string latest_country =
338 local_state_->GetString(prefs::kVariationsCountry); 338 local_state_->GetString(prefs::kVariationsCountry);
339
340 std::unique_ptr<const base::FieldTrial::EntropyProvider> low_entropy_provider(
341 GetLowEntropyProvider());
339 // Note that passing |&ui_string_overrider_| via base::Unretained below is 342 // Note that passing |&ui_string_overrider_| via base::Unretained below is
340 // safe because the callback is executed synchronously. It is not possible 343 // safe because the callback is executed synchronously. It is not possible
341 // to pass UIStringOverrider itself to VariationSeedProcesor as variations 344 // to pass UIStringOverrider itself to VariationSeedProcesor as variations
342 // components should not depends on //ui/base. 345 // components should not depends on //ui/base.
343 variations::VariationsSeedProcessor().CreateTrialsFromSeed( 346 variations::VariationsSeedProcessor().CreateTrialsFromSeed(
344 seed, client_->GetApplicationLocale(), 347 seed, client_->GetApplicationLocale(),
345 GetReferenceDateForExpiryChecks(local_state_), current_version, channel, 348 GetReferenceDateForExpiryChecks(local_state_), current_version, channel,
346 GetCurrentFormFactor(), GetHardwareClass(), latest_country, 349 GetCurrentFormFactor(), GetHardwareClass(), latest_country,
347 LoadPermanentConsistencyCountry(current_version, latest_country), 350 LoadPermanentConsistencyCountry(current_version, latest_country),
348 base::Bind(&UIStringOverrider::OverrideUIString, 351 base::Bind(&UIStringOverrider::OverrideUIString,
349 base::Unretained(&ui_string_overrider_)), 352 base::Unretained(&ui_string_overrider_)),
350 feature_list); 353 feature_list, low_entropy_provider.get());
351 354
352 const base::Time now = base::Time::Now(); 355 const base::Time now = base::Time::Now();
353 356
354 // Log the "freshness" of the seed that was just used. The freshness is the 357 // Log the "freshness" of the seed that was just used. The freshness is the
355 // time between the last successful seed download and now. 358 // time between the last successful seed download and now.
356 if (last_fetch_time_internal) { 359 if (last_fetch_time_internal) {
357 const base::TimeDelta delta = 360 const base::TimeDelta delta =
358 now - base::Time::FromInternalValue(last_fetch_time_internal); 361 now - base::Time::FromInternalValue(last_fetch_time_internal);
359 // Log the value in number of minutes. 362 // Log the value in number of minutes.
360 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedFreshness", delta.InMinutes(), 363 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedFreshness", delta.InMinutes(),
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 return true; 591 return true;
589 592
590 base::PostTaskAndReplyWithResult( 593 base::PostTaskAndReplyWithResult(
591 client_->GetBlockingPool(), FROM_HERE, 594 client_->GetBlockingPool(), FROM_HERE,
592 client_->GetVersionForSimulationCallback(), 595 client_->GetVersionForSimulationCallback(),
593 base::Bind(&VariationsService::PerformSimulationWithVersion, 596 base::Bind(&VariationsService::PerformSimulationWithVersion,
594 weak_ptr_factory_.GetWeakPtr(), base::Passed(&seed))); 597 weak_ptr_factory_.GetWeakPtr(), base::Passed(&seed)));
595 return true; 598 return true;
596 } 599 }
597 600
601 std::unique_ptr<const base::FieldTrial::EntropyProvider>
602 VariationsService::GetLowEntropyProvider() {
Alexei Svitkine (slow) 2016/05/17 16:31:35 Nit: CreateLowEntropyProvider. Although, maybe no
jwd 2016/05/18 13:24:18 Done. Yeah, it's for the tests.
603 return state_manager_->CreateLowEntropyProvider();
604 }
605
598 bool VariationsService::LoadSeed(VariationsSeed* seed) { 606 bool VariationsService::LoadSeed(VariationsSeed* seed) {
599 return seed_store_.LoadSeed(seed); 607 return seed_store_.LoadSeed(seed);
600 } 608 }
601 609
602 void VariationsService::FetchVariationsSeed() { 610 void VariationsService::FetchVariationsSeed() {
603 DCHECK(thread_checker_.CalledOnValidThread()); 611 DCHECK(thread_checker_.CalledOnValidThread());
604 612
605 const web_resource::ResourceRequestAllowedNotifier::State state = 613 const web_resource::ResourceRequestAllowedNotifier::State state =
606 resource_request_allowed_notifier_->GetResourceRequestsAllowedState(); 614 resource_request_allowed_notifier_->GetResourceRequestsAllowedState();
607 RecordRequestsAllowedHistogram(ResourceRequestStateToHistogramValue(state)); 615 RecordRequestsAllowedHistogram(ResourceRequestStateToHistogramValue(state));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 std::unique_ptr<variations::VariationsSeed> seed, 741 std::unique_ptr<variations::VariationsSeed> seed,
734 const base::Version& version) { 742 const base::Version& version) {
735 DCHECK(thread_checker_.CalledOnValidThread()); 743 DCHECK(thread_checker_.CalledOnValidThread());
736 744
737 if (!version.IsValid()) 745 if (!version.IsValid())
738 return; 746 return;
739 747
740 const base::ElapsedTimer timer; 748 const base::ElapsedTimer timer;
741 749
742 std::unique_ptr<const base::FieldTrial::EntropyProvider> entropy_provider = 750 std::unique_ptr<const base::FieldTrial::EntropyProvider> entropy_provider =
743 state_manager_->CreateEntropyProvider(); 751 state_manager_->CreateDefaultEntropyProvider();
744 variations::VariationsSeedSimulator seed_simulator(*entropy_provider); 752 variations::VariationsSeedSimulator seed_simulator(*entropy_provider);
745 753
746 const std::string latest_country = 754 const std::string latest_country =
747 local_state_->GetString(prefs::kVariationsCountry); 755 local_state_->GetString(prefs::kVariationsCountry);
748 const variations::VariationsSeedSimulator::Result result = 756 const variations::VariationsSeedSimulator::Result result =
749 seed_simulator.SimulateSeedStudies( 757 seed_simulator.SimulateSeedStudies(
750 *seed, client_->GetApplicationLocale(), 758 *seed, client_->GetApplicationLocale(),
751 GetReferenceDateForExpiryChecks(local_state_), version, 759 GetReferenceDateForExpiryChecks(local_state_), version,
752 GetChannelForVariations(client_->GetChannel()), 760 GetChannelForVariations(client_->GetChannel()),
753 GetCurrentFormFactor(), GetHardwareClass(), latest_country, 761 GetCurrentFormFactor(), GetHardwareClass(), latest_country,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 894
887 if (got_stored_country && stored_country == country_override) 895 if (got_stored_country && stored_country == country_override)
888 return false; 896 return false;
889 897
890 base::Version version(version_info::GetVersionNumber()); 898 base::Version version(version_info::GetVersionNumber());
891 StorePermanentCountry(version, country_override); 899 StorePermanentCountry(version, country_override);
892 return true; 900 return true;
893 } 901 }
894 902
895 } // namespace variations 903 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698