michael@0: /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * 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: #include "nsICache.idl" michael@0: michael@0: interface nsICacheEntryDescriptor; michael@0: interface nsICacheListener; michael@0: interface nsIFile; michael@0: michael@0: [scriptable, uuid(1dd7708c-de48-4ffe-b5aa-cd218c762887)] michael@0: interface nsICacheSession : nsISupports michael@0: { michael@0: /** michael@0: * Expired entries will be doomed or evicted if this attribute is set to michael@0: * true. If false, expired entries will be returned (useful for offline- michael@0: * mode and clients, such as HTTP, that can update the valid lifetime of michael@0: * cached content). This attribute defaults to true. michael@0: */ michael@0: attribute boolean doomEntriesIfExpired; michael@0: michael@0: /** michael@0: * When set, entries created with this session will be placed to a cache michael@0: * based at this directory. Use when storing entries to a different michael@0: * profile than the active profile of the the current running application michael@0: * process. michael@0: */ michael@0: attribute nsIFile profileDirectory; michael@0: michael@0: /** michael@0: * A cache session can only give out one descriptor with WRITE access michael@0: * to a given cache entry at a time. Until the client calls MarkValid on michael@0: * its descriptor, other attempts to open the same cache entry will block. michael@0: */ michael@0: michael@0: /** michael@0: * Synchronous cache access. This method fails if it is called on the main michael@0: * thread. Use asyncOpenCacheEntry() instead. This returns a unique michael@0: * descriptor each time it is called, even if the same key is specified. michael@0: * When called by multiple threads for write access, only one writable michael@0: * descriptor will be granted. If 'blockingMode' is set to false, it will michael@0: * return NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than block when another michael@0: * descriptor has been given WRITE access but hasn't validated the entry yet. michael@0: */ michael@0: nsICacheEntryDescriptor openCacheEntry(in ACString key, michael@0: in nsCacheAccessMode accessRequested, michael@0: in boolean blockingMode); michael@0: michael@0: /** michael@0: * Asynchronous cache access. Does not block the calling thread. Instead, michael@0: * the listener will be notified when the descriptor is available. If michael@0: * 'noWait' is set to true, the listener will be notified immediately with michael@0: * status NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than queuing the request michael@0: * when another descriptor has been given WRITE access but hasn't validated michael@0: * the entry yet. michael@0: */ michael@0: void asyncOpenCacheEntry(in ACString key, michael@0: in nsCacheAccessMode accessRequested, michael@0: in nsICacheListener listener, michael@0: [optional] in boolean noWait); michael@0: michael@0: /** michael@0: * Evict all entries for this session's clientID according to its storagePolicy. michael@0: */ michael@0: void evictEntries(); michael@0: michael@0: /** michael@0: * Return whether any of the cache devices implied by the session storage policy michael@0: * are currently enabled for instantiation if they don't already exist. michael@0: */ michael@0: boolean isStorageEnabled(); michael@0: michael@0: /** michael@0: * Asynchronously doom an entry specified by the key. Listener will be michael@0: * notified about the status of the operation. Null may be passed if caller michael@0: * doesn't care about the result. michael@0: */ michael@0: void doomEntry(in ACString key, in nsICacheListener listener); michael@0: michael@0: /** michael@0: * Private entries will be doomed when the last private browsing session michael@0: * finishes. michael@0: */ michael@0: attribute boolean isPrivate; michael@0: };