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

Unified Diff: chrome/browser/metrics/variations/variations_seed_store.h

Issue 1200233005: Support delta-compressed variations server responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing missing return in !is_compressed case. Created 5 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/metrics/variations/variations_seed_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/variations/variations_seed_store.h
diff --git a/chrome/browser/metrics/variations/variations_seed_store.h b/chrome/browser/metrics/variations/variations_seed_store.h
index 2de275f7a4fdf141a30bba3315ec251254772310..0598e908066a0c25751507021c1799fe7498b01c 100644
--- a/chrome/browser/metrics/variations/variations_seed_store.h
+++ b/chrome/browser/metrics/variations/variations_seed_store.h
@@ -32,15 +32,20 @@ class VariationsSeedStore {
// successful, |seed| will contain the loaded data and true is returned.
bool LoadSeed(variations::VariationsSeed* seed);
- // Stores the given seed data (serialized protobuf data) to local state, along
+ // Stores the given seed |data| (serialized protobuf) to local state, along
// with a base64-encoded digital signature for seed and the date when it was
- // fetched. The |seed_data| will be base64 encoded for storage. If the string
- // is invalid, the existing prefs are left as is and false is returned. On
- // success and if |parsed_seed| is not NULL, |parsed_seed| will be filled
- // with the de-serialized protobuf decoded from |seed_data|.
- bool StoreSeedData(const std::string& seed_data,
+ // fetched. If |is_delta_compressed| is true, treats |data| as being delta
+ // compressed and attempts to decode it first using the store's seed data.
+ // The actual seed data will be base64 encoded for storage. If the string
+ // is invalid, the existing prefs are untouched and false is returned.
+ // Additionally, stores the |country_code| that was received with the seed in
+ // a separate pref. On success and if |parsed_seed| is not NULL, |parsed_seed|
+ // will be filled with the de-serialized decoded protobuf.
+ bool StoreSeedData(const std::string& data,
const std::string& base64_seed_signature,
+ const std::string& country_code,
const base::Time& date_fetched,
+ bool is_delta_compressed,
variations::VariationsSeed* parsed_seed);
// Updates |kVariationsSeedDate| and logs when previous date was from a
@@ -52,13 +57,18 @@ class VariationsSeedStore {
return variations_serial_number_;
}
- // Registers Local State prefs used by this class.
- static void RegisterPrefs(PrefRegistrySimple* registry);
+ // Returns whether the last loaded or stored seed has the country field set.
+ bool seed_has_country_code() const {
+ return seed_has_country_code_;
+ }
// Returns the invalid signature in base64 format, or an empty string if the
// signature was valid, missing, or if signature verification is disabled.
std::string GetInvalidSignature() const;
+ // Registers Local State prefs used by this class.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
protected:
// Note: UMA histogram enum - don't re-order or remove entries.
enum VerifySignatureResult {
@@ -82,6 +92,7 @@ class VariationsSeedStore {
private:
FRIEND_TEST_ALL_PREFIXES(VariationsSeedStoreTest, VerifySeedSignature);
+ FRIEND_TEST_ALL_PREFIXES(VariationsSeedStoreTest, ApplyDeltaPatch);
// Clears all prefs related to variations seed storage.
void ClearPrefs();
@@ -89,12 +100,31 @@ class VariationsSeedStore {
// Reads the variations seed data from prefs; returns true on success.
bool ReadSeedData(std::string* seed_data);
+ // Internal version of |StoreSeedData()| that assumes |seed_data| is not delta
+ // compressed.
+ bool StoreSeedDataNoDelta(
+ const std::string& seed_data,
+ const std::string& base64_seed_signature,
+ const std::string& country_code,
+ const base::Time& date_fetched,
+ variations::VariationsSeed* parsed_seed);
+
+ // Applies a delta-compressed |patch| to |existing_data|, producing the result
+ // in |output|. Returns whether the operation was successful.
+ static bool ApplyDeltaPatch(const std::string& existing_data,
+ const std::string& patch,
+ std::string* output);
+
// The pref service used to persist the variations seed.
PrefService* local_state_;
// Cached serial number from the most recently fetched variations seed.
std::string variations_serial_number_;
+ // Whether the most recently fetched variations seed has the country code
+ // field set.
+ bool seed_has_country_code_;
+
// Keeps track of an invalid signature.
std::string invalid_base64_signature_;
« no previous file with comments | « no previous file | chrome/browser/metrics/variations/variations_seed_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698