Source code

Revision control

Other Tools

1
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
*
3
* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "nsISupports.idl"
8
9
interface nsIArray;
10
interface nsIFile;
11
interface nsIURI;
12
13
/**
14
* Application caches can store a set of namespace entries that affect
15
* loads from the application cache. If a load from the cache fails
16
* to match an exact cache entry, namespaces entries will be searched
17
* for a substring match, and should be applied appropriately.
18
*/
19
[scriptable, uuid(96e4c264-2065-4ce9-93bb-43734c62c4eb)]
20
interface nsIApplicationCacheNamespace : nsISupports
21
{
22
/**
23
* Items matching this namespace can be fetched from the network
24
* when loading from this cache. The "data" attribute is unused.
25
*/
26
const unsigned long NAMESPACE_BYPASS = 1 << 0;
27
28
/**
29
* Items matching this namespace can be fetched from the network
30
* when loading from this cache. If the load fails, the cache entry
31
* specified by the "data" attribute should be loaded instead.
32
*/
33
const unsigned long NAMESPACE_FALLBACK = 1 << 1;
34
35
/**
36
* Items matching this namespace should be cached
37
* opportunistically. Successful toplevel loads of documents
38
* in this namespace should be placed in the application cache.
39
* Namespaces specifying NAMESPACE_OPPORTUNISTIC may also specify
40
* NAMESPACE_FALLBACK to supply a fallback entry.
41
*/
42
const unsigned long NAMESPACE_OPPORTUNISTIC = 1 << 2;
43
44
/**
45
* Initialize the namespace.
46
*/
47
void init(in unsigned long itemType,
48
in ACString namespaceSpec,
49
in ACString data);
50
51
/**
52
* The namespace type.
53
*/
54
readonly attribute unsigned long itemType;
55
56
/**
57
* The prefix of this namespace. This should be the asciiSpec of the
58
* URI prefix.
59
*/
60
readonly attribute ACString namespaceSpec;
61
62
/**
63
* Data associated with this namespace, such as a fallback. URI data should
64
* use the asciiSpec of the URI.
65
*/
66
readonly attribute ACString data;
67
};
68
69
/**
70
* Application caches store resources for offline use. Each
71
* application cache has a unique client ID for use with
72
* nsICacheService::openSession() to access the cache's entries.
73
*
74
* Each entry in the application cache can be marked with a set of
75
* types, as discussed in the WHAT-WG offline applications
76
* specification.
77
*
78
* All application caches with the same group ID belong to a cache
79
* group. Each group has one "active" cache that will service future
80
* loads. Inactive caches will be removed from the cache when they are
81
* no longer referenced.
82
*/
83
[scriptable, uuid(06568DAE-C374-4383-A122-0CC96C7177F2)]
84
interface nsIApplicationCache : nsISupports
85
{
86
/**
87
* Init this application cache instance to just hold the group ID and
88
* the client ID to work just as a handle to the real cache. Used on
89
* content process to simplify the application cache code.
90
*/
91
void initAsHandle(in ACString groupId, in ACString clientId);
92
93
/**
94
* Entries in an application cache can be marked as one or more of
95
* the following types.
96
*/
97
98
/* This item is the application manifest. */
99
const unsigned long ITEM_MANIFEST = 1 << 0;
100
101
/* This item was explicitly listed in the application manifest. */
102
const unsigned long ITEM_EXPLICIT = 1 << 1;
103
104
/* This item was navigated in a toplevel browsing context, and
105
* named this cache's group as its manifest. */
106
const unsigned long ITEM_IMPLICIT = 1 << 2;
107
108
/* This item was added by the dynamic scripting API */
109
const unsigned long ITEM_DYNAMIC = 1 << 3;
110
111
/* This item was listed in the application manifest, but named a
112
* different cache group as its manifest. */
113
const unsigned long ITEM_FOREIGN = 1 << 4;
114
115
/* This item was listed as a fallback entry. */
116
const unsigned long ITEM_FALLBACK = 1 << 5;
117
118
/* This item matched an opportunistic cache namespace and was
119
* cached accordingly. */
120
const unsigned long ITEM_OPPORTUNISTIC = 1 << 6;
121
122
/**
123
* URI of the manfiest specifying this application cache.
124
**/
125
readonly attribute nsIURI manifestURI;
126
127
/**
128
* The group ID for this cache group. It is an internally generated string
129
* and cannot be used as manifest URL spec.
130
**/
131
readonly attribute ACString groupID;
132
133
/**
134
* The client ID for this application cache. Clients can open a
135
* session with nsICacheService::createSession() using this client
136
* ID and a storage policy of STORE_OFFLINE to access this cache.
137
*/
138
readonly attribute ACString clientID;
139
140
/**
141
* TRUE if the cache is the active cache for this group.
142
*/
143
readonly attribute boolean active;
144
145
/**
146
* The disk usage of the application cache, in bytes.
147
*/
148
readonly attribute unsigned long usage;
149
150
/**
151
* Makes this cache the active application cache for this group.
152
* Future loads associated with this group will come from this
153
* cache. Other caches from this cache group will be deactivated.
154
*/
155
void activate();
156
157
/**
158
* Discard this application cache. Removes all cached resources
159
* for this cache. If this is the active application cache for the
160
* group, the group will be removed.
161
*/
162
void discard();
163
164
/**
165
* Adds item types to a given entry.
166
*/
167
void markEntry(in ACString key, in unsigned long typeBits);
168
169
/**
170
* Removes types from a given entry. If the resulting entry has
171
* no types left, the entry is removed.
172
*/
173
void unmarkEntry(in ACString key, in unsigned long typeBits);
174
175
/**
176
* Gets the types for a given entry.
177
*/
178
unsigned long getTypes(in ACString key);
179
180
/**
181
* Returns any entries in the application cache whose type matches
182
* one or more of the bits in typeBits.
183
*/
184
Array<ACString> gatherEntries(in uint32_t typeBits);
185
186
/**
187
* Add a set of namespace entries to the application cache.
188
* @param namespaces
189
* An nsIArray of nsIApplicationCacheNamespace entries.
190
*/
191
void addNamespaces(in nsIArray namespaces);
192
193
/**
194
* Get the most specific namespace matching a given key.
195
*/
196
nsIApplicationCacheNamespace getMatchingNamespace(in ACString key);
197
198
/**
199
* If set, this offline cache is placed in a different directory
200
* than the current application profile.
201
*/
202
readonly attribute nsIFile profileDirectory;
203
};