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..242d444a47d43ffb499b55ad6cedcf70446cf711 100644 |
--- a/components/variations/variations_seed_store.cc |
+++ b/components/variations/variations_seed_store.cc |
@@ -339,14 +339,52 @@ void VariationsSeedStore::ClearPrefs() { |
bool VariationsSeedStore::ReadSeedData(std::string* seed_data) { |
std::string base64_seed_data = |
local_state_->GetString(prefs::kVariationsCompressedSeed); |
- const bool is_compressed = !base64_seed_data.empty(); |
+ |
+ // ToDo (agulenko): return const identifier back |
+ /* 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); |
if (base64_seed_data.empty()) { |
+#if defined(OS_ANDROID) |
+ LOG(WARNING) << "variationsTracker: Trying to read seed from Java side"; |
Steven Holte
2015/10/28 01:00:18
Move this block of code into a function, e.g. Migr
Alexei Svitkine (slow)
2015/10/28 15:16:38
Agree with Steve. How about naming it ImportJavaSe
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ std::string plain_seed_data = pull_variations_seed_pref_.Run( |
+ prefs::kVariationsSeed); |
+ std::string seed_signature = pull_variations_seed_pref_.Run( |
+ prefs::kVariationsSeedSignature); |
+ std::string country_code = pull_variations_seed_pref_.Run( |
+ prefs::kVariationsCountry); |
+ |
+ if (plain_seed_data.empty()) { |
+ RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_EMPTY); |
+ return false; |
+ } |
+ |
+ // ToDo (agulenko): pull actual time from the response. |
Alexei Svitkine (slow)
2015/10/28 15:16:38
Nit: Usual format for these is:
TODO(agulenko): P
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ base::Time current_time = base::Time::Now(); |
+ scoped_ptr<variations::VariationsSeed> seed(new variations::VariationsSeed); |
Alexei Svitkine (slow)
2015/10/28 15:16:38
It doesn't seem like you're using |seed| other tha
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ |
+ // Trying to translated the seed that we pulled from the Java side. |
Steven Holte
2015/10/28 01:00:18
translate -> migrate, but moving to a function sho
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ // ToDo(agulenko): replace "true" with real value |
Steven Holte
2015/10/28 01:00:18
Nit: All caps TODO
Steven Holte
2015/10/28 01:00:18
Probably TODO: support gzipped seed?
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ if (!StoreSeedData(plain_seed_data, seed_signature, country_code, |
+ current_time, false, false, seed.get())) { |
+ LOG(WARNING) << "Seed translation failed!"; |
Steven Holte
2015/10/28 01:00:18
Change to "First run variations seed is invalid"
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ return false; |
+ } |
Steven Holte
2015/10/28 01:00:18
Add a TODO to clear the Java prefs (regardless if
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ |
+ base64_seed_data = local_state_->GetString(prefs::kVariationsCompressedSeed); |
Steven Holte
2015/10/28 01:00:18
To avoid this duplication it's probably better to
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
+ 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); |
+ } |
+#else // OS_ANDROID |
RecordVariationSeedEmptyHistogram(VARIATIONS_SEED_EMPTY); |
return false; |
+#endif // OS_ANDROID |
} |
// If the decode process fails, assume the pref value is corrupt and clear it. |