2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2018-11-30 15:39:55 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-01-15 00:26:47 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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 _nsCacheService_h_
|
|
|
|
#define _nsCacheService_h_
|
|
|
|
|
|
|
|
#include "nsICacheService.h"
|
2001-02-26 14:55:58 +00:00
|
|
|
#include "nsCacheSession.h"
|
2001-02-23 13:18:01 +00:00
|
|
|
#include "nsCacheDevice.h"
|
|
|
|
#include "nsCacheEntry.h"
|
2012-09-17 21:31:46 +00:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsICacheListener.h"
|
2001-05-03 02:35:26 +00:00
|
|
|
|
2006-06-27 23:13:48 +00:00
|
|
|
#include "prthread.h"
|
2001-03-13 01:59:43 +00:00
|
|
|
#include "nsIObserver.h"
|
2001-03-20 22:42:03 +00:00
|
|
|
#include "nsString.h"
|
2006-06-27 23:13:48 +00:00
|
|
|
#include "nsTArray.h"
|
2012-06-04 14:12:24 +00:00
|
|
|
#include "nsRefPtrHashtable.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 04:29:02 +00:00
|
|
|
#include "mozilla/CondVar.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
2012-06-29 23:20:34 +00:00
|
|
|
#include "mozilla/Telemetry.h"
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-02-26 15:53:31 +00:00
|
|
|
class nsCacheRequest;
|
2001-06-28 01:30:26 +00:00
|
|
|
class nsCacheProfilePrefObserver;
|
2007-05-14 20:09:20 +00:00
|
|
|
class nsOfflineCacheDevice;
|
2006-06-27 23:13:48 +00:00
|
|
|
class nsCacheServiceAutoLock;
|
2012-01-06 15:19:10 +00:00
|
|
|
class nsITimer;
|
2013-04-10 00:21:07 +00:00
|
|
|
class mozIStorageService;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2012-09-17 21:31:46 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* nsNotifyDoomListener
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2016-04-26 00:23:21 +00:00
|
|
|
class nsNotifyDoomListener : public mozilla::Runnable {
|
2012-09-17 21:31:46 +00:00
|
|
|
public:
|
2017-06-12 19:34:10 +00:00
|
|
|
nsNotifyDoomListener(nsICacheListener *listener, nsresult status)
|
|
|
|
: mozilla::Runnable("nsNotifyDoomListener"),
|
|
|
|
mListener(listener) // transfers reference
|
|
|
|
,
|
|
|
|
mStatus(status) {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-06-12 19:34:10 +00:00
|
|
|
NS_IMETHOD Run() override {
|
|
|
|
mListener->OnCacheEntryDoomed(mStatus);
|
|
|
|
NS_RELEASE(mListener);
|
|
|
|
return NS_OK;
|
2012-09-17 21:31:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsICacheListener *mListener;
|
|
|
|
nsresult mStatus;
|
|
|
|
};
|
|
|
|
|
2001-03-20 22:42:03 +00:00
|
|
|
/******************************************************************************
|
2001-02-23 13:18:01 +00:00
|
|
|
* nsCacheService
|
2001-03-20 22:42:03 +00:00
|
|
|
******************************************************************************/
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2019-02-07 03:49:00 +00:00
|
|
|
class nsCacheService final : public nsICacheServiceInternal {
|
2014-06-24 16:36:44 +00:00
|
|
|
virtual ~nsCacheService();
|
2013-01-15 00:26:47 +00:00
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
public:
|
2013-07-19 02:24:13 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_DECL_NSICACHESERVICE
|
2013-05-12 14:01:13 +00:00
|
|
|
NS_DECL_NSICACHESERVICEINTERNAL
|
2001-02-23 13:18:01 +00:00
|
|
|
|
|
|
|
nsCacheService();
|
|
|
|
|
|
|
|
// Define a Create method to be used with a factory:
|
|
|
|
static nsresult Create(nsISupports *outer, const nsIID &iid, void **result);
|
2001-02-26 14:55:58 +00:00
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
/**
|
|
|
|
* Methods called by nsCacheSession
|
|
|
|
*/
|
2002-08-07 01:13:29 +00:00
|
|
|
static nsresult OpenCacheEntry(nsCacheSession *session, const nsACString &key,
|
2001-03-05 10:45:33 +00:00
|
|
|
nsCacheAccessMode accessRequested,
|
|
|
|
bool blockingMode, nsICacheListener *listener,
|
|
|
|
nsICacheEntryDescriptor **result);
|
2001-03-05 07:17:58 +00:00
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
static nsresult EvictEntriesForSession(nsCacheSession *session);
|
2001-04-09 08:14:08 +00:00
|
|
|
|
2002-01-24 01:25:25 +00:00
|
|
|
static nsresult IsStorageEnabledForPolicy(nsCacheStoragePolicy storagePolicy,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *result);
|
2002-01-24 01:25:25 +00:00
|
|
|
|
2012-03-22 22:54:20 +00:00
|
|
|
static nsresult DoomEntry(nsCacheSession *session, const nsACString &key,
|
|
|
|
nsICacheListener *listener);
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
/**
|
|
|
|
* Methods called by nsCacheEntryDescriptor
|
|
|
|
*/
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
static void CloseDescriptor(nsCacheEntryDescriptor *descriptor);
|
2001-03-01 05:01:43 +00:00
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
static nsresult GetFileForEntry(nsCacheEntry *entry, nsIFile **result);
|
2001-03-02 01:51:41 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
static nsresult OpenInputStreamForEntry(nsCacheEntry *entry,
|
|
|
|
nsCacheAccessMode mode,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t offset,
|
2003-01-18 02:15:14 +00:00
|
|
|
nsIInputStream **result);
|
|
|
|
|
|
|
|
static nsresult OpenOutputStreamForEntry(nsCacheEntry *entry,
|
|
|
|
nsCacheAccessMode mode,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t offset,
|
2003-01-18 02:15:14 +00:00
|
|
|
nsIOutputStream **result);
|
2001-03-01 05:01:43 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static nsresult OnDataSizeChange(nsCacheEntry *entry, int32_t deltaSize);
|
2002-08-07 01:13:29 +00:00
|
|
|
|
|
|
|
static nsresult SetCacheElement(nsCacheEntry *entry, nsISupports *element);
|
|
|
|
|
|
|
|
static nsresult ValidateEntry(nsCacheEntry *entry);
|
2001-02-26 14:55:58 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t CacheCompressionLevel();
|
2001-03-08 21:22:18 +00:00
|
|
|
|
2012-12-14 17:03:01 +00:00
|
|
|
static bool GetClearingEntries();
|
|
|
|
|
2014-04-25 11:02:36 +00:00
|
|
|
static void GetCacheBaseDirectoty(nsIFile **result);
|
2014-02-05 19:29:54 +00:00
|
|
|
static void GetDiskCacheDirectory(nsIFile **result);
|
2014-04-25 11:02:36 +00:00
|
|
|
static void GetAppCacheDirectory(nsIFile **result);
|
2014-02-05 19:29:54 +00:00
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
/**
|
|
|
|
* Methods called by any cache classes
|
|
|
|
*/
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
static nsCacheService *GlobalInstance() { return gService; }
|
2011-07-19 01:22:36 +00:00
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
static nsresult DoomEntry(nsCacheEntry *entry);
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsStorageEnabledForPolicy_Locked(nsCacheStoragePolicy policy);
|
2001-06-06 02:30:07 +00:00
|
|
|
|
2012-04-30 17:57:09 +00:00
|
|
|
/**
|
|
|
|
* Methods called by nsApplicationCacheService
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsresult GetOfflineDevice(nsOfflineCacheDevice **aDevice);
|
|
|
|
|
2012-06-04 14:12:24 +00:00
|
|
|
/**
|
|
|
|
* Creates an offline cache device that works over a specific profile
|
|
|
|
* directory. A tool to preload offline cache for profiles different from the
|
|
|
|
* current application's profile directory.
|
|
|
|
*/
|
2012-06-06 02:08:30 +00:00
|
|
|
nsresult GetCustomOfflineDevice(nsIFile *aProfileDir, int32_t aQuota,
|
2012-06-04 14:12:24 +00:00
|
|
|
nsOfflineCacheDevice **aDevice);
|
|
|
|
|
2006-06-27 23:13:48 +00: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,
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIEventTarget *target = nullptr);
|
2006-06-27 23:13:48 +00:00
|
|
|
|
2010-09-15 18:42:38 +00:00
|
|
|
static nsresult DispatchToCacheIOThread(nsIRunnable *event);
|
|
|
|
|
2011-01-20 21:41:10 +00: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();
|
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
/**
|
2001-06-28 01:30:26 +00:00
|
|
|
* Methods called by nsCacheProfilePrefObserver
|
2018-11-30 10:46:48 +00:00
|
|
|
*/
|
2014-12-30 19:09:09 +00:00
|
|
|
static void OnProfileShutdown();
|
2001-08-17 00:01:01 +00:00
|
|
|
static void OnProfileChanged();
|
2010-09-15 18:42:38 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static void SetOfflineCacheEnabled(bool enabled);
|
2008-12-15 05:57:24 +00:00
|
|
|
// Sets the offline cache capacity (in kilobytes)
|
2012-08-22 15:56:38 +00:00
|
|
|
static void SetOfflineCacheCapacity(int32_t capacity);
|
2001-06-28 01:30:26 +00:00
|
|
|
|
2011-10-19 12:35:57 +00:00
|
|
|
static void MoveOrRemoveDiskCache(nsIFile *aOldCacheDir,
|
2011-12-24 03:21:17 +00:00
|
|
|
nsIFile *aNewCacheDir,
|
|
|
|
const char *aCacheSubdir);
|
2011-10-19 12:35:57 +00:00
|
|
|
|
2013-02-11 14:47:21 +00:00
|
|
|
nsresult Init();
|
2004-10-31 21:58:51 +00:00
|
|
|
void Shutdown();
|
2013-02-11 14:47:21 +00:00
|
|
|
|
2012-11-09 15:34:03 +00:00
|
|
|
static bool IsInitialized() {
|
|
|
|
if (!gService) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return gService->mInitialized;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2012-11-09 15:34:03 +00: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 04:29:02 +00:00
|
|
|
static void AssertOwnsLock() { gService->mLock.AssertCurrentThreadOwns(); }
|
|
|
|
|
2012-05-24 15:31:54 +00:00
|
|
|
static void LeavePrivateBrowsing();
|
2012-08-20 12:08:46 +00:00
|
|
|
bool IsDoomListEmpty();
|
2012-05-24 15:31:54 +00:00
|
|
|
|
|
|
|
typedef bool (*DoomCheckFn)(nsCacheEntry *entry);
|
|
|
|
|
2014-06-05 18:14:07 +00:00
|
|
|
// Accessors to the disabled functionality
|
|
|
|
nsresult CreateSessionInternal(const char *clientID,
|
|
|
|
nsCacheStoragePolicy storagePolicy,
|
|
|
|
bool streamBased, nsICacheSession **result);
|
|
|
|
nsresult VisitEntriesInternal(nsICacheVisitor *visitor);
|
|
|
|
nsresult EvictEntriesInternal(nsCacheStoragePolicy storagePolicy);
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
private:
|
2006-06-27 23:13:48 +00:00
|
|
|
friend class nsCacheServiceAutoLock;
|
2008-08-26 23:09:02 +00:00
|
|
|
friend class nsOfflineCacheDevice;
|
2010-08-24 01:06:23 +00:00
|
|
|
friend class nsProcessRequestEvent;
|
2011-01-20 21:41:10 +00:00
|
|
|
friend class nsBlockOnCacheThreadEvent;
|
2012-03-22 22:54:20 +00:00
|
|
|
friend class nsDoomEvent;
|
2012-09-17 21:31:46 +00:00
|
|
|
friend class nsAsyncDoomEvent;
|
|
|
|
friend class nsCacheEntryDescriptor;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
/**
|
|
|
|
* Internal Methods
|
|
|
|
*/
|
2001-03-23 21:06:39 +00:00
|
|
|
|
2015-08-05 00:19:09 +00:00
|
|
|
static void Lock();
|
2017-02-15 19:15:15 +00:00
|
|
|
static void Lock(::mozilla::Telemetry::HistogramID mainThreadLockerID);
|
2006-06-27 23:13:48 +00:00
|
|
|
static void Unlock();
|
2013-05-12 14:01:13 +00:00
|
|
|
void LockAcquired();
|
|
|
|
void LockReleased();
|
2006-06-27 23:13:48 +00:00
|
|
|
|
2001-03-23 21:06:39 +00:00
|
|
|
nsresult CreateDiskDevice();
|
2007-03-14 01:52:07 +00:00
|
|
|
nsresult CreateOfflineDevice();
|
2012-06-06 02:08:30 +00:00
|
|
|
nsresult CreateCustomOfflineDevice(nsIFile *aProfileDir, int32_t aQuota,
|
2012-06-04 14:12:24 +00:00
|
|
|
nsOfflineCacheDevice **aDevice);
|
2001-03-29 05:54:58 +00:00
|
|
|
nsresult CreateMemoryDevice();
|
2001-03-23 21:06:39 +00:00
|
|
|
|
2012-07-11 18:20:17 +00:00
|
|
|
nsresult RemoveCustomOfflineDevice(nsOfflineCacheDevice *aDevice);
|
|
|
|
|
2001-03-05 10:45:33 +00:00
|
|
|
nsresult CreateRequest(nsCacheSession *session, const nsACString &clientKey,
|
|
|
|
nsCacheAccessMode accessRequested, bool blockingMode,
|
|
|
|
nsICacheListener *listener, nsCacheRequest **request);
|
|
|
|
|
2010-10-25 22:47:40 +00:00
|
|
|
nsresult DoomEntry_Internal(nsCacheEntry *entry,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool doProcessPendingRequests);
|
2002-08-07 01:13:29 +00:00
|
|
|
|
|
|
|
nsresult EvictEntriesForClient(const char *clientID,
|
|
|
|
nsCacheStoragePolicy storagePolicy);
|
|
|
|
|
2006-06-27 23:13:48 +00: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 10:45:33 +00:00
|
|
|
nsresult NotifyListener(nsCacheRequest *request,
|
|
|
|
nsICacheEntryDescriptor *descriptor,
|
|
|
|
nsCacheAccessMode accessGranted, nsresult error);
|
|
|
|
|
2010-10-25 22:47:40 +00:00
|
|
|
nsresult ActivateEntry(nsCacheRequest *request, nsCacheEntry **entry,
|
|
|
|
nsCacheEntry **doomedEntry);
|
2001-03-05 10:45:33 +00:00
|
|
|
|
|
|
|
nsCacheDevice *EnsureEntryHasDevice(nsCacheEntry *entry);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
nsCacheEntry *SearchCacheDevices(nsCString *key, nsCacheStoragePolicy policy,
|
|
|
|
bool *collision);
|
2001-02-26 14:55:58 +00:00
|
|
|
|
2001-03-05 10:45:33 +00:00
|
|
|
void DeactivateEntry(nsCacheEntry *entry);
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-05-09 03:36:00 +00:00
|
|
|
nsresult ProcessRequest(nsCacheRequest *request,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool calledFromOpenCacheEntry,
|
2001-03-05 10:45:33 +00:00
|
|
|
nsICacheEntryDescriptor **result);
|
2001-02-24 01:02:37 +00:00
|
|
|
|
2001-03-05 10:45:33 +00:00
|
|
|
nsresult ProcessPendingRequests(nsCacheEntry *entry);
|
2001-02-24 01:02:37 +00:00
|
|
|
|
2001-03-13 15:43:17 +00:00
|
|
|
void ClearDoomList(void);
|
2012-05-24 15:31:54 +00:00
|
|
|
void DoomActiveEntries(DoomCheckFn check);
|
2012-12-14 17:03:01 +00:00
|
|
|
void CloseAllStreams();
|
2013-06-18 05:44:00 +00:00
|
|
|
void FireClearNetworkCacheStoredAnywhereNotification();
|
2001-03-13 15:43:17 +00:00
|
|
|
|
2001-04-04 03:30:45 +00:00
|
|
|
void LogCacheStatistics();
|
2001-05-08 00:13:21 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
/**
|
|
|
|
* Data Members
|
|
|
|
*/
|
|
|
|
|
2001-06-28 01:30:26 +00:00
|
|
|
static nsCacheService *gService; // there can be only one...
|
2013-01-15 00:26:47 +00:00
|
|
|
|
2013-04-10 00:21:07 +00:00
|
|
|
nsCOMPtr<mozIStorageService> mStorageService;
|
|
|
|
|
2001-06-28 01:30:26 +00:00
|
|
|
nsCacheProfilePrefObserver *mObserver;
|
2013-01-15 00:26:47 +00: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 04:29:02 +00:00
|
|
|
mozilla::Mutex mLock;
|
|
|
|
mozilla::CondVar mCondVar;
|
2016-05-13 06:56:22 +00:00
|
|
|
bool mNotified;
|
2006-06-27 23:13:48 +00:00
|
|
|
|
2013-05-12 14:01:13 +00:00
|
|
|
mozilla::Mutex mTimeStampLock;
|
|
|
|
mozilla::TimeStamp mLockAcquiredTimeStamp;
|
|
|
|
|
2010-08-24 01:06:23 +00:00
|
|
|
nsCOMPtr<nsIThread> mCacheIOThread;
|
|
|
|
|
2006-06-27 23:13:48 +00:00
|
|
|
nsTArray<nsISupports *> mDoomedObjects;
|
2013-01-15 00:26:47 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInitialized;
|
2012-04-12 16:24:57 +00:00
|
|
|
bool mClearingEntries;
|
2013-01-15 00:26:47 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mEnableOfflineDevice;
|
2001-03-29 05:54:58 +00:00
|
|
|
|
2007-05-14 20:09:20 +00:00
|
|
|
nsOfflineCacheDevice *mOfflineDevice;
|
2001-02-27 05:35:53 +00:00
|
|
|
|
2012-06-04 14:12:24 +00:00
|
|
|
nsRefPtrHashtable<nsStringHashKey, nsOfflineCacheDevice>
|
|
|
|
mCustomOfflineDevices;
|
|
|
|
|
2001-06-28 01:30:26 +00:00
|
|
|
nsCacheEntryHashTable mActiveEntries;
|
|
|
|
PRCList mDoomedEntries;
|
2001-03-02 01:51:41 +00:00
|
|
|
|
2001-03-13 15:43:17 +00:00
|
|
|
// stats
|
2013-01-15 00:26:47 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mTotalEntries;
|
|
|
|
uint32_t mCacheHits;
|
|
|
|
uint32_t mCacheMisses;
|
|
|
|
uint32_t mMaxKeyLength;
|
|
|
|
uint32_t mMaxDataSize;
|
|
|
|
uint32_t mMaxMetaSize;
|
2001-03-13 15:43:17 +00:00
|
|
|
|
2001-03-02 01:51:41 +00:00
|
|
|
// Unexpected error totals
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mDeactivateFailures;
|
|
|
|
uint32_t mDeactivatedUnboundEntries;
|
2001-02-23 13:18:01 +00:00
|
|
|
};
|
|
|
|
|
2006-06-27 23:13:48 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* nsCacheServiceAutoLock
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-06-29 23:20:34 +00:00
|
|
|
#define LOCK_TELEM(x) \
|
|
|
|
(::mozilla::Telemetry::CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_##x)
|
|
|
|
|
2006-06-27 23:13:48 +00:00
|
|
|
// Instantiate this class to acquire the cache service lock for a particular
|
|
|
|
// execution scope.
|
|
|
|
class nsCacheServiceAutoLock {
|
|
|
|
public:
|
2015-08-05 00:19:09 +00:00
|
|
|
nsCacheServiceAutoLock() { nsCacheService::Lock(); }
|
2017-02-15 19:15:15 +00:00
|
|
|
explicit nsCacheServiceAutoLock(
|
|
|
|
mozilla::Telemetry::HistogramID mainThreadLockerID) {
|
2012-06-29 23:20:34 +00:00
|
|
|
nsCacheService::Lock(mainThreadLockerID);
|
2006-06-27 23:13:48 +00:00
|
|
|
}
|
|
|
|
~nsCacheServiceAutoLock() { nsCacheService::Unlock(); }
|
|
|
|
};
|
2001-02-23 13:18:01 +00:00
|
|
|
|
|
|
|
#endif // _nsCacheService_h_
|