mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-06 22:25:46 +01:00
Update :pageinfo to use the new HTTP cache API.
This commit is contained in:
@@ -2661,25 +2661,22 @@ Buffer.addPageInfoSection("g", "General Info", function (verbose) {
|
|||||||
let doc = this.focusedFrame.document;
|
let doc = this.focusedFrame.document;
|
||||||
|
|
||||||
// get file size
|
// get file size
|
||||||
const ACCESS_READ = Ci.nsICache.ACCESS_READ;
|
let { LoadContextInfo } = Cu.import("resource://gre/modules/LoadContextInfo.jsm", {});
|
||||||
let cacheKey = doc.documentURI;
|
let contextInfo = LoadContextInfo.fromLoadContext(sanitizer.getContext(doc), false);
|
||||||
|
let storage = services.cache.diskCacheStorage(contextInfo, false);
|
||||||
for (let proto in array.iterValues(["HTTP", "FTP"])) {
|
|
||||||
try {
|
|
||||||
var cacheEntryDescriptor = services.cache.createSession(proto, 0, true)
|
|
||||||
.openCacheEntry(cacheKey, ACCESS_READ, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let pageSize = []; // [0] bytes; [1] kbytes
|
let pageSize = []; // [0] bytes; [1] kbytes
|
||||||
if (cacheEntryDescriptor) {
|
|
||||||
pageSize[0] = util.formatBytes(cacheEntryDescriptor.dataSize, 0, false);
|
storage.asyncOpenURI(util.createURI(doc.documentURI), "",
|
||||||
pageSize[1] = util.formatBytes(cacheEntryDescriptor.dataSize, 2, true);
|
Ci.nsICacheStorage.OPEN_NORMALLY,
|
||||||
if (pageSize[1] == pageSize[0])
|
{
|
||||||
pageSize.length = 1; // don't output "xx Bytes" twice
|
onCacheEntryCheck: () => Ci.nsICacheEntryOpenCallback.ENTRY_WANTED,
|
||||||
}
|
onCacheEntryAvailable: entry => {
|
||||||
|
pageSize[0] = util.formatBytes(entry.dataSize, 0, false);
|
||||||
|
pageSize[1] = util.formatBytes(entry.dataSize, 2, true);
|
||||||
|
if (pageSize[1] == pageSize[0])
|
||||||
|
pageSize.length = 1; // don't output "xx Bytes" twice
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let lastModVerbose = new Date(doc.lastModified).toLocaleString();
|
let lastModVerbose = new Date(doc.lastModified).toLocaleString();
|
||||||
let lastMod = new Date(doc.lastModified).toLocaleFormat("%x %X");
|
let lastMod = new Date(doc.lastModified).toLocaleFormat("%x %X");
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ var Services = Module("Services", {
|
|||||||
this.add("appStartup", "@mozilla.org/toolkit/app-startup;1", "nsIAppStartup");
|
this.add("appStartup", "@mozilla.org/toolkit/app-startup;1", "nsIAppStartup");
|
||||||
this.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService");
|
this.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService");
|
||||||
this.add("browserSearch", "@mozilla.org/browser/search-service;1", "nsIBrowserSearchService");
|
this.add("browserSearch", "@mozilla.org/browser/search-service;1", "nsIBrowserSearchService");
|
||||||
this.add("cache", "@mozilla.org/network/cache-service;1", "nsICacheService");
|
this.add("cache", "@mozilla.org/netwerk/cache-storage-service;1", "nsICacheStorageService");
|
||||||
this.add("chromeRegistry", "@mozilla.org/chrome/chrome-registry;1", "nsIXULChromeRegistry");
|
this.add("chromeRegistry", "@mozilla.org/chrome/chrome-registry;1", "nsIXULChromeRegistry");
|
||||||
this.add("clipboard", "@mozilla.org/widget/clipboard;1", "nsIClipboard");
|
this.add("clipboard", "@mozilla.org/widget/clipboard;1", "nsIClipboard");
|
||||||
this.add("clipboardHelper", "@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper");
|
this.add("clipboardHelper", "@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper");
|
||||||
|
|||||||
Reference in New Issue
Block a user