nsIApplicationCache.idl 6.6 KB

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