1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/cache2/nsICacheStorageService.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "nsISupports.idl" 1.9 + 1.10 +interface nsICacheStorage; 1.11 +interface nsILoadContextInfo; 1.12 +interface nsIApplicationCache; 1.13 +interface nsIEventTarget; 1.14 +interface nsICacheStorageConsumptionObserver; 1.15 + 1.16 +/** 1.17 + * Provides access to particual cache storages of the network URI cache. 1.18 + */ 1.19 +[scriptable, uuid(44de2fa4-1b0e-4cd3-9e32-211e936f721e)] 1.20 +interface nsICacheStorageService : nsISupports 1.21 +{ 1.22 + /** 1.23 + * Get storage where entries will only remain in memory, never written 1.24 + * to the disk. 1.25 + * 1.26 + * @param aLoadContextInfo 1.27 + * Information about the loading context, this focuses the storage JAR and 1.28 + * respects separate storage for private browsing. 1.29 + */ 1.30 + nsICacheStorage memoryCacheStorage(in nsILoadContextInfo aLoadContextInfo); 1.31 + 1.32 + /** 1.33 + * Get storage where entries will be written to disk when not forbidden by 1.34 + * response headers. 1.35 + * 1.36 + * @param aLookupAppCache 1.37 + * When set true (for top level document loading channels) app cache will 1.38 + * be first to check on to find entries in. 1.39 + */ 1.40 + nsICacheStorage diskCacheStorage(in nsILoadContextInfo aLoadContextInfo, 1.41 + in bool aLookupAppCache); 1.42 + 1.43 + /** 1.44 + * Get storage for a specified application cache obtained using some different 1.45 + * mechanism. 1.46 + * 1.47 + * @param aLoadContextInfo 1.48 + * Mandatory reference to a load context information. 1.49 + * @param aApplicationCache 1.50 + * Optional reference to an existing appcache. When left null, this will 1.51 + * work with offline cache as a whole. 1.52 + */ 1.53 + nsICacheStorage appCacheStorage(in nsILoadContextInfo aLoadContextInfo, 1.54 + in nsIApplicationCache aApplicationCache); 1.55 + 1.56 + /** 1.57 + * Evict the whole cache. 1.58 + */ 1.59 + void clear(); 1.60 + 1.61 + /** 1.62 + * Purge only data of disk backed entries. Metadata are left for 1.63 + * performance purposes. 1.64 + */ 1.65 + const uint32_t PURGE_DISK_DATA_ONLY = 1; 1.66 + /** 1.67 + * Purge whole disk backed entries from memory. Disk files will 1.68 + * be left unattended. 1.69 + */ 1.70 + const uint32_t PURGE_DISK_ALL = 2; 1.71 + /** 1.72 + * Purge all entries we keep in memory, including memory-storage 1.73 + * entries. This may be dangerous to use. 1.74 + */ 1.75 + const uint32_t PURGE_EVERYTHING = 3; 1.76 + /** 1.77 + * Purges data we keep warmed in memory. Use for tests and for 1.78 + * saving memory. 1.79 + */ 1.80 + void purgeFromMemory(in uint32_t aWhat); 1.81 + 1.82 + /** 1.83 + * I/O thread target to use for any operations on disk 1.84 + */ 1.85 + readonly attribute nsIEventTarget ioTarget; 1.86 + 1.87 + /** 1.88 + * Asynchronously determine how many bytes of the disk space the cache takes. 1.89 + * @see nsICacheStorageConsumptionObserver 1.90 + * @param aObserver 1.91 + * A mandatory (weak referred) observer. Documented at 1.92 + * nsICacheStorageConsumptionObserver. 1.93 + * NOTE: the observer MUST implement nsISupportsWeakReference. 1.94 + */ 1.95 + void asyncGetDiskConsumption(in nsICacheStorageConsumptionObserver aObserver); 1.96 +}; 1.97 + 1.98 +[scriptable, uuid(7728ab5b-4c01-4483-a606-32bf5b8136cb)] 1.99 +interface nsICacheStorageConsumptionObserver : nsISupports 1.100 +{ 1.101 + /** 1.102 + * Callback invoked to answer asyncGetDiskConsumption call. Always triggered 1.103 + * on the main thread. 1.104 + * NOTE: implementers must also implement nsISupportsWeakReference. 1.105 + * 1.106 + * @param aDiskSize 1.107 + * The disk consumption in bytes. 1.108 + */ 1.109 + void onNetworkCacheDiskConsumption(in int64_t aDiskSize); 1.110 +};