nsICacheInfoChannel.idl 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsISupports.idl"
  5. interface nsIOutputStream;
  6. [scriptable, uuid(72c34415-c6eb-48af-851f-772fa9ee5972)]
  7. interface nsICacheInfoChannel : nsISupports
  8. {
  9. /**
  10. * Get expiration time from cache token. This attribute is equivalent to
  11. * nsICachingChannel.cacheToken.expirationTime.
  12. */
  13. readonly attribute uint32_t cacheTokenExpirationTime;
  14. /**
  15. * Set/get charset of cache entry. Accessing this attribute is equivalent to
  16. * calling nsICachingChannel.cacheToken.getMetaDataElement("charset") and
  17. * nsICachingChannel.cacheToken.setMetaDataElement("charset").
  18. */
  19. attribute ACString cacheTokenCachedCharset;
  20. /**
  21. * TRUE if this channel's data is being loaded from the cache. This value
  22. * is undefined before the channel fires its OnStartRequest notification
  23. * and after the channel fires its OnStopRequest notification.
  24. */
  25. boolean isFromCache();
  26. /**
  27. * Set/get the cache key... uniquely identifies the data in the cache
  28. * for this channel. Holding a reference to this key does NOT prevent
  29. * the cached data from being removed.
  30. *
  31. * A cache key retrieved from a particular instance of nsICacheInfoChannel
  32. * could be set on another instance of nsICacheInfoChannel provided the
  33. * underlying implementations are compatible and provided the new
  34. * channel instance was created with the same URI. The implementation of
  35. * nsICacheInfoChannel would be expected to use the cache entry identified
  36. * by the cache token. Depending on the value of nsIRequest::loadFlags,
  37. * the cache entry may be validated, overwritten, or simply read.
  38. *
  39. * The cache key may be NULL indicating that the URI of the channel is
  40. * sufficient to locate the same cache entry. Setting a NULL cache key
  41. * is likewise valid.
  42. */
  43. attribute nsISupports cacheKey;
  44. /**
  45. * Tells the channel to behave as if the LOAD_FROM_CACHE flag has been set,
  46. * but without affecting the loads for the entire loadGroup in case of this
  47. * channel being the default load group's channel.
  48. */
  49. attribute boolean allowStaleCacheContent;
  50. /**
  51. * Calling this method instructs the channel to serve the alternative data
  52. * if that was previously saved in the cache, otherwise it will serve the
  53. * real data.
  54. * Must be called before AsyncOpen.
  55. */
  56. void preferAlternativeDataType(in ACString type);
  57. /**
  58. * Holds the type of the alternative data representation that the channel
  59. * is returning.
  60. * Is empty string if no alternative data representation was requested, or
  61. * if the requested representation wasn't found in the cache.
  62. * Can only be called during or after OnStartRequest.
  63. */
  64. readonly attribute ACString alternativeDataType;
  65. /**
  66. * Opens and returns an output stream that a consumer may use to save an
  67. * alternate representation of the data.
  68. * Must be called after the OnStopRequest that delivered the real data.
  69. * The consumer may choose to replace the saved alt representation.
  70. * Opening the output stream will fail if there are any open input streams
  71. * reading the already saved alt representation.
  72. */
  73. nsIOutputStream openAlternativeOutputStream(in ACString type);
  74. };