michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsICacheStorage; michael@0: interface nsILoadContextInfo; michael@0: interface nsIApplicationCache; michael@0: interface nsIEventTarget; michael@0: interface nsICacheStorageConsumptionObserver; michael@0: michael@0: /** michael@0: * Provides access to particual cache storages of the network URI cache. michael@0: */ michael@0: [scriptable, uuid(44de2fa4-1b0e-4cd3-9e32-211e936f721e)] michael@0: interface nsICacheStorageService : nsISupports michael@0: { michael@0: /** michael@0: * Get storage where entries will only remain in memory, never written michael@0: * to the disk. michael@0: * michael@0: * @param aLoadContextInfo michael@0: * Information about the loading context, this focuses the storage JAR and michael@0: * respects separate storage for private browsing. michael@0: */ michael@0: nsICacheStorage memoryCacheStorage(in nsILoadContextInfo aLoadContextInfo); michael@0: michael@0: /** michael@0: * Get storage where entries will be written to disk when not forbidden by michael@0: * response headers. michael@0: * michael@0: * @param aLookupAppCache michael@0: * When set true (for top level document loading channels) app cache will michael@0: * be first to check on to find entries in. michael@0: */ michael@0: nsICacheStorage diskCacheStorage(in nsILoadContextInfo aLoadContextInfo, michael@0: in bool aLookupAppCache); michael@0: michael@0: /** michael@0: * Get storage for a specified application cache obtained using some different michael@0: * mechanism. michael@0: * michael@0: * @param aLoadContextInfo michael@0: * Mandatory reference to a load context information. michael@0: * @param aApplicationCache michael@0: * Optional reference to an existing appcache. When left null, this will michael@0: * work with offline cache as a whole. michael@0: */ michael@0: nsICacheStorage appCacheStorage(in nsILoadContextInfo aLoadContextInfo, michael@0: in nsIApplicationCache aApplicationCache); michael@0: michael@0: /** michael@0: * Evict the whole cache. michael@0: */ michael@0: void clear(); michael@0: michael@0: /** michael@0: * Purge only data of disk backed entries. Metadata are left for michael@0: * performance purposes. michael@0: */ michael@0: const uint32_t PURGE_DISK_DATA_ONLY = 1; michael@0: /** michael@0: * Purge whole disk backed entries from memory. Disk files will michael@0: * be left unattended. michael@0: */ michael@0: const uint32_t PURGE_DISK_ALL = 2; michael@0: /** michael@0: * Purge all entries we keep in memory, including memory-storage michael@0: * entries. This may be dangerous to use. michael@0: */ michael@0: const uint32_t PURGE_EVERYTHING = 3; michael@0: /** michael@0: * Purges data we keep warmed in memory. Use for tests and for michael@0: * saving memory. michael@0: */ michael@0: void purgeFromMemory(in uint32_t aWhat); michael@0: michael@0: /** michael@0: * I/O thread target to use for any operations on disk michael@0: */ michael@0: readonly attribute nsIEventTarget ioTarget; michael@0: michael@0: /** michael@0: * Asynchronously determine how many bytes of the disk space the cache takes. michael@0: * @see nsICacheStorageConsumptionObserver michael@0: * @param aObserver michael@0: * A mandatory (weak referred) observer. Documented at michael@0: * nsICacheStorageConsumptionObserver. michael@0: * NOTE: the observer MUST implement nsISupportsWeakReference. michael@0: */ michael@0: void asyncGetDiskConsumption(in nsICacheStorageConsumptionObserver aObserver); michael@0: }; michael@0: michael@0: [scriptable, uuid(7728ab5b-4c01-4483-a606-32bf5b8136cb)] michael@0: interface nsICacheStorageConsumptionObserver : nsISupports michael@0: { michael@0: /** michael@0: * Callback invoked to answer asyncGetDiskConsumption call. Always triggered michael@0: * on the main thread. michael@0: * NOTE: implementers must also implement nsISupportsWeakReference. michael@0: * michael@0: * @param aDiskSize michael@0: * The disk consumption in bytes. michael@0: */ michael@0: void onNetworkCacheDiskConsumption(in int64_t aDiskSize); michael@0: };