Bug 1002383 - Mark fallback cache entries correctly. r=ochameau
authorFredrik Lanker <fredrik.lanker@sonymobile.com>
Mon, 28 Apr 2014 02:20:00 +0200
changeset 181175 a4747f7827a9bef5f8b50dfce29214526fce280c
parent 181174 c32223e0b1051fde113ee3c97b773520957541e2
child 181176 3608f5b12dc896d45484abc493525eda5b030289
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersochameau
bugs1002383
milestone32.0a1
Bug 1002383 - Mark fallback cache entries correctly. r=ochameau storeCache is async, so at the time markEntry was run for fallback items, the cache entry might not exist yet which led to that the fallback entries were not properly marked. Instead, we now send the proper type directly to storeCache.
dom/apps/src/OfflineCacheInstaller.jsm
--- a/dom/apps/src/OfflineCacheInstaller.jsm
+++ b/dom/apps/src/OfflineCacheInstaller.jsm
@@ -233,32 +233,30 @@ function installCache(app) {
 
       if (!file.exists()) {
         let msg = 'File ' + file.path + ' exists in the manifest but does ' +
                   'not points to a real file.';
         throw new Error(msg);
       }
 
       let itemType = nsIApplicationCache.ITEM_EXPLICIT;
+      if (entries.fallbacks.indexOf(url) > -1) {
+        debug('add fallback: ' + url + '\n');
+        itemType |= nsIApplicationCache.ITEM_FALLBACK;
+      }
       storeCache(applicationCache, url, file, itemType);
     });
 
     let array = new MutableArray();
     entries.namespaces.forEach(function processNamespace([type, spec, data]) {
       debug('add namespace: ' + type + ' - ' + spec + ' - ' + data + '\n');
       array.appendElement(new Namespace(type, spec, data), false);
     });
     applicationCache.addNamespaces(array);
 
-    entries.fallbacks.forEach(function processFallback(url) {
-      debug('add fallback: ' + url + '\n');
-      let type = nsIApplicationCache.ITEM_FALLBACK;
-      applicationCache.markEntry(url, type);
-    });
-
     storeCache(applicationCache, appcacheURL, cacheManifest,
                nsIApplicationCache.ITEM_MANIFEST);
   });
 }
 
 
 // Public API