netwerk/cache/nsICacheService.idl
author Mike Hommey <mh+mozilla@glandium.org>
Fri, 04 Jan 2013 17:14:33 +0100
changeset 117619 0d1a01e16ce73ce3ead6744ce66abdc5ded8f2dd
parent 94475 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 131698 e1eb29a56dab37ba0fe5e7f8f2eb778ae772c88d
permissions -rw-r--r--
Backout changeset 6656cdc8b20d (bug 824330) because of android and b2g bustage on clobber builds

/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsICache.idl"

interface nsISimpleEnumerator;
interface nsICacheListener;
interface nsICacheSession;
interface nsICacheVisitor;
interface nsIEventTarget;

[scriptable, uuid(14dbe1e9-f3bc-45af-92f4-2c574fcd4e39)]
interface nsICacheService : nsISupports
{
    /**
     * Create a cache session
     *
     * A cache session represents a client's access into the cache.  The cache
     * session is not "owned" by the cache service.  Hence, it is possible to
     * create duplicate cache sessions.  Entries created by a cache session
     * are invisible to other cache sessions, unless the cache sessions are
     * equivalent.
     *
     * @param clientID - Specifies the name of the client using the cache.
     * @param storagePolicy - Limits the storage policy for all entries
     *   accessed via the returned session.  As a result, devices excluded
     *   by the storage policy will not be searched when opening entries
     *   from the returned session.
     * @param streamBased - Indicates whether or not the data being cached
     *   can be represented as a stream.  The storagePolicy must be 
     *   consistent with the value of this field.  For example, a non-stream-
     *   based cache entry can only have a storage policy of STORE_IN_MEMORY.
     * @return new cache session.
     */
    nsICacheSession createSession(in string                 clientID,
                                  in nsCacheStoragePolicy   storagePolicy,
                                  in boolean                streamBased);

    /**
     * Visit entries stored in the cache.  Used to implement about:cache.
     */
    void visitEntries(in nsICacheVisitor visitor);

    /**
     * Evicts all entries in all devices implied by the storage policy.
     *
     * @note This function may evict some items but will throw if it fails to evict
     *       everything.
     */
    void evictEntries(in nsCacheStoragePolicy  storagePolicy);

    /**
     * Event target which is used for I/O operations
     */
    readonly attribute nsIEventTarget cacheIOTarget;
};

%{C++
/**
 * Observer service notification that is sent when
 * nsICacheService::evictEntries() or nsICacheSession::evictEntries()
 * is called.
 */
#define NS_CACHESERVICE_EMPTYCACHE_TOPIC_ID "cacheservice:empty-cache"
%}