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

Unified Diff: components/variations/variations_seed_store.cc

Issue 1404583004: Support gzip-compressed seed data from the variations server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix signed-unsigned comparison issue 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 e20b0560069cc23ebc1c66e028fe3bc652734ad0..49695e5dec26d01b7c51bdc251b88bf0c99510c7 100644
--- a/components/variations/variations_seed_store.cc
+++ b/components/variations/variations_seed_store.cc
@@ -91,6 +91,7 @@ enum VariationsSeedStoreResult {
VARIATIONS_SEED_STORE_FAILED_DELTA_READ_SEED,
VARIATIONS_SEED_STORE_FAILED_DELTA_APPLY,
VARIATIONS_SEED_STORE_FAILED_DELTA_STORE,
+ VARIATIONS_SEED_STORE_FAILED_UNGZIP,
VARIATIONS_SEED_STORE_RESULT_ENUM_SIZE,
};
@@ -194,14 +195,32 @@ bool VariationsSeedStore::StoreSeedData(
const std::string& country_code,
const base::Time& date_fetched,
bool is_delta_compressed,
+ bool is_gzip_compressed,
variations::VariationsSeed* parsed_seed) {
+ // If the data is gzip compressed, first uncompress it.
+ std::string ungzipped_data;
+ if (is_gzip_compressed) {
+ if (compression::GzipUncompress(data, &ungzipped_data)) {
+ int size_reduction = ungzipped_data.length() - data.length();
+ UMA_HISTOGRAM_PERCENTAGE("Variations.StoreSeed.GzipSize.ReductionPercent",
Alexei Svitkine (slow) 2015/10/15 15:50:44 There should be a guard somewhere that ungzipped_d
veranika 2015/10/15 20:02:57 Done.
+ 100 * size_reduction / ungzipped_data.length());
Alexei Svitkine (slow) 2015/10/15 15:50:44 Nit: Align.
veranika 2015/10/15 20:02:57 Done.
+ UMA_HISTOGRAM_COUNTS_1000("Variations.StoreSeed.GzipSize",
+ data.length() / 1024);
+ } else {
+ RecordSeedStoreHistogram(VARIATIONS_SEED_STORE_FAILED_UNGZIP);
+ return false;
+ }
+ } else {
+ ungzipped_data = data;
+ }
+
if (!is_delta_compressed) {
const bool result =
- StoreSeedDataNoDelta(data, base64_seed_signature, country_code,
- date_fetched, parsed_seed);
+ StoreSeedDataNoDelta(ungzipped_data, base64_seed_signature,
+ country_code, date_fetched, parsed_seed);
if (result) {
UMA_HISTOGRAM_COUNTS_1000("Variations.StoreSeed.Size",
- data.length() / 1024);
+ ungzipped_data.length() / 1024);
}
return result;
}
@@ -216,7 +235,8 @@ bool VariationsSeedStore::StoreSeedData(
RecordSeedStoreHistogram(VARIATIONS_SEED_STORE_FAILED_DELTA_READ_SEED);
return false;
}
- if (!ApplyDeltaPatch(existing_seed_data, data, &updated_seed_data)) {
+ if (!ApplyDeltaPatch(existing_seed_data, ungzipped_data,
+ &updated_seed_data)) {
RecordSeedStoreHistogram(VARIATIONS_SEED_STORE_FAILED_DELTA_APPLY);
return false;
}
@@ -227,11 +247,11 @@ bool VariationsSeedStore::StoreSeedData(
if (result) {
// Note: |updated_seed_data.length()| is guaranteed to be non-zero, else
// result would be false.
- int size_reduction = updated_seed_data.length() - data.length();
+ int size_reduction = updated_seed_data.length() - ungzipped_data.length();
UMA_HISTOGRAM_PERCENTAGE("Variations.StoreSeed.DeltaSize.ReductionPercent",
100 * size_reduction / updated_seed_data.length());
UMA_HISTOGRAM_COUNTS_1000("Variations.StoreSeed.DeltaSize",
- data.length() / 1024);
+ ungzipped_data.length() / 1024);
} else {
RecordSeedStoreHistogram(VARIATIONS_SEED_STORE_FAILED_DELTA_STORE);
}

Powered by Google App Engine
This is Rietveld 408576698