netwerk/cache/nsCacheDevice.h

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:a2028d6c956f
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
7 #ifndef _nsCacheDevice_h_
8 #define _nsCacheDevice_h_
9
10 #include "nspr.h"
11 #include "nsError.h"
12 #include "nsICache.h"
13
14 class nsIFile;
15 class nsCString;
16 class nsCacheEntry;
17 class nsICacheVisitor;
18 class nsIInputStream;
19 class nsIOutputStream;
20
21 /******************************************************************************
22 * nsCacheDevice
23 *******************************************************************************/
24 class nsCacheDevice {
25 public:
26 nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice); }
27 virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice); }
28
29 virtual nsresult Init() = 0;
30 virtual nsresult Shutdown() = 0;
31
32 virtual const char * GetDeviceID(void) = 0;
33 virtual nsCacheEntry * FindEntry( nsCString * key, bool *collision ) = 0;
34
35 virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0;
36 virtual nsresult BindEntry( nsCacheEntry * entry ) = 0;
37 virtual void DoomEntry( nsCacheEntry * entry ) = 0;
38
39 virtual nsresult OpenInputStreamForEntry(nsCacheEntry * entry,
40 nsCacheAccessMode mode,
41 uint32_t offset,
42 nsIInputStream ** result) = 0;
43
44 virtual nsresult OpenOutputStreamForEntry(nsCacheEntry * entry,
45 nsCacheAccessMode mode,
46 uint32_t offset,
47 nsIOutputStream ** result) = 0;
48
49 virtual nsresult GetFileForEntry( nsCacheEntry * entry,
50 nsIFile ** result ) = 0;
51
52 virtual nsresult OnDataSizeChange( nsCacheEntry * entry, int32_t deltaSize ) = 0;
53
54 virtual nsresult Visit(nsICacheVisitor * visitor) = 0;
55
56 /**
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.
59 */
60 virtual nsresult EvictEntries(const char * clientID) = 0;
61 };
62
63 #endif // _nsCacheDevice_h_

mercurial