1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is nsIOfflineCacheSession.idl.
17 *
18 * The Initial Developer of the Original Code is
19 * Mozilla Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2007
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 * Dave Camp <dcamp@mozilla.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 #include "nsISupports.idl"
41 #include "nsICache.idl"
42
43 /**
44 * The offline cache is meant to reliably store resources for
45 * offline use. The expected semantics are:
46 *
47 * a) Once populated, the cache will not evict an application resource
48 * unless explicitly asked.
49 *
50 * b) Resources no longer in use by the application should be evicted.
51 *
52 * c) If the cache fills up, new entries should be rejected rather
53 * than throwing out old ones.
54 *
55 * The offline cache uses domains to concretely represent an
56 * application. It maintains a list of resources to be pinned for
57 * each domain. This list is separate from actual cache
58 * population - the caller is still responsible for placing items
59 * in the cache, and ownership can be declared without a
60 * corresponding entry.
61 *
62 * A key can optionally be associated with a specific URI within
63 * the domain.
64 */
65
66 [scriptable, uuid(3a33e268-4175-4440-a933-89d461c86c5f)]
67 interface nsIOfflineCacheSession : nsISupports
68 {
69 /**
70 * Gets the list of owner domains in the cache.
71 *
72 * @param count
73 * The number of domains returned
74 * @param uris
75 * The domains that own resources in the cache
76 */
77 void getOwnerDomains(out unsigned long count,
78 [array, size_is(count)]out string domains);
79
80 /**
81 * Gets the list of owner URIs associated with a domain.
82 *
83 * @param ownerAsciiDomain
84 * The domain to query
85 * !! IMPORTANT !! : This must be ascii encoded host - nsIURI.asciiHost
86 * @param count
87 * The number of uris returned
88 * @param uris
89 * The uris in this domain that own resources
90 */
91 void getOwnerURIs(in ACString ownerAsciiDomain,
92 out unsigned long count,
93 [array, size_is(count)]out string uris);
94
95 /**
96 * Sets the resources owned by a given domain/URI pair.
97 *
98 * Setting a list will remove any resources previously owned by this
99 * domain/URI pair.
100 *
101 * A key can be added while there is no associated entry. When
102 * an entry is created with this key, it will be owned by the
103 * domain/URI pair.
104 *
105 * @param ownerAsciiDomain
106 * The domain that owns the resources
107 * !! IMPORTANT !! : This must be ascii encoded host - nsIURI.asciiHost
108 * @param ownerAsciiKey
109 * The specific key that owns the resources. You may use
110 * ascii encoded URI spec of the owner - nsIURI.asciiSpec.
111 * This can be empty if none specifically owns the resources.
112 * @param count
113 * The number of keys in keys.
114 * @param keys
115 * The keys that the domain/URI pair own. This can be empty to
116 * clear ownership for the domain/URI pair.
117 */
118 void setOwnedKeys(in ACString ownerAsciiDomain,
119 in ACString ownerAsciiKey,
120 in unsigned long count,
121 [array, size_is(count)]in string keys);
122
123 /**
124 * Gets the list of resources owned by a given domain/URI pair.
125 *
126 * @param ownerAsciiDomain
127 * The domain that owns the resources
128 * !! IMPORTANT !! : This must be ascii encoded host - nsIURI.asciiHost
129 * @param ownerAsciiKey
130 * The specific key that owns the resources. You may use
131 * ascii encoded URI spec of the owner - nsIURI.asciiSpec.
132 * This can be empty if none specifically owns the resources.
133 * @param count
134 * The number of keys in keys.
135 * @param keys
136 * The keys that the domain/URI pair own.
137 */
138 void getOwnedKeys(in ACString ownerAsciiDomain,
139 in ACString ownerAsciiKey,
140 out unsigned long count,
141 [array, size_is(count)]out string keys);
142
143 /**
144 * Adds an owned key to a domain/URI pair.
145 *
146 * A key can be added while there is no associated entry. When
147 * an entry is created with this key, it will be owned by the
148 * domain/URI pair.
149 *
150 * @param ownerAsciiDomain
151 * The domain that owns the resources
152 * !! IMPORTANT !! : This must be ascii encoded host - nsIURI.asciiHost
153 * @param ownerAsciiKey
154 * The specific key that owns the resources. You may use
155 * ascii encoded URI spec of the owner - nsIURI.asciiSpec.
156 * This can be empty if none specifically owns the resources.
157 * @param key
158 * The key to add.
159 */
160 void addOwnedKey(in ACString ownerAsciiDomain,
161 in ACString ownerAsciiKey,
162 in ACString key);
163
164 /**
165 * Removes an owned key from a domain/URI pair.
166 *
167 * If the key does not exist, an NS_ERROR_NOT_AVAILABLE exception
168 * will be thrown.
169 *
170 * @param ownerAsciiDomain
171 * The domain that owns the resources
172 * !! IMPORTANT !! : This must be ascii encoded host - nsIURI.asciiHost
173 * @param ownerAsciiKey
174 * The specific key that owns the resources. You may use
175 * ascii encoded URI spec of the owner - nsIURI.asciiSpec.
176 * This can be empty if none specifically owns the resources.
177 * @param key The key to remove.
178 */
179 void removeOwnedKey(in ACString ownerAsciiDomain,
180 in ACString ownerAsciiKey,
181 in ACString key);
182
183 /**
184 * Checks whether a key is owned by a given domain/URI pair.
185 *
186 * @param ownerAsciiDomain
187 * The domain that owns the resources
188 * !! IMPORTANT !! : This must be ascii encoded host - nsIURI.asciiHost
189 * @param ownerAsciiKey
190 * The specific key that owns the resources. You may use
191 * ascii encoded URI spec of the owner - nsIURI.asciiSpec.
192 * This can be empty if none specifically owns the resources.
193 * @param key The key to check
194 */
195 boolean keyIsOwned(in ACString ownerAsciiDomain,
196 in ACString ownerAsciiKey,
197 in ACString key);
198
199 /**
200 * Remove all keys owned by a domain, including keys owned by
201 * a specific URI.
202 *
203 * @param ownerAsciiDomain
204 * The domain for which keys should be removed
205 * !! IMPORTANT !! : This must be ascii encoded host - nsIURI.asciiHost
206 */
207 void clearKeysOwnedByDomain(in ACString ownerAsciiDomain);
208
209 /**
210 * Get the number of bytes used in the cache by a domain.
211 *
212 * @param domain The domain to check.
213 */
214 unsigned long getDomainUsage(in ACString ownerDomain);
215
216 /**
217 * Evict all entries that are not owned by a domain.
218 */
219 void evictUnownedEntries();
220
221 /**
222 * Merge the items from a temporary clientID in to this client. This lets
223 * offline cache updates accumulate in a temporary client and be moved
224 * in all at once.
225 *
226 * Entries in the temporary client will replace any entries in this client
227 * with the same cache key.
228 *
229 * Ownership lists for a given domain/URI pair from the temporary client
230 * will replace ownership lists for the same domain/URI pair.
231 */
232 void mergeTemporaryClientID(in ACString temporaryClientID);
233 };