michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsCacheDevice_h_ michael@0: #define _nsCacheDevice_h_ michael@0: michael@0: #include "nspr.h" michael@0: #include "nsError.h" michael@0: #include "nsICache.h" michael@0: michael@0: class nsIFile; michael@0: class nsCString; michael@0: class nsCacheEntry; michael@0: class nsICacheVisitor; michael@0: class nsIInputStream; michael@0: class nsIOutputStream; michael@0: michael@0: /****************************************************************************** michael@0: * nsCacheDevice michael@0: *******************************************************************************/ michael@0: class nsCacheDevice { michael@0: public: michael@0: nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice); } michael@0: virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice); } michael@0: michael@0: virtual nsresult Init() = 0; michael@0: virtual nsresult Shutdown() = 0; michael@0: michael@0: virtual const char * GetDeviceID(void) = 0; michael@0: virtual nsCacheEntry * FindEntry( nsCString * key, bool *collision ) = 0; michael@0: michael@0: virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0; michael@0: virtual nsresult BindEntry( nsCacheEntry * entry ) = 0; michael@0: virtual void DoomEntry( nsCacheEntry * entry ) = 0; michael@0: michael@0: virtual nsresult OpenInputStreamForEntry(nsCacheEntry * entry, michael@0: nsCacheAccessMode mode, michael@0: uint32_t offset, michael@0: nsIInputStream ** result) = 0; michael@0: michael@0: virtual nsresult OpenOutputStreamForEntry(nsCacheEntry * entry, michael@0: nsCacheAccessMode mode, michael@0: uint32_t offset, michael@0: nsIOutputStream ** result) = 0; michael@0: michael@0: virtual nsresult GetFileForEntry( nsCacheEntry * entry, michael@0: nsIFile ** result ) = 0; michael@0: michael@0: virtual nsresult OnDataSizeChange( nsCacheEntry * entry, int32_t deltaSize ) = 0; michael@0: michael@0: virtual nsresult Visit(nsICacheVisitor * visitor) = 0; michael@0: michael@0: /** michael@0: * Device must evict entries associated with clientID. If clientID == nullptr, all michael@0: * entries must be evicted. Active entries must be doomed, rather than evicted. michael@0: */ michael@0: virtual nsresult EvictEntries(const char * clientID) = 0; michael@0: }; michael@0: michael@0: #endif // _nsCacheDevice_h_