Bug 783551 - Get tooltool running on the b2g on OS X builds. r=respindola
[gecko.git] / netwerk / cache / nsCacheDevice.h
blob75a4f5c423d494c9400e4dfd353f8808aa65d4a9
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_
10 #include "nspr.h"
11 #include "nsError.h"
12 #include "nsICache.h"
14 class nsIFile;
15 class nsCString;
16 class nsCacheEntry;
17 class nsICacheVisitor;
18 class nsIInputStream;
19 class nsIOutputStream;
21 /******************************************************************************
22 * nsCacheDevice
23 *******************************************************************************/
24 class nsCacheDevice {
25 public:
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,
41 PRUint32 offset,
42 nsIInputStream ** result) = 0;
44 virtual nsresult OpenOutputStreamForEntry(nsCacheEntry * entry,
45 nsCacheAccessMode mode,
46 PRUint32 offset,
47 nsIOutputStream ** result) = 0;
49 virtual nsresult GetFileForEntry( nsCacheEntry * entry,
50 nsIFile ** result ) = 0;
52 virtual nsresult OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize ) = 0;
54 virtual nsresult Visit(nsICacheVisitor * visitor) = 0;
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.
60 virtual nsresult EvictEntries(const char * clientID) = 0;
63 #endif // _nsCacheDevice_h_