netwerk/cache/nsCacheDevice.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/cache/nsCacheDevice.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef _nsCacheDevice_h_
    1.11 +#define _nsCacheDevice_h_
    1.12 +
    1.13 +#include "nspr.h"
    1.14 +#include "nsError.h"
    1.15 +#include "nsICache.h"
    1.16 +
    1.17 +class nsIFile;
    1.18 +class nsCString;
    1.19 +class nsCacheEntry;
    1.20 +class nsICacheVisitor;
    1.21 +class nsIInputStream;
    1.22 +class nsIOutputStream;
    1.23 +
    1.24 +/******************************************************************************
    1.25 +* nsCacheDevice
    1.26 +*******************************************************************************/
    1.27 +class nsCacheDevice {
    1.28 +public:
    1.29 +    nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice); }
    1.30 +    virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice); }
    1.31 +
    1.32 +    virtual nsresult Init() = 0;
    1.33 +    virtual nsresult Shutdown() = 0;
    1.34 +
    1.35 +    virtual const char *   GetDeviceID(void) = 0;
    1.36 +    virtual nsCacheEntry * FindEntry( nsCString * key, bool *collision ) = 0;
    1.37 +
    1.38 +    virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0;
    1.39 +    virtual nsresult BindEntry( nsCacheEntry * entry ) = 0;
    1.40 +    virtual void     DoomEntry( nsCacheEntry * entry ) = 0;
    1.41 +
    1.42 +    virtual nsresult OpenInputStreamForEntry(nsCacheEntry *     entry,
    1.43 +                                             nsCacheAccessMode  mode,
    1.44 +                                             uint32_t           offset,
    1.45 +                                             nsIInputStream **  result) = 0;
    1.46 +
    1.47 +    virtual nsresult OpenOutputStreamForEntry(nsCacheEntry *     entry,
    1.48 +                                              nsCacheAccessMode  mode,
    1.49 +                                              uint32_t           offset,
    1.50 +                                              nsIOutputStream ** result) = 0;
    1.51 +
    1.52 +    virtual nsresult GetFileForEntry( nsCacheEntry *    entry,
    1.53 +                                      nsIFile **        result ) = 0;
    1.54 +
    1.55 +    virtual nsresult OnDataSizeChange( nsCacheEntry * entry, int32_t deltaSize ) = 0;
    1.56 +
    1.57 +    virtual nsresult Visit(nsICacheVisitor * visitor) = 0;
    1.58 +
    1.59 +    /**
    1.60 +     * Device must evict entries associated with clientID.  If clientID == nullptr, all
    1.61 +     * entries must be evicted.  Active entries must be doomed, rather than evicted.
    1.62 +     */
    1.63 +    virtual nsresult EvictEntries(const char * clientID) = 0;
    1.64 +};
    1.65 +
    1.66 +#endif // _nsCacheDevice_h_

mercurial