[Variations] Record the safe seed's freshness in safe mode.
[email protected]
Bug: 727984
Change-Id: I1ac800cce5cbfc7de67885ac6f9c3c6a715f25cb
Reviewed-on: https://chromium-review.googlesource.com/892323
Commit-Queue: Ilya Sherman <[email protected]>
Reviewed-by: Alexei Svitkine <[email protected]>
Cr-Commit-Position: refs/heads/master@{#533199}
diff --git a/components/variations/variations_seed_store.h b/components/variations/variations_seed_store.h
index 656fc3e..56bd21d 100644
--- a/components/variations/variations_seed_store.h
+++ b/components/variations/variations_seed_store.h
@@ -59,15 +59,16 @@
VariationsSeed* parsed_seed) WARN_UNUSED_RESULT;
// Loads the safe variations seed data from local state into |seed| and
- // updates any relevant fields in |client_state|. Returns true iff the safe
- // seed was read successfully from prefs. If the safe seed could not be
- // loaded, it is guaranteed that no fields in |client_state| are modified.
+ // updates any relevant fields in |client_state| and stores the
+ // |seed_fetch_time|. Returns true iff the safe seed was read successfully
+ // from prefs. If the safe seed could not be loaded, it is guaranteed that no
+ // fields in |client_state| are modified.
// Side-effect: Upon any failure to read or validate the safe seed, clears all
// of the safe seed pref values. This occurs iff the method returns false.
// Virtual for testing.
virtual bool LoadSafeSeed(VariationsSeed* seed,
- ClientFilterableState* client_state)
- WARN_UNUSED_RESULT;
+ ClientFilterableState* client_state,
+ base::Time* seed_fetch_time) WARN_UNUSED_RESULT;
// Stores the given |seed_data| (a serialized protobuf) to local state as a
// safe seed, along with a base64-encoded digital signature for seed and any
@@ -76,7 +77,17 @@
// Virtual for testing.
virtual bool StoreSafeSeed(const std::string& seed_data,
const std::string& base64_seed_signature,
- const ClientFilterableState& client_state);
+ const ClientFilterableState& client_state,
+ base::Time seed_fetch_time);
+
+ // Loads the last fetch time (for the latest seed) that was persisted to the
+ // store.
+ base::Time GetLastFetchTime() const;
+
+ // Records the current time as the last time at which a seed was fetched
+ // successfully. Also updates the safe seed's fetch time if the latest and
+ // safe seeds are identical.
+ void RecordLastFetchTime();
// Updates |kVariationsSeedDate| and logs when previous date was from a
// different day.