|
|
54 |
* Austin Andrews |
54 |
* Austin Andrews |
55 |
* Christoph Dorn |
55 |
* Christoph Dorn |
56 |
* Steven Roussey (AppCenter Inc, Network54) |
56 |
* Steven Roussey (AppCenter Inc, Network54) |
57 |
* Mihai Sucan (Mozilla Corp.) |
57 |
* Mihai Sucan (Mozilla Corp.) |
58 |
*/ |
58 |
*/ |
59 |
|
59 |
|
60 |
"use strict"; |
60 |
"use strict"; |
61 |
|
61 |
|
62 |
const {components, Cc, Ci} = require("chrome"); |
62 |
const {components, Cc, Ci, Cu} = require("chrome"); |
63 |
loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm"); |
63 |
loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm"); |
64 |
const DevToolsUtils = require("devtools/shared/DevToolsUtils"); |
64 |
const DevToolsUtils = require("devtools/shared/DevToolsUtils"); |
65 |
const Services = require("Services"); |
65 |
const Services = require("Services"); |
66 |
const { LocalizationHelper } = require("devtools/shared/l10n"); |
66 |
const { LocalizationHelper } = require("devtools/shared/l10n"); |
67 |
const L10N = new LocalizationHelper("devtools/client/locales/netmonitor.properties"); |
67 |
const L10N = new LocalizationHelper("devtools/client/locales/netmonitor.properties"); |
68 |
|
68 |
|
69 |
// The cache used in the `nsIURL` function. |
69 |
// The cache used in the `nsIURL` function. |
70 |
const gNSURLStore = new Map(); |
70 |
const gNSURLStore = new Map(); |
|
499 |
case "svg": |
499 |
case "svg": |
500 |
case "xml": |
500 |
case "xml": |
501 |
return true; |
501 |
return true; |
502 |
|
502 |
|
503 |
default: |
503 |
default: |
504 |
return false; |
504 |
return false; |
505 |
} |
505 |
} |
506 |
}, |
506 |
}, |
|
|
507 |
/** |
508 |
* Gets a cache entry for a request. |
509 |
* |
510 |
* @param Object request |
511 |
* @param Object response |
512 |
* @param Function onCacheDescriptorAvailable |
513 |
*/ |
514 |
getCacheEntry: function(request, response, onCacheDescriptorAvailable) { |
515 |
let CacheService = Cc["@mozilla.org/network/cache-service;1"]; |
516 |
let CacheStorageService = Cc["@mozilla.org/network/cache-storage-service;1"]; |
517 |
if (CacheStorageService) { |
518 |
let cacheService = CacheStorageService.getService(Ci.nsICacheStorageService); |
519 |
let loadContext = Services.loadContextInfo.default; |
520 |
let cacheSession = cacheService.diskCacheStorage(loadContext, false); |
521 |
cacheSession.asyncOpenURI(this.nsIURL(request.URI.spec), "", Ci.nsICacheStorage.OPEN_NORMALLY, |
522 |
{ |
523 |
onCacheEntryCheck: function(entry, appcache) { |
524 |
return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED; |
525 |
}, |
526 |
onCacheEntryAvailable: function(descriptor, isnew, appcache, status) { |
527 |
if (descriptor) { |
528 |
let cdescriptor = { |
529 |
dataSize: descriptor.storageDataSize, |
530 |
expires: descriptor.expirationTime, |
531 |
fetchCount: descriptor.fetchCount, |
532 |
lastFetched: descriptor.lastFetched, |
533 |
lastModified: descriptor.lastModified, |
534 |
}; |
535 |
if (descriptor.deviceID) { |
536 |
cdescriptor["device"] = descriptor.deviceID; |
537 |
} |
538 |
onCacheDescriptorAvailable(cdescriptor); |
539 |
} else { |
540 |
onCacheDescriptorAvailable(null); |
541 |
} |
542 |
|
543 |
}, |
544 |
}); |
545 |
} else { // CacheStorageService does not exist. |
546 |
let oldICache = Ci["ns" + "ICache"]; |
547 |
let cacheService = CacheService.getService(Ci.nsICacheService); |
548 |
let cacheSession = cacheService.createSession("HTTP", oldICache.STORE_ANYWHERE, true); |
549 |
|
550 |
cacheSession.asyncOpenCacheEntry(this.nsIURL(request.URI.spec), oldICache.ACCESS_READ, { |
551 |
onCacheEntryAvailable: function(descriptor, accessGranted, status) { |
552 |
if (descriptor) { |
553 |
let cdescriptor = { |
554 |
dataSize: descriptor.storageDataSize, |
555 |
expires: descriptor.expirationTime, |
556 |
fetchCount: descriptor.fetchCount, |
557 |
lastFetched: descriptor.lastFetched, |
558 |
lastModified: descriptor.lastModified, |
559 |
}; |
560 |
if (descriptor.deviceID) { |
561 |
cdescriptor["device"] = descriptor.deviceID; |
562 |
} |
563 |
onCacheDescriptorAvailable(cdescriptor); |
564 |
} else { |
565 |
onCacheDescriptorAvailable(null); |
566 |
} |
567 |
} |
568 |
}) |
569 |
} |
570 |
}, |
507 |
|
571 |
|
508 |
/** |
572 |
/** |
509 |
* Takes a securityInfo object of nsIRequest, the nsIRequest itself and |
573 |
* Takes a securityInfo object of nsIRequest, the nsIRequest itself and |
510 |
* extracts security information from them. |
574 |
* extracts security information from them. |
511 |
* |
575 |
* |
512 |
* @param object securityInfo |
576 |
* @param object securityInfo |
513 |
* The securityInfo object of a request. If null channel is assumed |
577 |
* The securityInfo object of a request. If null channel is assumed |
514 |
* to be insecure. |
578 |
* to be insecure. |