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..edda22fa0b715adb7de159b4778c140335640b37 100644 |
--- a/chrome/browser/metrics/variations/variations_seed_store.h |
+++ b/chrome/browser/metrics/variations/variations_seed_store.h |
@@ -32,15 +32,19 @@ 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 |
rkaplow
2015/08/04 22:37:05
nit, would change to |data| too then
Alexei Svitkine (slow)
2015/08/05 15:46:15
Done.
|
// 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 |
+ // fetched. If |is_delta_compressed| is true, treats |data| as being delta |
+ // compressed and attempts to decode it first using the store seed data. |
rkaplow
2015/08/04 22:37:05
did you mean stored btw?
Alexei Svitkine (slow)
2015/08/05 15:46:15
No meant, store's - i.e. refererring to this class
rkaplow
2015/08/05 18:01:56
it's fine - wasn't sure which way you meant it.
|
+ // The actual seed data will be base64 encoded for storage. If the string |
+ // is invalid, the existing prefs are untouched 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, |
+ // with the de-serialized decoded protobuf. |
+ bool StoreSeedData(const std::string& data, |
const std::string& base64_seed_signature, |
+ const std::string& country_code, |
rkaplow
2015/08/04 22:37:05
might be worth to add a line in the comment on how
Alexei Svitkine (slow)
2015/08/05 15:46:15
Done.
|
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 +56,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 +91,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 +99,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_; |