Bug 901622 - Invalidate ProfileInformationCache by bumping version. r=rnewman, a=bajaj
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 07 Aug 2013 09:28:10 -0700
changeset 149044 f66f82f71f6c91015ebcf448d0f2665e0193c460
parent 149043 551c1859c61a0e82d924385475100393dc6da9a2
child 149045 6a1a48886f7eede0addecdafcf34511b999862ed
push id4129
push userryanvm@gmail.com
push dateThu, 15 Aug 2013 16:48:54 +0000
treeherdermozilla-aurora@f66f82f71f6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, bajaj
bugs901622
milestone25.0a2
Bug 901622 - Invalidate ProfileInformationCache by bumping version. r=rnewman, a=bajaj
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");