1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/. */
7 #ifndef _nsCacheDevice_h_
8 #define _nsCacheDevice_h_
17 class nsICacheVisitor
;
19 class nsIOutputStream
;
21 /******************************************************************************
23 *******************************************************************************/
26 nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice
); }
27 virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice
); }
29 virtual nsresult
Init() = 0;
30 virtual nsresult
Shutdown() = 0;
32 virtual const char * GetDeviceID(void) = 0;
33 virtual nsCacheEntry
* FindEntry( nsCString
* key
, bool *collision
) = 0;
35 virtual nsresult
DeactivateEntry( nsCacheEntry
* entry
) = 0;
36 virtual nsresult
BindEntry( nsCacheEntry
* entry
) = 0;
37 virtual void DoomEntry( nsCacheEntry
* entry
) = 0;
39 virtual nsresult
OpenInputStreamForEntry(nsCacheEntry
* entry
,
40 nsCacheAccessMode mode
,
42 nsIInputStream
** result
) = 0;
44 virtual nsresult
OpenOutputStreamForEntry(nsCacheEntry
* entry
,
45 nsCacheAccessMode mode
,
47 nsIOutputStream
** result
) = 0;
49 virtual nsresult
GetFileForEntry( nsCacheEntry
* entry
,
50 nsIFile
** result
) = 0;
52 virtual nsresult
OnDataSizeChange( nsCacheEntry
* entry
, int32_t deltaSize
) = 0;
54 virtual nsresult
Visit(nsICacheVisitor
* visitor
) = 0;
57 * Device must evict entries associated with clientID. If clientID == nullptr, all
58 * entries must be evicted. Active entries must be doomed, rather than evicted.
60 virtual nsresult
EvictEntries(const char * clientID
) = 0;
63 #endif // _nsCacheDevice_h_