summaryrefslogtreecommitdiffstats
path: root/netwerk/cache/nsICacheService.idl
blob: b015a7244af81bf7fa05c39e3cbf6460bf12ba52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* -*- 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;

/**
 * @deprecated
 *
 * IMPORTANT NOTE: THIS INTERFACE IS NO LONGER SUPPORTED AND PLANNED TO BE
 * REMOVED SOON. WE STRONGLY ENCORAGE TO MIGRATE THE EXISTING CODE AND FOR
 * THE NEW CODE USE ONLY THE NEW HTTP CACHE API IN netwerk/cache2/.
 */
[scriptable, uuid(14dbe1e9-f3bc-45af-92f4-2c574fcd4e39)]
interface nsICacheService : nsISupports
{
    /**
     * @throws NS_ERROR_NOT_IMPLEMENTED when the cache v2 is prefered to use.
     *
     * 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);

    /**
     * @throws NS_ERROR_NOT_IMPLEMENTED when the cache v2 is prefered to use.
     *
     * Visit entries stored in the cache.  Used to implement about:cache.
     */
    void visitEntries(in nsICacheVisitor visitor);

    /**
     * @throws NS_ERROR_NOT_IMPLEMENTED when the cache v2 is prefered to use.
     *
     * 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"
%}

[scriptable, builtinclass, uuid(d0fc8d38-db80-4928-bf1c-b0085ddfa9dc)]
interface nsICacheServiceInternal : nsICacheService
{
    /**
     * This is an internal interface. It changes so frequently that it probably
     * went away while you were reading this.
     */

    /**
     * Milliseconds for which the service lock has been held. 0 if unlocked.
     */
    readonly attribute double lockHeldTime;
};