nsICacheSession.idl 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include "nsICache.idl"
  8. interface nsICacheEntryDescriptor;
  9. interface nsICacheListener;
  10. interface nsIFile;
  11. [scriptable, uuid(1dd7708c-de48-4ffe-b5aa-cd218c762887)]
  12. interface nsICacheSession : nsISupports
  13. {
  14. /**
  15. * Expired entries will be doomed or evicted if this attribute is set to
  16. * true. If false, expired entries will be returned (useful for offline-
  17. * mode and clients, such as HTTP, that can update the valid lifetime of
  18. * cached content). This attribute defaults to true.
  19. */
  20. attribute boolean doomEntriesIfExpired;
  21. /**
  22. * When set, entries created with this session will be placed to a cache
  23. * based at this directory. Use when storing entries to a different
  24. * profile than the active profile of the the current running application
  25. * process.
  26. */
  27. attribute nsIFile profileDirectory;
  28. /**
  29. * A cache session can only give out one descriptor with WRITE access
  30. * to a given cache entry at a time. Until the client calls MarkValid on
  31. * its descriptor, other attempts to open the same cache entry will block.
  32. */
  33. /**
  34. * Synchronous cache access. This method fails if it is called on the main
  35. * thread. Use asyncOpenCacheEntry() instead. This returns a unique
  36. * descriptor each time it is called, even if the same key is specified.
  37. * When called by multiple threads for write access, only one writable
  38. * descriptor will be granted. If 'blockingMode' is set to false, it will
  39. * return NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than block when another
  40. * descriptor has been given WRITE access but hasn't validated the entry yet.
  41. */
  42. nsICacheEntryDescriptor openCacheEntry(in ACString key,
  43. in nsCacheAccessMode accessRequested,
  44. in boolean blockingMode);
  45. /**
  46. * Asynchronous cache access. Does not block the calling thread. Instead,
  47. * the listener will be notified when the descriptor is available. If
  48. * 'noWait' is set to true, the listener will be notified immediately with
  49. * status NS_ERROR_CACHE_WAIT_FOR_VALIDATION rather than queuing the request
  50. * when another descriptor has been given WRITE access but hasn't validated
  51. * the entry yet.
  52. */
  53. void asyncOpenCacheEntry(in ACString key,
  54. in nsCacheAccessMode accessRequested,
  55. in nsICacheListener listener,
  56. [optional] in boolean noWait);
  57. /**
  58. * Evict all entries for this session's clientID according to its storagePolicy.
  59. */
  60. void evictEntries();
  61. /**
  62. * Return whether any of the cache devices implied by the session storage policy
  63. * are currently enabled for instantiation if they don't already exist.
  64. */
  65. boolean isStorageEnabled();
  66. /**
  67. * Asynchronously doom an entry specified by the key. Listener will be
  68. * notified about the status of the operation. Null may be passed if caller
  69. * doesn't care about the result.
  70. */
  71. void doomEntry(in ACString key, in nsICacheListener listener);
  72. /**
  73. * Private entries will be doomed when the last private browsing session
  74. * finishes.
  75. */
  76. attribute boolean isPrivate;
  77. };