2001-02-23 16:18:01 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is nsCacheService.h, released
|
|
|
|
* February 10, 2001.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Gordon Sheridan <gordon@netscape.com>
|
|
|
|
* Patrick C. Beard <beard@netscape.com>
|
|
|
|
* Darin Fisher <darin@netscape.com>
|
2008-10-25 14:26:20 +04:00
|
|
|
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
|
2004-04-19 02:01:16 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-02-23 16:18:01 +03:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef _nsCacheService_h_
|
|
|
|
#define _nsCacheService_h_
|
|
|
|
|
|
|
|
#include "nsICacheService.h"
|
2001-02-26 17:55:58 +03:00
|
|
|
#include "nsCacheSession.h"
|
2001-02-23 16:18:01 +03:00
|
|
|
#include "nsCacheDevice.h"
|
|
|
|
#include "nsCacheEntry.h"
|
2001-05-03 06:35:26 +04:00
|
|
|
|
2006-06-28 03:13:48 +04:00
|
|
|
#include "prthread.h"
|
2001-03-13 04:59:43 +03:00
|
|
|
#include "nsIObserver.h"
|
2001-03-21 01:42:03 +03:00
|
|
|
#include "nsString.h"
|
2006-06-28 03:13:48 +04:00
|
|
|
#include "nsTArray.h"
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
#include "mozilla/CondVar.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-02-26 18:53:31 +03:00
|
|
|
class nsCacheRequest;
|
2001-06-28 05:30:26 +04:00
|
|
|
class nsCacheProfilePrefObserver;
|
|
|
|
class nsDiskCacheDevice;
|
|
|
|
class nsMemoryCacheDevice;
|
2007-05-15 00:09:20 +04:00
|
|
|
class nsOfflineCacheDevice;
|
2006-06-28 03:13:48 +04:00
|
|
|
class nsCacheServiceAutoLock;
|
2012-01-06 19:19:10 +04:00
|
|
|
class nsITimer;
|
2001-02-23 16:18:01 +03:00
|
|
|
|
|
|
|
|
2001-03-21 01:42:03 +03:00
|
|
|
/******************************************************************************
|
2001-02-23 16:18:01 +03:00
|
|
|
* nsCacheService
|
2001-03-21 01:42:03 +03:00
|
|
|
******************************************************************************/
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-06-28 05:30:26 +04:00
|
|
|
class nsCacheService : public nsICacheService
|
2001-02-23 16:18:01 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICACHESERVICE
|
|
|
|
|
|
|
|
nsCacheService();
|
|
|
|
virtual ~nsCacheService();
|
|
|
|
|
|
|
|
// Define a Create method to be used with a factory:
|
2010-06-10 22:11:40 +04:00
|
|
|
static nsresult
|
2001-02-23 16:18:01 +03:00
|
|
|
Create(nsISupports* outer, const nsIID& iid, void* *result);
|
|
|
|
|
2001-02-26 17:55:58 +03:00
|
|
|
|
2001-02-28 07:10:43 +03:00
|
|
|
/**
|
|
|
|
* Methods called by nsCacheSession
|
|
|
|
*/
|
2002-08-07 05:13:29 +04:00
|
|
|
static nsresult OpenCacheEntry(nsCacheSession * session,
|
2005-01-13 06:25:28 +03:00
|
|
|
const nsACString & key,
|
2001-03-05 13:45:33 +03:00
|
|
|
nsCacheAccessMode accessRequested,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool blockingMode,
|
2001-03-05 13:45:33 +03:00
|
|
|
nsICacheListener * listener,
|
|
|
|
nsICacheEntryDescriptor ** result);
|
2001-03-05 10:17:58 +03:00
|
|
|
|
2002-08-07 05:13:29 +04:00
|
|
|
static nsresult EvictEntriesForSession(nsCacheSession * session);
|
2001-04-09 12:14:08 +04:00
|
|
|
|
2002-01-24 04:25:25 +03:00
|
|
|
static nsresult IsStorageEnabledForPolicy(nsCacheStoragePolicy storagePolicy,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool * result);
|
2002-01-24 04:25:25 +03:00
|
|
|
|
2012-03-23 02:54:20 +04:00
|
|
|
static nsresult DoomEntry(nsCacheSession *session,
|
|
|
|
const nsACString &key,
|
|
|
|
nsICacheListener *listener);
|
|
|
|
|
2001-02-28 07:10:43 +03:00
|
|
|
/**
|
|
|
|
* Methods called by nsCacheEntryDescriptor
|
|
|
|
*/
|
|
|
|
|
2002-08-07 05:13:29 +04:00
|
|
|
static void CloseDescriptor(nsCacheEntryDescriptor * descriptor);
|
2001-03-01 08:01:43 +03:00
|
|
|
|
2002-08-07 05:13:29 +04:00
|
|
|
static nsresult GetFileForEntry(nsCacheEntry * entry,
|
|
|
|
nsIFile ** result);
|
2001-03-02 04:51:41 +03:00
|
|
|
|
2003-01-18 05:15:14 +03:00
|
|
|
static nsresult OpenInputStreamForEntry(nsCacheEntry * entry,
|
|
|
|
nsCacheAccessMode mode,
|
|
|
|
PRUint32 offset,
|
|
|
|
nsIInputStream ** result);
|
|
|
|
|
|
|
|
static nsresult OpenOutputStreamForEntry(nsCacheEntry * entry,
|
|
|
|
nsCacheAccessMode mode,
|
|
|
|
PRUint32 offset,
|
|
|
|
nsIOutputStream ** result);
|
2001-03-01 08:01:43 +03:00
|
|
|
|
2002-08-07 05:13:29 +04:00
|
|
|
static nsresult OnDataSizeChange(nsCacheEntry * entry, PRInt32 deltaSize);
|
|
|
|
|
|
|
|
static nsresult SetCacheElement(nsCacheEntry * entry, nsISupports * element);
|
|
|
|
|
|
|
|
static nsresult ValidateEntry(nsCacheEntry * entry);
|
2001-02-26 17:55:58 +03:00
|
|
|
|
2011-12-17 14:30:29 +04:00
|
|
|
static PRInt32 CacheCompressionLevel();
|
2001-03-09 00:22:18 +03:00
|
|
|
|
2001-02-28 07:10:43 +03:00
|
|
|
/**
|
|
|
|
* Methods called by any cache classes
|
|
|
|
*/
|
|
|
|
|
|
|
|
static
|
2002-08-07 05:13:29 +04:00
|
|
|
nsCacheService * GlobalInstance() { return gService; }
|
2011-07-19 05:22:36 +04:00
|
|
|
|
2012-04-10 09:52:33 +04:00
|
|
|
static PRInt64 MemoryDeviceSize();
|
2002-08-07 05:13:29 +04:00
|
|
|
|
|
|
|
static nsresult DoomEntry(nsCacheEntry * entry);
|
2001-02-28 07:10:43 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool IsStorageEnabledForPolicy_Locked(nsCacheStoragePolicy policy);
|
2001-06-06 06:30:07 +04:00
|
|
|
|
2012-04-30 21:57:09 +04:00
|
|
|
/**
|
|
|
|
* Methods called by nsApplicationCacheService
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsresult GetOfflineDevice(nsOfflineCacheDevice ** aDevice);
|
|
|
|
|
2006-06-28 03:13:48 +04:00
|
|
|
// This method may be called to release an object while the cache service
|
|
|
|
// lock is being held. If a non-null target is specified and the target
|
|
|
|
// does not correspond to the current thread, then the release will be
|
|
|
|
// proxied to the specified target. Otherwise, the object will be added to
|
|
|
|
// the list of objects to be released when the cache service is unlocked.
|
|
|
|
static void ReleaseObject_Locked(nsISupports * object,
|
|
|
|
nsIEventTarget * target = nsnull);
|
|
|
|
|
2010-09-15 22:42:38 +04:00
|
|
|
static nsresult DispatchToCacheIOThread(nsIRunnable* event);
|
|
|
|
|
2011-01-21 00:41:10 +03:00
|
|
|
// Calling this method will block the calling thread until all pending
|
|
|
|
// events on the cache-io thread has finished. The calling thread must
|
|
|
|
// hold the cache-lock
|
|
|
|
static nsresult SyncWithCacheIOThread();
|
|
|
|
|
2010-09-15 22:42:38 +04:00
|
|
|
|
2001-03-21 01:42:03 +03:00
|
|
|
/**
|
2001-06-28 05:30:26 +04:00
|
|
|
* Methods called by nsCacheProfilePrefObserver
|
2001-03-21 01:42:03 +03:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static void OnProfileShutdown(bool cleanse);
|
2001-08-17 04:01:01 +04:00
|
|
|
static void OnProfileChanged();
|
2001-06-28 05:30:26 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static void SetDiskCacheEnabled(bool enabled);
|
2008-12-15 08:57:24 +03:00
|
|
|
// Sets the disk cache capacity (in kilobytes)
|
2001-06-28 05:30:26 +04:00
|
|
|
static void SetDiskCacheCapacity(PRInt32 capacity);
|
2011-09-13 23:24:01 +04:00
|
|
|
// Set max size for a disk-cache entry (in KB). -1 disables limit up to
|
|
|
|
// 1/8th of disk cache size
|
2011-06-27 16:21:15 +04:00
|
|
|
static void SetDiskCacheMaxEntrySize(PRInt32 maxSize);
|
2011-09-13 23:24:01 +04:00
|
|
|
// Set max size for a memory-cache entry (in kilobytes). -1 disables
|
|
|
|
// limit up to 90% of memory cache size
|
2011-06-27 16:21:15 +04:00
|
|
|
static void SetMemoryCacheMaxEntrySize(PRInt32 maxSize);
|
2001-06-28 05:30:26 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static void SetOfflineCacheEnabled(bool enabled);
|
2008-12-15 08:57:24 +03:00
|
|
|
// Sets the offline cache capacity (in kilobytes)
|
2007-03-14 04:52:07 +03:00
|
|
|
static void SetOfflineCacheCapacity(PRInt32 capacity);
|
|
|
|
|
2005-10-09 23:58:06 +04:00
|
|
|
static void SetMemoryCache();
|
2001-03-21 01:42:03 +03:00
|
|
|
|
2011-12-17 14:30:29 +04:00
|
|
|
static void SetCacheCompressionLevel(PRInt32 level);
|
|
|
|
|
2008-10-25 14:26:20 +04:00
|
|
|
static void OnEnterExitPrivateBrowsing();
|
|
|
|
|
2011-10-19 16:35:57 +04:00
|
|
|
// Starts smart cache size computation if disk device is available
|
2011-12-24 07:21:17 +04:00
|
|
|
static nsresult SetDiskSmartSize();
|
2011-10-19 16:35:57 +04:00
|
|
|
|
2004-11-01 00:58:51 +03:00
|
|
|
nsresult Init();
|
|
|
|
void Shutdown();
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
|
|
|
|
static void AssertOwnsLock()
|
|
|
|
{ gService->mLock.AssertCurrentThreadOwns(); }
|
|
|
|
|
2001-02-23 16:18:01 +03:00
|
|
|
private:
|
2006-06-28 03:13:48 +04:00
|
|
|
friend class nsCacheServiceAutoLock;
|
2008-08-27 03:09:02 +04:00
|
|
|
friend class nsOfflineCacheDevice;
|
2010-08-24 05:06:23 +04:00
|
|
|
friend class nsProcessRequestEvent;
|
2010-09-15 22:42:40 +04:00
|
|
|
friend class nsSetSmartSizeEvent;
|
2011-01-21 00:41:10 +03:00
|
|
|
friend class nsBlockOnCacheThreadEvent;
|
2012-01-06 19:19:10 +04:00
|
|
|
friend class nsSetDiskSmartSizeCallback;
|
2012-03-23 02:54:20 +04:00
|
|
|
friend class nsDoomEvent;
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-02-28 07:10:43 +03:00
|
|
|
/**
|
|
|
|
* Internal Methods
|
|
|
|
*/
|
2001-03-24 00:06:39 +03:00
|
|
|
|
2006-06-28 03:13:48 +04:00
|
|
|
static void Lock();
|
|
|
|
static void Unlock();
|
|
|
|
|
2001-03-24 00:06:39 +03:00
|
|
|
nsresult CreateDiskDevice();
|
2007-03-14 04:52:07 +03:00
|
|
|
nsresult CreateOfflineDevice();
|
2001-03-29 09:54:58 +04:00
|
|
|
nsresult CreateMemoryDevice();
|
2001-03-24 00:06:39 +03:00
|
|
|
|
2001-03-05 13:45:33 +03:00
|
|
|
nsresult CreateRequest(nsCacheSession * session,
|
2005-01-13 06:25:28 +03:00
|
|
|
const nsACString & clientKey,
|
2001-03-05 13:45:33 +03:00
|
|
|
nsCacheAccessMode accessRequested,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool blockingMode,
|
2001-03-05 13:45:33 +03:00
|
|
|
nsICacheListener * listener,
|
|
|
|
nsCacheRequest ** request);
|
|
|
|
|
2010-10-26 02:47:40 +04:00
|
|
|
nsresult DoomEntry_Internal(nsCacheEntry * entry,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool doProcessPendingRequests);
|
2002-08-07 05:13:29 +04:00
|
|
|
|
|
|
|
nsresult EvictEntriesForClient(const char * clientID,
|
|
|
|
nsCacheStoragePolicy storagePolicy);
|
|
|
|
|
2006-06-28 03:13:48 +04:00
|
|
|
// Notifies request listener asynchronously on the request's thread, and
|
|
|
|
// releases the descriptor on the request's thread. If this method fails,
|
|
|
|
// the descriptor is not released.
|
2001-03-05 13:45:33 +03:00
|
|
|
nsresult NotifyListener(nsCacheRequest * request,
|
|
|
|
nsICacheEntryDescriptor * descriptor,
|
|
|
|
nsCacheAccessMode accessGranted,
|
|
|
|
nsresult error);
|
|
|
|
|
2010-10-26 02:47:40 +04:00
|
|
|
nsresult ActivateEntry(nsCacheRequest * request,
|
|
|
|
nsCacheEntry ** entry,
|
|
|
|
nsCacheEntry ** doomedEntry);
|
2001-03-05 13:45:33 +03:00
|
|
|
|
|
|
|
nsCacheDevice * EnsureEntryHasDevice(nsCacheEntry * entry);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsCacheEntry * SearchCacheDevices(nsCString * key, nsCacheStoragePolicy policy, bool *collision);
|
2001-02-26 17:55:58 +03:00
|
|
|
|
2001-03-05 13:45:33 +03:00
|
|
|
void DeactivateEntry(nsCacheEntry * entry);
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2001-05-09 07:36:00 +04:00
|
|
|
nsresult ProcessRequest(nsCacheRequest * request,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool calledFromOpenCacheEntry,
|
2001-03-05 13:45:33 +03:00
|
|
|
nsICacheEntryDescriptor ** result);
|
2001-02-24 04:02:37 +03:00
|
|
|
|
2001-03-05 13:45:33 +03:00
|
|
|
nsresult ProcessPendingRequests(nsCacheEntry * entry);
|
2001-02-24 04:02:37 +03:00
|
|
|
|
2001-03-13 18:43:17 +03:00
|
|
|
void ClearPendingRequests(nsCacheEntry * entry);
|
|
|
|
void ClearDoomList(void);
|
|
|
|
void ClearActiveEntries(void);
|
2001-09-18 00:47:09 +04:00
|
|
|
void DoomActiveEntries(void);
|
2001-03-13 18:43:17 +03:00
|
|
|
|
|
|
|
static
|
2008-10-10 19:04:34 +04:00
|
|
|
PLDHashOperator DeactivateAndClearEntry(PLDHashTable * table,
|
|
|
|
PLDHashEntryHdr * hdr,
|
|
|
|
PRUint32 number,
|
|
|
|
void * arg);
|
2001-09-18 00:47:09 +04:00
|
|
|
static
|
2008-10-10 19:04:34 +04:00
|
|
|
PLDHashOperator RemoveActiveEntry(PLDHashTable * table,
|
|
|
|
PLDHashEntryHdr * hdr,
|
|
|
|
PRUint32 number,
|
|
|
|
void * arg);
|
2001-04-04 07:30:45 +04:00
|
|
|
#if defined(PR_LOGGING)
|
|
|
|
void LogCacheStatistics();
|
|
|
|
#endif
|
2001-05-08 04:13:21 +04:00
|
|
|
|
2012-01-06 19:19:10 +04:00
|
|
|
nsresult SetDiskSmartSize_Locked();
|
2011-10-19 16:35:57 +04:00
|
|
|
|
2001-02-23 16:18:01 +03:00
|
|
|
/**
|
|
|
|
* Data Members
|
|
|
|
*/
|
|
|
|
|
2001-06-28 05:30:26 +04:00
|
|
|
static nsCacheService * gService; // there can be only one...
|
|
|
|
|
|
|
|
nsCacheProfilePrefObserver * mObserver;
|
2001-05-03 06:35:26 +04:00
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
mozilla::Mutex mLock;
|
|
|
|
mozilla::CondVar mCondVar;
|
2006-06-28 03:13:48 +04:00
|
|
|
|
2010-08-24 05:06:23 +04:00
|
|
|
nsCOMPtr<nsIThread> mCacheIOThread;
|
|
|
|
|
2006-06-28 03:13:48 +04:00
|
|
|
nsTArray<nsISupports*> mDoomedObjects;
|
2012-01-06 19:19:10 +04:00
|
|
|
nsCOMPtr<nsITimer> mSmartSizeTimer;
|
2001-02-27 08:35:53 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInitialized;
|
2012-04-12 20:24:57 +04:00
|
|
|
bool mClearingEntries;
|
2002-08-07 05:13:29 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mEnableMemoryDevice;
|
|
|
|
bool mEnableDiskDevice;
|
|
|
|
bool mEnableOfflineDevice;
|
2001-03-29 09:54:58 +04:00
|
|
|
|
2001-06-28 05:30:26 +04:00
|
|
|
nsMemoryCacheDevice * mMemoryDevice;
|
|
|
|
nsDiskCacheDevice * mDiskDevice;
|
2007-05-15 00:09:20 +04:00
|
|
|
nsOfflineCacheDevice * mOfflineDevice;
|
2001-02-27 08:35:53 +03:00
|
|
|
|
2001-06-28 05:30:26 +04:00
|
|
|
nsCacheEntryHashTable mActiveEntries;
|
|
|
|
PRCList mDoomedEntries;
|
2001-03-02 04:51:41 +03:00
|
|
|
|
2001-03-13 18:43:17 +03:00
|
|
|
// stats
|
2001-04-04 07:30:45 +04:00
|
|
|
|
2001-06-28 05:30:26 +04:00
|
|
|
PRUint32 mTotalEntries;
|
|
|
|
PRUint32 mCacheHits;
|
|
|
|
PRUint32 mCacheMisses;
|
|
|
|
PRUint32 mMaxKeyLength;
|
|
|
|
PRUint32 mMaxDataSize;
|
|
|
|
PRUint32 mMaxMetaSize;
|
2001-03-13 18:43:17 +03:00
|
|
|
|
2001-03-02 04:51:41 +03:00
|
|
|
// Unexpected error totals
|
2001-06-28 05:30:26 +04:00
|
|
|
PRUint32 mDeactivateFailures;
|
|
|
|
PRUint32 mDeactivatedUnboundEntries;
|
2001-02-23 16:18:01 +03:00
|
|
|
};
|
|
|
|
|
2006-06-28 03:13:48 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* nsCacheServiceAutoLock
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
// Instantiate this class to acquire the cache service lock for a particular
|
|
|
|
// execution scope.
|
|
|
|
class nsCacheServiceAutoLock {
|
|
|
|
public:
|
|
|
|
nsCacheServiceAutoLock() {
|
|
|
|
nsCacheService::Lock();
|
|
|
|
}
|
|
|
|
~nsCacheServiceAutoLock() {
|
|
|
|
nsCacheService::Unlock();
|
|
|
|
}
|
|
|
|
};
|
2001-02-23 16:18:01 +03:00
|
|
|
|
|
|
|
#endif // _nsCacheService_h_
|