Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | var DEBUG = true; |
michael@0 | 2 | |
michael@0 | 3 | var clientID = "javascript"; |
michael@0 | 4 | var nsICache = Components.interfaces.nsICache; |
michael@0 | 5 | |
michael@0 | 6 | function getCacheService() |
michael@0 | 7 | { |
michael@0 | 8 | var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"]; |
michael@0 | 9 | var service = nsCacheService.getService(Components.interfaces.nsICacheService); |
michael@0 | 10 | return service; |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | function CacheVisitor() |
michael@0 | 14 | { |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | CacheVisitor.prototype = { |
michael@0 | 18 | QueryInterface : function(iid) |
michael@0 | 19 | { |
michael@0 | 20 | if (iid.equals(Components.interfaces.nsICacheVisitor)) |
michael@0 | 21 | return this; |
michael@0 | 22 | throw Components.results.NS_NOINTERFACE; |
michael@0 | 23 | }, |
michael@0 | 24 | |
michael@0 | 25 | visitDevice : function(deviceID, deviceInfo) |
michael@0 | 26 | { |
michael@0 | 27 | print("[visiting device (deviceID = " + deviceID + ", description = " + deviceInfo.description + ")]"); |
michael@0 | 28 | return true; |
michael@0 | 29 | }, |
michael@0 | 30 | |
michael@0 | 31 | visitEntry : function(deviceID, entryInfo) |
michael@0 | 32 | { |
michael@0 | 33 | print("[visiting entry (clientID = " + entryInfo.clientID + ", key = " + entryInfo.key + ")]"); |
michael@0 | 34 | return true; |
michael@0 | 35 | } |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | function test() |
michael@0 | 39 | { |
michael@0 | 40 | var cacheService = getCacheService(); |
michael@0 | 41 | var visitor = new CacheVisitor(); |
michael@0 | 42 | cacheService.visitEntries(visitor); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | // load the cache service before doing anything with Java... |
michael@0 | 46 | getCacheService(); |
michael@0 | 47 | |
michael@0 | 48 | if (DEBUG) { |
michael@0 | 49 | print("cache service loaded."); |
michael@0 | 50 | } else { |
michael@0 | 51 | print("running cache visitor test."); |
michael@0 | 52 | test(); |
michael@0 | 53 | print("cache visitor test complete."); |
michael@0 | 54 | } |