2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-02-23 13:18:01 +00:00
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-02-23 13:18:01 +00:00
|
|
|
|
|
|
|
#ifndef _nsCacheDevice_h_
|
|
|
|
#define _nsCacheDevice_h_
|
|
|
|
|
|
|
|
#include "nspr.h"
|
|
|
|
#include "nsError.h"
|
2001-03-13 04:53:46 +00:00
|
|
|
#include "nsICache.h"
|
2017-08-16 23:48:52 +00:00
|
|
|
#include "nsStringFwd.h"
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-03-13 04:53:46 +00:00
|
|
|
class nsIFile;
|
2001-02-23 13:18:01 +00:00
|
|
|
class nsCacheEntry;
|
2001-03-08 21:00:02 +00:00
|
|
|
class nsICacheVisitor;
|
2003-01-18 02:15:14 +00:00
|
|
|
class nsIInputStream;
|
|
|
|
class nsIOutputStream;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-03-20 22:42:03 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* nsCacheDevice
|
|
|
|
*******************************************************************************/
|
2001-02-23 13:18:01 +00:00
|
|
|
class nsCacheDevice {
|
|
|
|
public:
|
2001-11-06 22:51:58 +00:00
|
|
|
nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice); }
|
|
|
|
virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice); }
|
2001-02-27 05:33:34 +00:00
|
|
|
|
|
|
|
virtual nsresult Init() = 0;
|
2001-03-29 05:54:58 +00:00
|
|
|
virtual nsresult Shutdown() = 0;
|
2001-02-27 05:33:34 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual const char* GetDeviceID(void) = 0;
|
|
|
|
virtual nsCacheEntry* FindEntry(nsCString* key, bool* collision) = 0;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual nsresult DeactivateEntry(nsCacheEntry* entry) = 0;
|
|
|
|
virtual nsresult BindEntry(nsCacheEntry* entry) = 0;
|
|
|
|
virtual void DoomEntry(nsCacheEntry* entry) = 0;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual nsresult OpenInputStreamForEntry(nsCacheEntry* entry,
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheAccessMode mode,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t offset,
|
2019-05-01 08:47:10 +00:00
|
|
|
nsIInputStream** result) = 0;
|
2003-01-18 02:15:14 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual nsresult OpenOutputStreamForEntry(nsCacheEntry* entry,
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheAccessMode mode,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t offset,
|
2019-05-01 08:47:10 +00:00
|
|
|
nsIOutputStream** result) = 0;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual nsresult GetFileForEntry(nsCacheEntry* entry, nsIFile** result) = 0;
|
2001-03-08 21:22:18 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual nsresult OnDataSizeChange(nsCacheEntry* entry, int32_t deltaSize) = 0;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual nsresult Visit(nsICacheVisitor* visitor) = 0;
|
2001-03-29 05:54:58 +00:00
|
|
|
|
|
|
|
/**
|
2012-07-30 14:20:58 +00:00
|
|
|
* Device must evict entries associated with clientID. If clientID ==
|
2001-03-29 05:54:58 +00:00
|
|
|
* nullptr, all entries must be evicted. Active entries must be doomed,
|
|
|
|
* rather than evicted.
|
|
|
|
*/
|
2019-05-01 08:47:10 +00:00
|
|
|
virtual nsresult EvictEntries(const char* clientID) = 0;
|
2001-02-23 13:18:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _nsCacheDevice_h_
|