nsICachingChannel.idl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsICacheInfoChannel.idl"
  6. interface nsIFile;
  7. /**
  8. * A channel may optionally implement this interface to allow clients
  9. * to affect its behavior with respect to how it uses the cache service.
  10. *
  11. * This interface provides:
  12. * 1) Support for "stream as file" semantics (for JAR and plugins).
  13. * 2) Support for "pinning" cached data in the cache (for printing and save-as).
  14. * 3) Support for uniquely identifying cached data in cases when the URL
  15. * is insufficient (e.g., HTTP form submission).
  16. */
  17. [scriptable, uuid(dd1d6122-5ecf-4fe4-8f0f-995e7ab3121a)]
  18. interface nsICachingChannel : nsICacheInfoChannel
  19. {
  20. /**
  21. * Set/get the cache token... uniquely identifies the data in the cache.
  22. * Holding a reference to this token prevents the cached data from being
  23. * removed.
  24. *
  25. * A cache token retrieved from a particular instance of nsICachingChannel
  26. * could be set on another instance of nsICachingChannel provided the
  27. * underlying implementations are compatible. The implementation of
  28. * nsICachingChannel would be expected to only read from the cache entry
  29. * identified by the cache token and not try to validate it.
  30. *
  31. * The cache token can be QI'd to a nsICacheEntryInfo if more detail
  32. * about the cache entry is needed (e.g., expiration time).
  33. */
  34. attribute nsISupports cacheToken;
  35. /**
  36. * The same as above but accessing the offline app cache token if there
  37. * is any.
  38. *
  39. * @throws
  40. * NS_ERROR_NOT_AVAILABLE when there is not offline cache token
  41. */
  42. attribute nsISupports offlineCacheToken;
  43. /**
  44. * Instructs the channel to only store the metadata of the entry, and not
  45. * the content. When reading an existing entry, this automatically sets
  46. * LOAD_ONLY_IF_MODIFIED flag.
  47. * Must be called before asyncOpen().
  48. */
  49. attribute boolean cacheOnlyMetadata;
  50. /**
  51. * Tells the channel to use the pinning storage.
  52. */
  53. attribute boolean pin;
  54. /**
  55. * Overrides cache validation for a time specified in seconds.
  56. *
  57. * @param aSecondsToTheFuture
  58. *
  59. */
  60. void forceCacheEntryValidFor(in unsigned long aSecondsToTheFuture);
  61. /**************************************************************************
  62. * Caching channel specific load flags:
  63. */
  64. /**
  65. * This load flag inhibits fetching from the net. An error of
  66. * NS_ERROR_DOCUMENT_NOT_CACHED will be sent to the listener's
  67. * onStopRequest if network IO is necessary to complete the request.
  68. *
  69. * This flag can be used to find out whether fetching this URL would
  70. * cause validation of the cache entry via the network.
  71. *
  72. * Combining this flag with LOAD_BYPASS_LOCAL_CACHE will cause all
  73. * loads to fail. This flag differs from LOAD_ONLY_FROM_CACHE in that
  74. * this flag fails the load if validation is required while
  75. * LOAD_ONLY_FROM_CACHE skips validation where possible.
  76. */
  77. const unsigned long LOAD_NO_NETWORK_IO = 1 << 26;
  78. /**
  79. * This load flag causes the offline cache to be checked when fetching
  80. * a request. It will be set automatically if the browser is offline.
  81. *
  82. * This flag will not be transferred through a redirect.
  83. */
  84. const unsigned long LOAD_CHECK_OFFLINE_CACHE = 1 << 27;
  85. /**
  86. * This load flag causes the local cache to be skipped when fetching a
  87. * request. Unlike LOAD_BYPASS_CACHE, it does not force an end-to-end load
  88. * (i.e., it does not affect proxy caches).
  89. */
  90. const unsigned long LOAD_BYPASS_LOCAL_CACHE = 1 << 28;
  91. /**
  92. * This load flag causes the local cache to be skipped if the request
  93. * would otherwise block waiting to access the cache.
  94. */
  95. const unsigned long LOAD_BYPASS_LOCAL_CACHE_IF_BUSY = 1 << 29;
  96. /**
  97. * This load flag inhibits fetching from the net if the data in the cache
  98. * has been evicted. An error of NS_ERROR_DOCUMENT_NOT_CACHED will be sent
  99. * to the listener's onStopRequest in this case. This flag is set
  100. * automatically when the application is offline.
  101. */
  102. const unsigned long LOAD_ONLY_FROM_CACHE = 1 << 30;
  103. /**
  104. * This load flag controls what happens when a document would be loaded
  105. * from the cache to satisfy a call to AsyncOpen. If this attribute is
  106. * set to TRUE, then the document will not be loaded from the cache. A
  107. * stream listener can check nsICachingChannel::isFromCache to determine
  108. * if the AsyncOpen will actually result in data being streamed.
  109. *
  110. * If this flag has been set, and the request can be satisfied via the
  111. * cache, then the OnDataAvailable events will be skipped. The listener
  112. * will only see OnStartRequest followed by OnStopRequest.
  113. */
  114. const unsigned long LOAD_ONLY_IF_MODIFIED = 1 << 31;
  115. };