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

Unified Diff: components/variations/variations_seed_store.cc

Issue 1417503010: Variations seed is pulled from the Java application on the first launch of Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes according to code review and lint comments Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/variations/variations_seed_store.cc
diff --git a/components/variations/variations_seed_store.cc b/components/variations/variations_seed_store.cc
index 89e1af214400935b73c4099d3897ec7cf29e221a..9e203c20af5d5b5593f4937af507578b47997843 100644
--- a/components/variations/variations_seed_store.cc
+++ b/components/variations/variations_seed_store.cc
@@ -152,6 +152,9 @@ VariationsSeedStore::~VariationsSeedStore() {
bool VariationsSeedStore::LoadSeed(variations::VariationsSeed* seed) {
invalid_base64_signature_.clear();
+ if (!local_state_->HasPrefPath(prefs::kVariationsSeedSignature))
+ ImportFirstRunJavaSeed();
+
std::string seed_data;
if (!ReadSeedData(&seed_data))
return false;
@@ -336,10 +339,35 @@ void VariationsSeedStore::ClearPrefs() {
local_state_->ClearPref(prefs::kVariationsSeedSignature);
}
+void VariationsSeedStore::ImportFirstRunJavaSeed() {
+ LOG(WARNING) << "variationsTracker: Trying to read seed from Java side";
Steven Holte 2015/10/29 01:37:12 Remove or change this to DVLOG(1) << "Importing f
Alexander Agulenko 2015/11/02 22:55:33 Done.
+ std::string seed_data, seed_signature, seed_country;
Alexei Svitkine (slow) 2015/10/29 15:04:12 Nit: 1 param per line.
Alexander Agulenko 2015/11/02 22:55:33 Done.
+ get_variations_first_run_seed_.Run(&seed_data, &seed_signature,
+ &seed_country);
+
+ if (seed_data.empty()) {
+ RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_EMPTY);
Steven Holte 2015/10/29 01:37:12 This should already get recorded by ReadSeedData (
Alexander Agulenko 2015/11/02 22:55:33 Done.
+ return;
+ }
+
+ // TODO (agulenko): Pull actual time from the response.
+ base::Time current_time = base::Time::Now();
+
+ // TODO(agulenko): Support gzip compressed seed.
+ if (!StoreSeedData(seed_data, seed_signature, seed_country,
+ current_time, false, false, nullptr)) {
+ LOG(WARNING) << "First run variations seed is invalid.";
+ return;
+ }
+ // TODO(agulenko): Clear Java prefs.
+}
+
bool VariationsSeedStore::ReadSeedData(std::string* seed_data) {
std::string base64_seed_data =
local_state_->GetString(prefs::kVariationsCompressedSeed);
+
Alexei Svitkine (slow) 2015/10/29 15:04:12 Nit: Remove extra diff here, same on line 370.
Alexander Agulenko 2015/11/02 22:55:33 Done.
const bool is_compressed = !base64_seed_data.empty();
+
// If there's no compressed seed, fall back to the uncompressed one.
if (!is_compressed)
base64_seed_data = local_state_->GetString(prefs::kVariationsSeed);

Powered by Google App Engine
This is Rietveld 408576698