nsICacheStorageService.idl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 nsICacheStorage;
  6. interface nsILoadContextInfo;
  7. interface nsIApplicationCache;
  8. interface nsIEventTarget;
  9. interface nsICacheStorageConsumptionObserver;
  10. /**
  11. * Provides access to particual cache storages of the network URI cache.
  12. */
  13. [scriptable, uuid(ae29c44b-fbc3-4552-afaf-0a157ce771e7)]
  14. interface nsICacheStorageService : nsISupports
  15. {
  16. /**
  17. * Get storage where entries will only remain in memory, never written
  18. * to the disk.
  19. *
  20. * NOTE: Any existing disk entry for [URL|id-extension] will be doomed
  21. * prior opening an entry using this memory-only storage. Result of
  22. * AsyncOpenURI will be a new and empty memory-only entry. Using
  23. * OPEN_READONLY open flag has no effect on this behavior.
  24. *
  25. * @param aLoadContextInfo
  26. * Information about the loading context, this focuses the storage JAR and
  27. * respects separate storage for private browsing.
  28. */
  29. nsICacheStorage memoryCacheStorage(in nsILoadContextInfo aLoadContextInfo);
  30. /**
  31. * Get storage where entries will be written to disk when not forbidden by
  32. * response headers.
  33. *
  34. * @param aLookupAppCache
  35. * When set true (for top level document loading channels) app cache will
  36. * be first to check on to find entries in.
  37. */
  38. nsICacheStorage diskCacheStorage(in nsILoadContextInfo aLoadContextInfo,
  39. in bool aLookupAppCache);
  40. /**
  41. * Get storage where entries will be written to disk and marked as pinned.
  42. * These pinned entries are immune to over limit eviction and call of clear()
  43. * on this service.
  44. */
  45. nsICacheStorage pinningCacheStorage(in nsILoadContextInfo aLoadContextInfo);
  46. /**
  47. * Get storage for a specified application cache obtained using some different
  48. * mechanism.
  49. *
  50. * @param aLoadContextInfo
  51. * Mandatory reference to a load context information.
  52. * @param aApplicationCache
  53. * Optional reference to an existing appcache. When left null, this will
  54. * work with offline cache as a whole.
  55. */
  56. nsICacheStorage appCacheStorage(in nsILoadContextInfo aLoadContextInfo,
  57. in nsIApplicationCache aApplicationCache);
  58. /**
  59. * Get storage for synthesized cache entries that we currently use for ServiceWorker interception in non-e10s mode.
  60. *
  61. * This cache storage has no limits on file size to allow the ServiceWorker to intercept large files.
  62. */
  63. nsICacheStorage synthesizedCacheStorage(in nsILoadContextInfo aLoadContextInfo);
  64. /**
  65. * Evict the whole cache.
  66. */
  67. void clear();
  68. /**
  69. * Purge only data of disk backed entries. Metadata are left for
  70. * performance purposes.
  71. */
  72. const uint32_t PURGE_DISK_DATA_ONLY = 1;
  73. /**
  74. * Purge whole disk backed entries from memory. Disk files will
  75. * be left unattended.
  76. */
  77. const uint32_t PURGE_DISK_ALL = 2;
  78. /**
  79. * Purge all entries we keep in memory, including memory-storage
  80. * entries. This may be dangerous to use.
  81. */
  82. const uint32_t PURGE_EVERYTHING = 3;
  83. /**
  84. * Purges data we keep warmed in memory. Use for tests and for
  85. * saving memory.
  86. */
  87. void purgeFromMemory(in uint32_t aWhat);
  88. /**
  89. * I/O thread target to use for any operations on disk
  90. */
  91. readonly attribute nsIEventTarget ioTarget;
  92. /**
  93. * Asynchronously determine how many bytes of the disk space the cache takes.
  94. * @see nsICacheStorageConsumptionObserver
  95. * @param aObserver
  96. * A mandatory (weak referred) observer. Documented at
  97. * nsICacheStorageConsumptionObserver.
  98. * NOTE: the observer MUST implement nsISupportsWeakReference.
  99. */
  100. void asyncGetDiskConsumption(in nsICacheStorageConsumptionObserver aObserver);
  101. };
  102. [scriptable, uuid(7728ab5b-4c01-4483-a606-32bf5b8136cb)]
  103. interface nsICacheStorageConsumptionObserver : nsISupports
  104. {
  105. /**
  106. * Callback invoked to answer asyncGetDiskConsumption call. Always triggered
  107. * on the main thread.
  108. * NOTE: implementers must also implement nsISupportsWeakReference.
  109. *
  110. * @param aDiskSize
  111. * The disk consumption in bytes.
  112. */
  113. void onNetworkCacheDiskConsumption(in int64_t aDiskSize);
  114. };