Bug 901622 - Invalidate ProfileInformationCache by bumping version. r=rnewman
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 07 Aug 2013 09:28:10 -0700
changeset 141666 3c188512a17c71e33b1c2eaa47ecb760b8ba00ab
parent 141665 74f983165c02cd0fca42412157d080d443f42671
child 141667 85c1aed7e525f5dad8d52775e203f099ea2c72ed
push id25068
push useremorley@mozilla.com
push dateWed, 07 Aug 2013 23:17:15 +0000
treeherdermozilla-central@45128af17739 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs901622
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 901622 - Invalidate ProfileInformationCache by bumping version. r=rnewman
mobile/android/base/background/healthreport/ProfileInformationCache.java
--- a/mobile/android/base/background/healthreport/ProfileInformationCache.java
+++ b/mobile/android/base/background/healthreport/ProfileInformationCache.java
@@ -21,17 +21,24 @@ import org.mozilla.gecko.background.heal
  * There are some parts of the FHR environment that can't be readily computed
  * without a running Gecko -- add-ons, for example. In order to make this
  * information available without launching Gecko, we persist it on Fennec
  * startup. This class is the notepad in which we write.
  */
 public class ProfileInformationCache implements ProfileInformationProvider {
   private static final String LOG_TAG = "GeckoProfileInfo";
   private static final String CACHE_FILE = "profile_info_cache.json";
-  public static final int FORMAT_VERSION = 1;
+
+  /*
+   * FORMAT_VERSION history:
+   *   -: No version number; implicit v1.
+   *   1: Add versioning (Bug 878670).
+   *   2: Bump to regenerate add-on set after landing Bug 900694 (Bug 901622).
+   */
+  public static final int FORMAT_VERSION = 2;
 
   protected boolean initialized = false;
   protected boolean needsWrite = false;
 
   protected final File file;
 
   private volatile boolean blocklistEnabled = true;
   private volatile boolean telemetryEnabled = false;
@@ -61,17 +68,20 @@ public class ProfileInformationCache imp
       // There isn't much we can do about this.
       // Let's just quietly muffle.
       return null;
     }
     return object;
   }
 
   /**
-   * Attempt to restore this object from a JSON blob.
+   * Attempt to restore this object from a JSON blob. If there is a version mismatch, there has
+   * likely been an upgrade to the cache format. The cache can be reconstructed without data loss
+   * so rather than migrating, we invalidate the cache by refusing to store the given JSONObject
+   * and returning false.
    *
    * @return false if there's a version mismatch or an error, true on success.
    */
   private boolean fromJSON(JSONObject object) throws JSONException {
     int version = object.optInt("version", 1);
     switch (version) {
     case FORMAT_VERSION:
       blocklistEnabled = object.getBoolean("blocklist");