mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 669117 - Add a memory reporter for the Necko memory cache. r=khuey,jduell.
This commit is contained in:
parent
d8af27d8bc
commit
44f3c270fd
26
netwerk/cache/nsCacheService.cpp
vendored
26
netwerk/cache/nsCacheService.cpp
vendored
@ -57,6 +57,7 @@
|
||||
#include "nsDiskCacheDeviceSQL.h"
|
||||
#endif
|
||||
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
@ -1002,6 +1003,15 @@ private:
|
||||
*****************************************************************************/
|
||||
nsCacheService * nsCacheService::gService = nsnull;
|
||||
|
||||
static nsCOMPtr<nsIMemoryReporter> MemoryCacheReporter = nsnull;
|
||||
|
||||
NS_THREADSAFE_MEMORY_REPORTER_IMPLEMENT(NetworkMemoryCache,
|
||||
"explicit/network-memory-cache",
|
||||
KIND_HEAP,
|
||||
UNITS_BYTES,
|
||||
nsCacheService::MemoryDeviceSize,
|
||||
"Memory used by the network memory cache.")
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCacheService, nsICacheService)
|
||||
|
||||
nsCacheService::nsCacheService()
|
||||
@ -1102,6 +1112,11 @@ nsCacheService::Shutdown()
|
||||
// proceeding with destructive actions (bug #620660)
|
||||
(void) SyncWithCacheIOThread();
|
||||
|
||||
// unregister memory reporter, before deleting the memory device, just
|
||||
// to be safe
|
||||
NS_UnregisterMemoryReporter(MemoryCacheReporter);
|
||||
MemoryCacheReporter = nsnull;
|
||||
|
||||
// deallocate memory and disk caches
|
||||
delete mMemoryDevice;
|
||||
mMemoryDevice = nsnull;
|
||||
@ -1443,6 +1458,11 @@ nsCacheService::CreateMemoryDevice()
|
||||
delete mMemoryDevice;
|
||||
mMemoryDevice = nsnull;
|
||||
}
|
||||
|
||||
MemoryCacheReporter =
|
||||
new NS_MEMORY_REPORTER_NAME(NetworkMemoryCache);
|
||||
NS_RegisterMemoryReporter(MemoryCacheReporter);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1913,6 +1933,12 @@ nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry)
|
||||
return device;
|
||||
}
|
||||
|
||||
PRInt64
|
||||
nsCacheService::MemoryDeviceSize()
|
||||
{
|
||||
nsMemoryCacheDevice *memoryDevice = GlobalInstance()->mMemoryDevice;
|
||||
return memoryDevice ? memoryDevice->TotalSize() : 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCacheService::DoomEntry(nsCacheEntry * entry)
|
||||
|
3
netwerk/cache/nsCacheService.h
vendored
3
netwerk/cache/nsCacheService.h
vendored
@ -131,6 +131,9 @@ public:
|
||||
|
||||
static
|
||||
nsCacheService * GlobalInstance() { return gService; }
|
||||
|
||||
static
|
||||
PRInt64 MemoryDeviceSize();
|
||||
|
||||
static nsresult DoomEntry(nsCacheEntry * entry);
|
||||
|
||||
|
5
netwerk/cache/nsMemoryCacheDevice.cpp
vendored
5
netwerk/cache/nsMemoryCacheDevice.cpp
vendored
@ -307,6 +307,11 @@ nsMemoryCacheDevice::EntryIsTooBig(PRInt64 entrySize)
|
||||
return (entrySize > mSoftLimit || entrySize > mMaxEntrySize);
|
||||
}
|
||||
|
||||
size_t
|
||||
nsMemoryCacheDevice::TotalSize()
|
||||
{
|
||||
return mTotalSize;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMemoryCacheDevice::OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize)
|
||||
|
3
netwerk/cache/nsMemoryCacheDevice.h
vendored
3
netwerk/cache/nsMemoryCacheDevice.h
vendored
@ -91,6 +91,9 @@ public:
|
||||
void SetMaxEntrySize(PRInt32 maxSizeInKilobytes);
|
||||
|
||||
bool EntryIsTooBig(PRInt64 entrySize);
|
||||
|
||||
size_t TotalSize();
|
||||
|
||||
private:
|
||||
friend class nsMemoryCacheDeviceInfo;
|
||||
enum { DELETE_ENTRY = PR_TRUE,
|
||||
|
@ -247,7 +247,7 @@ interface nsIMemoryReporterManager : nsISupports
|
||||
/*
|
||||
* Note that this defaults 'process' to "", which is usually what's desired.
|
||||
*/
|
||||
#define NS_MEMORY_REPORTER_IMPLEMENT(_classname, _path, _kind, _units, _amountFunction, _desc) \
|
||||
#define NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_classname, _path, _kind, _units, _amountFunction, _desc, _ts) \
|
||||
class MemoryReporter_##_classname : public nsIMemoryReporter { \
|
||||
public: \
|
||||
NS_DECL_ISUPPORTS \
|
||||
@ -258,7 +258,12 @@ interface nsIMemoryReporterManager : nsISupports
|
||||
NS_IMETHOD GetAmount(PRInt64 *amount) { *amount = _amountFunction(); return NS_OK; } \
|
||||
NS_IMETHOD GetDescription(nsACString &desc) { desc.Assign(_desc); return NS_OK; } \
|
||||
}; \
|
||||
NS_IMPL_ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter)
|
||||
NS_IMPL##_ts##ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter)
|
||||
|
||||
#define NS_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
|
||||
NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_c, _p, _k, _u, _a, _d, _)
|
||||
#define NS_THREADSAFE_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
|
||||
NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_c, _p, _k, _u, _a, _d, _THREADSAFE_)
|
||||
|
||||
#define NS_MEMORY_REPORTER_NAME(_classname) MemoryReporter_##_classname
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user