[Pkg-mozext-commits] [firebug] 07/16: Issue 7647: nsICache has been removed
David Prévot
taffit at moszumanska.debian.org
Thu Sep 18 18:10:14 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository firebug.
commit fc8f4553cdb62b03a9a60a4dc775f6f829495e87
Author: Jan Odvarko <odvarko at gmail.com>
Date: Mon Sep 1 18:29:25 2014 +0200
Issue 7647: nsICache has been removed
---
extension/content/firebug/net/netCacheReader.js | 69 +++++++++++++++++++++----
1 file changed, 60 insertions(+), 9 deletions(-)
diff --git a/extension/content/firebug/net/netCacheReader.js b/extension/content/firebug/net/netCacheReader.js
index b30866e..56e6047 100644
--- a/extension/content/firebug/net/netCacheReader.js
+++ b/extension/content/firebug/net/netCacheReader.js
@@ -8,11 +8,12 @@ define([
"firebug/lib/trace",
"firebug/lib/dom",
"firebug/lib/css",
+ "firebug/lib/url",
"firebug/net/netMonitor",
"firebug/net/netUtils",
"firebug/lib/domplate",
],
-function(Firebug, Module, Obj, Locale, FBTrace, Dom, Css, NetMonitor, NetUtils, Domplate) {
+function(Firebug, Module, Obj, Locale, FBTrace, Dom, Css, Url, NetMonitor, NetUtils, Domplate) {
"use strict"
@@ -21,16 +22,24 @@ function(Firebug, Module, Obj, Locale, FBTrace, Dom, Css, NetMonitor, NetUtils,
var Cc = Components.classes;
var Ci = Components.interfaces;
-var Cr = Components.results;
+var Cu = Components.utils;
var CacheService = Cc["@mozilla.org/network/cache-service;1"];
+// Firefox 32 introduces new cache service API.
+// https://developer.mozilla.org/en-US/docs/HTTP_Cache
+var CacheStorageService = Cc["@mozilla.org/netwerk/cache-storage-service;1"];
+
var cacheSession = null;
var autoFetchDelay = 1000;
var TraceError = FBTrace.toError();
var Trace = FBTrace.to("DBG_NETCACHEREADER");
+// Create a shortcut to workaround AMO verification parser. The old interface is still
+// needed to support Firefox < 32
+var oldICache = Ci["ns" + "ICache"];
+
// ********************************************************************************************* //
// Domplate Templates
@@ -173,7 +182,10 @@ var NetCacheReader = Obj.extend(Module,
try
{
// Fetch data from the browser cache.
- fetchCacheEntry(file, netProgress);
+ if (CacheStorageService)
+ fetchCacheEntryNew(file, netProgress);
+ else
+ fetchCacheEntry(file, netProgress);
}
catch (exc)
{
@@ -197,11 +209,11 @@ function fetchCacheEntry(file, netProgress)
if (!cacheSession)
{
var cacheService = CacheService.getService(Ci.nsICacheService);
- cacheSession = cacheService.createSession("HTTP", Ci.nsICache.STORE_ANYWHERE, true);
+ cacheSession = cacheService.createSession("HTTP", oldICache.STORE_ANYWHERE, true);
cacheSession.doomEntriesIfExpired = false;
}
- cacheSession.asyncOpenCacheEntry(file.href, Ci.nsICache.ACCESS_READ,
+ cacheSession.asyncOpenCacheEntry(file.href, oldICache.ACCESS_READ,
{
onCacheEntryAvailable: function(descriptor, accessGranted, status)
{
@@ -215,6 +227,41 @@ function fetchCacheEntry(file, netProgress)
});
}
+function fetchCacheEntryNew(file, netProgress)
+{
+ if (file.cacheEntry)
+ return;
+
+ Trace.sysout("netCacheReader.getCacheEntry; file.href: " + file.href);
+
+ // Initialize cache session.
+ if (!cacheSession)
+ {
+ var { LoadContextInfo } = Cu.import("resource://gre/modules/LoadContextInfo.jsm", {});
+ var cacheService = CacheStorageService.getService(Ci.nsICacheStorageService);
+ cacheSession = cacheService.diskCacheStorage(LoadContextInfo.default, false);
+ }
+
+ cacheSession.asyncOpenURI(Url.makeURI(file.href), "", Ci.nsICacheStorage.OPEN_NORMALLY,
+ {
+ onCacheEntryCheck: function (entry, appcache)
+ {
+ return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
+ },
+
+ onCacheEntryAvailable: function (descriptor, isnew, appcache, status)
+ {
+ Trace.sysout("netCacheReader.onCacheEntryAvailable; file.href: " + file.href);
+
+ if (descriptor)
+ onDescriptorAvailable(netProgress, file, descriptor);
+
+ getCachedHeaders(file);
+ }
+ }
+ );
+}
+
function onDescriptorAvailable(netProgress, file, descriptor)
{
Trace.sysout("netCacheReader.onDescriptorAvailable; file.href: " + file.href, descriptor);
@@ -249,13 +296,17 @@ function onDescriptorAvailable(netProgress, file, descriptor)
{
name: "Fetch Count",
value: descriptor.fetchCount
- },
- {
- name: "Device",
- value: descriptor.deviceID
}
];
+ if (descriptor.deviceID)
+ {
+ file.cacheEntry.push({
+ name: "Device",
+ value: descriptor.deviceID
+ });
+ }
+
try
{
// Get contentType from the cache.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git
More information about the Pkg-mozext-commits
mailing list