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); |