[not part of build] Tests cache visitation API.

This commit is contained in:
beard%netscape.com 2001-03-09 18:59:53 +00:00
parent 1ec94db8a7
commit 0313a7eb10

View File

@ -0,0 +1,54 @@
var DEBUG = true;
var clientID = "javascript";
var nsICache = Components.interfaces.nsICache;
function getCacheService()
{
var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"];
var service = nsCacheService.getService(Components.interfaces.nsICacheService);
return service;
}
function CacheVisitor()
{
}
CacheVisitor.prototype = {
QueryInterface : function(iid)
{
if (iid.equals(Components.interfaces.nsICacheVisitor))
return this;
throw Components.results.NS_NOINTERFACE;
},
visitDevice : function(deviceID, deviceInfo)
{
print("[visiting device (deviceID = " + deviceID + ", description = " + deviceInfo.description + ")]");
return true;
},
visitEntry : function(deviceID, clientID, entryInfo)
{
print("[visiting entry (clientID = " + clientID + ", key = " + entryInfo.key + ")]");
return true;
}
};
function test()
{
var cacheService = getCacheService();
var visitor = new CacheVisitor();
cacheService.visitEntries(visitor);
}
// load the cache service before doing anything with Java...
getCacheService();
if (DEBUG) {
print("cache service loaded.");
} else {
print("running cache visitor test.");
test();
print("cache visitor test complete.");
}