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

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: Minor fix: removed debug output 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..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.

Powered by Google App Engine
This is Rietveld 408576698