Bug 936964 (part 1) - Make StartupCache ref-counted. r=aklotz.
This commit is contained in:
@@ -110,7 +110,6 @@ StartupCache::GetSingleton()
|
|||||||
void
|
void
|
||||||
StartupCache::DeleteSingleton()
|
StartupCache::DeleteSingleton()
|
||||||
{
|
{
|
||||||
delete StartupCache::gStartupCache;
|
|
||||||
StartupCache::gStartupCache = nullptr;
|
StartupCache::gStartupCache = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,17 +121,18 @@ StartupCache::InitSingleton()
|
|||||||
|
|
||||||
rv = StartupCache::gStartupCache->Init();
|
rv = StartupCache::gStartupCache->Init();
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
delete StartupCache::gStartupCache;
|
|
||||||
StartupCache::gStartupCache = nullptr;
|
StartupCache::gStartupCache = nullptr;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartupCache* StartupCache::gStartupCache;
|
StaticRefPtr<StartupCache> StartupCache::gStartupCache;
|
||||||
bool StartupCache::gShutdownInitiated;
|
bool StartupCache::gShutdownInitiated;
|
||||||
bool StartupCache::gIgnoreDiskCache;
|
bool StartupCache::gIgnoreDiskCache;
|
||||||
enum StartupCache::TelemetrifyAge StartupCache::gPostFlushAgeAction = StartupCache::IGNORE_AGE;
|
enum StartupCache::TelemetrifyAge StartupCache::gPostFlushAgeAction = StartupCache::IGNORE_AGE;
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS1(StartupCache, nsISupports)
|
||||||
|
|
||||||
StartupCache::StartupCache()
|
StartupCache::StartupCache()
|
||||||
: mArchive(nullptr), mStartupWriteInitiated(false), mWriteThread(nullptr)
|
: mArchive(nullptr), mStartupWriteInitiated(false), mWriteThread(nullptr)
|
||||||
{ }
|
{ }
|
||||||
@@ -156,7 +156,6 @@ StartupCache::~StartupCache()
|
|||||||
WriteToDisk();
|
WriteToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
gStartupCache = nullptr;
|
|
||||||
NS_UnregisterMemoryReporter(mMappingReporter);
|
NS_UnregisterMemoryReporter(mMappingReporter);
|
||||||
NS_UnregisterMemoryReporter(mDataReporter);
|
NS_UnregisterMemoryReporter(mDataReporter);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
|
#include "mozilla/StaticPtr.h"
|
||||||
|
|
||||||
class nsIMemoryReporter;
|
class nsIMemoryReporter;
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ class nsIMemoryReporter;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
namespace scache {
|
namespace scache {
|
||||||
|
|
||||||
struct CacheEntry
|
struct CacheEntry
|
||||||
@@ -96,13 +98,14 @@ class StartupCacheListener MOZ_FINAL : public nsIObserver
|
|||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
};
|
};
|
||||||
|
|
||||||
class StartupCache
|
class StartupCache : public nsISupports
|
||||||
{
|
{
|
||||||
|
|
||||||
friend class StartupCacheListener;
|
friend class StartupCacheListener;
|
||||||
friend class StartupCacheWrapper;
|
friend class StartupCacheWrapper;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
// StartupCache methods. See above comments for a more detailed description.
|
// StartupCache methods. See above comments for a more detailed description.
|
||||||
|
|
||||||
@@ -136,7 +139,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
StartupCache();
|
StartupCache();
|
||||||
~StartupCache();
|
virtual ~StartupCache();
|
||||||
|
|
||||||
enum TelemetrifyAge {
|
enum TelemetrifyAge {
|
||||||
IGNORE_AGE = 0,
|
IGNORE_AGE = 0,
|
||||||
@@ -169,7 +172,7 @@ private:
|
|||||||
|
|
||||||
bool mStartupWriteInitiated;
|
bool mStartupWriteInitiated;
|
||||||
|
|
||||||
static StartupCache *gStartupCache;
|
static StaticRefPtr<StartupCache> gStartupCache;
|
||||||
static bool gShutdownInitiated;
|
static bool gShutdownInitiated;
|
||||||
static bool gIgnoreDiskCache;
|
static bool gIgnoreDiskCache;
|
||||||
PRThread *mWriteThread;
|
PRThread *mWriteThread;
|
||||||
|
|||||||
Reference in New Issue
Block a user