nsICacheService.idl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 nsISimpleEnumerator;
  9. interface nsICacheListener;
  10. interface nsICacheSession;
  11. interface nsICacheVisitor;
  12. interface nsIEventTarget;
  13. /**
  14. * @deprecated
  15. *
  16. * IMPORTANT NOTE: THIS INTERFACE IS NO LONGER SUPPORTED AND PLANNED TO BE
  17. * REMOVED SOON. WE STRONGLY ENCORAGE TO MIGRATE THE EXISTING CODE AND FOR
  18. * THE NEW CODE USE ONLY THE NEW HTTP CACHE API IN netwerk/cache2/.
  19. */
  20. [scriptable, uuid(14dbe1e9-f3bc-45af-92f4-2c574fcd4e39)]
  21. interface nsICacheService : nsISupports
  22. {
  23. /**
  24. * @throws NS_ERROR_NOT_IMPLEMENTED when the cache v2 is prefered to use.
  25. *
  26. * Create a cache session
  27. *
  28. * A cache session represents a client's access into the cache. The cache
  29. * session is not "owned" by the cache service. Hence, it is possible to
  30. * create duplicate cache sessions. Entries created by a cache session
  31. * are invisible to other cache sessions, unless the cache sessions are
  32. * equivalent.
  33. *
  34. * @param clientID - Specifies the name of the client using the cache.
  35. * @param storagePolicy - Limits the storage policy for all entries
  36. * accessed via the returned session. As a result, devices excluded
  37. * by the storage policy will not be searched when opening entries
  38. * from the returned session.
  39. * @param streamBased - Indicates whether or not the data being cached
  40. * can be represented as a stream. The storagePolicy must be
  41. * consistent with the value of this field. For example, a non-stream-
  42. * based cache entry can only have a storage policy of STORE_IN_MEMORY.
  43. * @return new cache session.
  44. */
  45. nsICacheSession createSession(in string clientID,
  46. in nsCacheStoragePolicy storagePolicy,
  47. in boolean streamBased);
  48. /**
  49. * @throws NS_ERROR_NOT_IMPLEMENTED when the cache v2 is prefered to use.
  50. *
  51. * Visit entries stored in the cache. Used to implement about:cache.
  52. */
  53. void visitEntries(in nsICacheVisitor visitor);
  54. /**
  55. * @throws NS_ERROR_NOT_IMPLEMENTED when the cache v2 is prefered to use.
  56. *
  57. * Evicts all entries in all devices implied by the storage policy.
  58. *
  59. * @note This function may evict some items but will throw if it fails to evict
  60. * everything.
  61. */
  62. void evictEntries(in nsCacheStoragePolicy storagePolicy);
  63. /**
  64. * Event target which is used for I/O operations
  65. */
  66. readonly attribute nsIEventTarget cacheIOTarget;
  67. };
  68. %{C++
  69. /**
  70. * Observer service notification that is sent when
  71. * nsICacheService::evictEntries() or nsICacheSession::evictEntries()
  72. * is called.
  73. */
  74. #define NS_CACHESERVICE_EMPTYCACHE_TOPIC_ID "cacheservice:empty-cache"
  75. %}
  76. [scriptable, builtinclass, uuid(d0fc8d38-db80-4928-bf1c-b0085ddfa9dc)]
  77. interface nsICacheServiceInternal : nsICacheService
  78. {
  79. /**
  80. * This is an internal interface. It changes so frequently that it probably
  81. * went away while you were reading this.
  82. */
  83. /**
  84. * Milliseconds for which the service lock has been held. 0 if unlocked.
  85. */
  86. readonly attribute double lockHeldTime;
  87. };