[Variations] Always use the latest seed's serial number, even in safe mode.

[email protected]

Bug: 727984
Change-Id: If3b37c8c040eb9aee145699cb493c624aebd0028
Reviewed-on: https://chromium-review.googlesource.com/865525
Reviewed-by: Ilya Sherman <[email protected]>
Reviewed-by: Alexei Svitkine <[email protected]>
Commit-Queue: Ilya Sherman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#529639}
diff --git a/components/variations/variations_seed_store.h b/components/variations/variations_seed_store.h
index bc18b8e8..2af9b8d 100644
--- a/components/variations/variations_seed_store.h
+++ b/components/variations/variations_seed_store.h
@@ -73,10 +73,13 @@
   // Reports to UMA that the seed format specified by the server is unsupported.
   void ReportUnsupportedSeedFormatError();
 
-  // Returns the serial number of the last loaded or stored seed.
-  const std::string& variations_serial_number() const {
-    return variations_serial_number_;
-  }
+  // Returns the serial number of the most recently received seed, or an empty
+  // string if there is no seed (or if it could not be read).
+  // Side-effect: If there is a failure while attempting to read the latest seed
+  // from prefs, clears the prefs associated with the seed.
+  // Efficiency note: If code will eventually need to load the latest seed, it's
+  // more efficient to call LoadSeed() prior to calling this method.
+  const std::string& GetLatestSerialNumber();
 
   // Registers Local State prefs used by this class.
   static void RegisterPrefs(PrefRegistrySimple* registry);
@@ -155,7 +158,7 @@
   PrefService* local_state_;
 
   // Cached serial number from the most recently fetched variations seed.
-  std::string variations_serial_number_;
+  std::string latest_serial_number_;
 
   DISALLOW_COPY_AND_ASSIGN(VariationsSeedStore);
 };