nsCacheDevice.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* -*- Mode: C++; 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. #ifndef _nsCacheDevice_h_
  7. #define _nsCacheDevice_h_
  8. #include "nspr.h"
  9. #include "nsError.h"
  10. #include "nsICache.h"
  11. class nsIFile;
  12. class nsCString;
  13. class nsCacheEntry;
  14. class nsICacheVisitor;
  15. class nsIInputStream;
  16. class nsIOutputStream;
  17. /******************************************************************************
  18. * nsCacheDevice
  19. *******************************************************************************/
  20. class nsCacheDevice {
  21. public:
  22. nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice); }
  23. virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice); }
  24. virtual nsresult Init() = 0;
  25. virtual nsresult Shutdown() = 0;
  26. virtual const char * GetDeviceID(void) = 0;
  27. virtual nsCacheEntry * FindEntry( nsCString * key, bool *collision ) = 0;
  28. virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0;
  29. virtual nsresult BindEntry( nsCacheEntry * entry ) = 0;
  30. virtual void DoomEntry( nsCacheEntry * entry ) = 0;
  31. virtual nsresult OpenInputStreamForEntry(nsCacheEntry * entry,
  32. nsCacheAccessMode mode,
  33. uint32_t offset,
  34. nsIInputStream ** result) = 0;
  35. virtual nsresult OpenOutputStreamForEntry(nsCacheEntry * entry,
  36. nsCacheAccessMode mode,
  37. uint32_t offset,
  38. nsIOutputStream ** result) = 0;
  39. virtual nsresult GetFileForEntry( nsCacheEntry * entry,
  40. nsIFile ** result ) = 0;
  41. virtual nsresult OnDataSizeChange( nsCacheEntry * entry, int32_t deltaSize ) = 0;
  42. virtual nsresult Visit(nsICacheVisitor * visitor) = 0;
  43. /**
  44. * Device must evict entries associated with clientID. If clientID == nullptr, all
  45. * entries must be evicted. Active entries must be doomed, rather than evicted.
  46. */
  47. virtual nsresult EvictEntries(const char * clientID) = 0;
  48. };
  49. #endif // _nsCacheDevice_h_