summaryrefslogtreecommitdiffstats
path: root/netwerk/cache/nsICacheSession.idl
blob: e2a4dec5bd7aa0e6e52ac185844e6c9df6f3d289 (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
/* -*- 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 nsICacheEntryDescriptor;
interface nsICacheListener;
interface nsIFile;

[scriptable, uuid(1dd7708c-de48-4ffe-b5aa-cd218c762887)]
interface nsICacheSession : nsISupports
{
    /**
     * Expired entries will be doomed or evicted if this attribute is set to
     * true.  If false, expired entries will be returned (useful for offline-
     * mode and clients, such as HTTP, that can update the valid lifetime of
     * cached content).  This attribute defaults to true.
     */
    attribute boolean doomEntriesIfExpired;

    /**
     * When set, entries created with this session will be placed to a cache
     * based at this directory.  Use when storing entries to a different
     * profile than the active profile of the the current running application
     * process.
     */
    attribute nsIFile profileDirectory;

    /**
     * A cache session can only give out one descriptor with WRITE access
     * to a given cache entry at a time.  Until the client calls MarkValid on
     * its descriptor, other attempts to open the same cache entry will block.
     */

    /**
     * Synchronous cache access. This method fails if it is called on the main
     * thread. Use asyncOpenCacheEntry() instead. This returns a unique
     * descriptor each time it is called, even if the same key is specified.
     * When called by multiple threads for write access, only one writable
     * descriptor will be granted.  If 'blockingMode' is set to false, it will
     * return NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than block when another
     * descriptor has been given WRITE access but hasn't validated the entry yet.
     */
    nsICacheEntryDescriptor openCacheEntry(in ACString          key,
                                           in nsCacheAccessMode accessRequested,
                                           in boolean           blockingMode);

    /**
     * Asynchronous cache access. Does not block the calling thread. Instead,
     * the listener will be notified when the descriptor is available. If
     * 'noWait' is set to true, the listener will be notified immediately with
     * status NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than queuing the request
     * when another descriptor has been given WRITE access but hasn't validated
     * the entry yet.
     */
    void asyncOpenCacheEntry(in ACString           key,
                             in nsCacheAccessMode  accessRequested,
                             in nsICacheListener   listener,
                             [optional] in boolean noWait);

    /**
     * Evict all entries for this session's clientID according to its storagePolicy.
     */
    void evictEntries();
    
    /**
     * Return whether any of the cache devices implied by the session storage policy
     * are currently enabled for instantiation if they don't already exist.
     */
    boolean isStorageEnabled();

    /**
     * Asynchronously doom an entry specified by the key. Listener will be
     * notified about the status of the operation. Null may be passed if caller
     * doesn't care about the result.
     */
    void doomEntry(in ACString key, in nsICacheListener listener);

    /**
     * Private entries will be doomed when the last private browsing session
     * finishes.
     */
    attribute boolean isPrivate;
};