Back to index

lightning-sunbird  0.9+nobinonly
nsCacheDevice.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is nsCacheDevice.h, released
00017  * February 22, 2001.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 2001
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Gordon Sheridan, 22-February-2001
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #ifndef _nsCacheDevice_h_
00042 #define _nsCacheDevice_h_
00043 
00044 #include "nspr.h"
00045 #include "nsError.h"
00046 #include "nsICache.h"
00047 
00048 class nsIFile;
00049 class nsCString;
00050 class nsCacheEntry;
00051 class nsICacheVisitor;
00052 class nsIInputStream;
00053 class nsIOutputStream;
00054 
00055 /******************************************************************************
00056 * nsCacheDevice
00057 *******************************************************************************/
00058 class nsCacheDevice {
00059 public:
00060     nsCacheDevice() { MOZ_COUNT_CTOR(nsCacheDevice); }
00061     virtual ~nsCacheDevice() { MOZ_COUNT_DTOR(nsCacheDevice); }
00062 
00063     virtual nsresult Init() = 0;
00064     virtual nsresult Shutdown() = 0;
00065 
00066     virtual const char *   GetDeviceID(void) = 0;
00067     virtual nsCacheEntry * FindEntry( nsCString * key, PRBool *collision ) = 0;
00068 
00069     virtual nsresult DeactivateEntry( nsCacheEntry * entry ) = 0;
00070     virtual nsresult BindEntry( nsCacheEntry * entry ) = 0;
00071     virtual void     DoomEntry( nsCacheEntry * entry ) = 0;
00072 
00073     virtual nsresult OpenInputStreamForEntry(nsCacheEntry *     entry,
00074                                              nsCacheAccessMode  mode,
00075                                              PRUint32           offset,
00076                                              nsIInputStream **  result) = 0;
00077 
00078     virtual nsresult OpenOutputStreamForEntry(nsCacheEntry *     entry,
00079                                               nsCacheAccessMode  mode,
00080                                               PRUint32           offset,
00081                                               nsIOutputStream ** result) = 0;
00082 
00083     virtual nsresult GetFileForEntry( nsCacheEntry *    entry,
00084                                       nsIFile **        result ) = 0;
00085 
00086     virtual nsresult OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize ) = 0;
00087 
00088     virtual nsresult Visit(nsICacheVisitor * visitor) = 0;
00089 
00094     virtual nsresult EvictEntries(const char * clientID) = 0;
00095 };
00096 
00097 #endif // _nsCacheDevice_h_