2001-02-23 16:18:01 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04: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 16:18:01 +03:00
|
|
|
|
|
|
|
#ifndef _nsCacheDevice_h_
|
|
|
|
#define _nsCacheDevice_h_
|
|
|
|
|
|
|
|
#include "nspr.h"
|
|
|
|
#include "nsError.h"
|
2001-03-13 07:53:46 +03:00
|
|
|
#include "nsICache.h"
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-03-13 07:53:46 +03:00
|
|
|
class nsIFile;
|
|
|
|
class nsCString;
|
2001-02-23 16:18:01 +03:00
|
|
|
class nsCacheEntry;
|
2001-03-09 00:00:02 +03:00
|
|
|
class nsICacheVisitor;
|
2003-01-18 05:15:14 +03:00
|
|
|
class nsIInputStream;
|
|
|
|
class nsIOutputStream;
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-03-21 01:42:03 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* nsCacheDevice
|
|
|
|
*******************************************************************************/
|
2001-02-23 16:18:01 +03:00
|
|
|
class nsCacheDevice {
|
|
|
|
public:
|
2001-11-07 01:51:58 +03:00
|
|
|
nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice); }
|
|
|
|
virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice); }
|
2001-02-27 08:33:34 +03:00
|
|
|
|
|
|
|
virtual nsresult Init() = 0;
|
2001-03-29 09:54:58 +04:00
|
|
|
virtual nsresult Shutdown() = 0;
|
2001-02-27 08:33:34 +03:00
|
|
|
|
|
|
|
virtual const char * GetDeviceID(void) = 0;
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual nsCacheEntry * FindEntry( nsCString * key, bool *collision ) = 0;
|
2001-02-23 16:18:01 +03:00
|
|
|
|
|
|
|
virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0;
|
|
|
|
virtual nsresult BindEntry( nsCacheEntry * entry ) = 0;
|
2001-03-08 08:37:00 +03:00
|
|
|
virtual void DoomEntry( nsCacheEntry * entry ) = 0;
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
virtual nsresult OpenInputStreamForEntry(nsCacheEntry * entry,
|
|
|
|
nsCacheAccessMode mode,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t offset,
|
2003-01-18 05:15:14 +03:00
|
|
|
nsIInputStream ** result) = 0;
|
|
|
|
|
|
|
|
virtual nsresult OpenOutputStreamForEntry(nsCacheEntry * entry,
|
|
|
|
nsCacheAccessMode mode,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t offset,
|
2003-01-18 05:15:14 +03:00
|
|
|
nsIOutputStream ** result) = 0;
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-03-09 00:22:18 +03:00
|
|
|
virtual nsresult GetFileForEntry( nsCacheEntry * entry,
|
|
|
|
nsIFile ** result ) = 0;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsresult OnDataSizeChange( nsCacheEntry * entry, int32_t deltaSize ) = 0;
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-03-09 00:00:02 +03:00
|
|
|
virtual nsresult Visit(nsICacheVisitor * visitor) = 0;
|
2001-03-29 09:54:58 +04:00
|
|
|
|
|
|
|
/**
|
2012-07-30 18:20:58 +04:00
|
|
|
* Device must evict entries associated with clientID. If clientID == nullptr, all
|
2001-03-29 09:54:58 +04:00
|
|
|
* entries must be evicted. Active entries must be doomed, rather than evicted.
|
|
|
|
*/
|
|
|
|
virtual nsresult EvictEntries(const char * clientID) = 0;
|
2001-02-23 16:18:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _nsCacheDevice_h_
|