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

Unified Diff: components/variations/variations_seed_store.h

Issue 2935623004: [Cleanup] Clean up the VariationsSeedStore's histograms. (Closed)
Patch Set: Fix tests on iOS and Android Created 3 years, 6 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.h
diff --git a/components/variations/variations_seed_store.h b/components/variations/variations_seed_store.h
index 53a36546cda7edbebd5dde65d64697d46e8b4134..a80291196a30a0e9e6cdd3a7a2b731ac01a7c831 100644
--- a/components/variations/variations_seed_store.h
+++ b/components/variations/variations_seed_store.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/time/time.h"
#include "build/build_config.h"
+#include "components/variations/metrics.h"
class PrefService;
class PrefRegistrySimple;
@@ -32,7 +33,7 @@ class VariationsSeedStore {
// Loads the variations seed data from local state into |seed|. If there is a
// problem with loading, the pref value is cleared and false is returned. If
// successful, |seed| will contain the loaded data and true is returned.
- bool LoadSeed(variations::VariationsSeed* seed);
+ bool LoadSeed(variations::VariationsSeed* seed) WARN_UNUSED_RESULT;
// 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
@@ -51,7 +52,8 @@ class VariationsSeedStore {
const base::Time& date_fetched,
bool is_delta_compressed,
bool is_gzip_compressed,
- variations::VariationsSeed* parsed_seed);
+ variations::VariationsSeed* parsed_seed)
+ WARN_UNUSED_RESULT;
// Updates |kVariationsSeedDate| and logs when previous date was from a
// different day.
@@ -73,25 +75,8 @@ class VariationsSeedStore {
static void RegisterPrefs(PrefRegistrySimple* registry);
protected:
- // Note: UMA histogram enum - don't re-order or remove entries.
- enum VerifySignatureResult {
- VARIATIONS_SEED_SIGNATURE_MISSING,
- VARIATIONS_SEED_SIGNATURE_DECODE_FAILED,
- VARIATIONS_SEED_SIGNATURE_INVALID_SIGNATURE,
- VARIATIONS_SEED_SIGNATURE_INVALID_SEED,
- VARIATIONS_SEED_SIGNATURE_VALID,
- VARIATIONS_SEED_SIGNATURE_ENUM_SIZE,
- };
-
- // Verifies a variations seed (the serialized proto bytes) with the specified
- // base-64 encoded signature that was received from the server and returns the
- // result. The signature is assumed to be an "ECDSA with SHA-256" signature
- // (see kECDSAWithSHA256AlgorithmID in the .cc file). Returns the result of
- // signature verification or VARIATIONS_SEED_SIGNATURE_ENUM_SIZE if signature
- // verification is not enabled.
- virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature(
- const std::string& seed_bytes,
- const std::string& base64_seed_signature);
+ // Whether signature verification is enabled. Overridable for tests.
+ virtual bool SignatureVerificationEnabled();
private:
FRIEND_TEST_ALL_PREFIXES(VariationsSeedStoreTest, VerifySeedSignature);
@@ -106,23 +91,26 @@ class VariationsSeedStore {
void ImportFirstRunJavaSeed();
#endif // OS_ANDROID
- // Reads the variations seed data from prefs; returns true on success.
- bool ReadSeedData(std::string* seed_data);
+ // Reads the variations seed data from prefs into |seed_data|, and returns the
+ // result of the load. The value stored into |seed_data| should only be used
+ // if the result is SUCCESS.
+ // Side-effect: If the read fails, clears the prefs associated with the seed.
+ LoadSeedResult ReadSeedData(std::string* seed_data) WARN_UNUSED_RESULT;
// 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);
+ 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)
+ WARN_UNUSED_RESULT;
// 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);
+ std::string* output) WARN_UNUSED_RESULT;
// The pref service used to persist the variations seed.
PrefService* local_state_;

Powered by Google App Engine
This is Rietveld 408576698