Bug 711297 - add recordAgesAlways method to nsIStartupCache; r=mwu

This commit is contained in:
Nathan Froyd
2012-02-22 14:07:18 -05:00
parent b78702f85e
commit 1aa812be76
3 changed files with 24 additions and 3 deletions

View File

@@ -154,6 +154,7 @@ StartupCache::InitSingleton()
StartupCache* StartupCache::gStartupCache;
bool StartupCache::gShutdownInitiated;
enum StartupCache::TelemetrifyAge StartupCache::gPostFlushAgeAction = StartupCache::IGNORE_AGE;
StartupCache::StartupCache()
: mArchive(NULL), mStartupWriteInitiated(false), mWriteThread(NULL),
@@ -494,7 +495,7 @@ StartupCache::WriteToDisk()
zipW->Close();
// Our reader's view of the archive is outdated now, reload it.
LoadArchive(IGNORE_AGE);
LoadArchive(gPostFlushAgeAction);
return;
}
@@ -506,7 +507,7 @@ StartupCache::InvalidateCache()
mTable.Clear();
mArchive = NULL;
mFile->Remove(false);
LoadArchive(IGNORE_AGE);
LoadArchive(gPostFlushAgeAction);
}
/*
@@ -602,6 +603,13 @@ StartupCache::ResetStartupWriteTimer()
return NS_OK;
}
nsresult
StartupCache::RecordAgesAlways()
{
gPostFlushAgeAction = RECORD_AGE;
return NS_OK;
}
// StartupCacheDebugOutputStream implementation
#ifdef DEBUG
NS_IMPL_ISUPPORTS3(StartupCacheDebugOutputStream, nsIObjectOutputStream,
@@ -781,5 +789,11 @@ StartupCacheWrapper::GetObserver(nsIObserver** obv) {
return NS_OK;
}
nsresult
StartupCacheWrapper::RecordAgesAlways() {
StartupCache *sc = StartupCache::GetSingleton();
return sc ? sc->RecordAgesAlways() : NS_ERROR_NOT_INITIALIZED;
}
} // namespace scache
} // namespace mozilla

View File

@@ -151,6 +151,8 @@ public:
nsresult GetDebugObjectOutputStream(nsIObjectOutputStream* aStream,
nsIObjectOutputStream** outStream);
nsresult RecordAgesAlways();
static StartupCache* GetSingleton();
static void DeleteSingleton();
@@ -168,6 +170,7 @@ private:
IGNORE_AGE = 0,
RECORD_AGE = 1
};
static enum TelemetrifyAge gPostFlushAgeAction;
nsresult LoadArchive(enum TelemetrifyAge flag);
nsresult Init();

View File

@@ -42,7 +42,7 @@
#include "nsIObserver.idl"
#include "nsIObjectOutputStream.idl"
[uuid(8c2a360b-e337-455b-8c1b-04265ef9c5a3)]
[uuid(c1b3796b-33af-4ff0-b83d-8eb0ca2c080f)]
interface nsIStartupCache : nsISupports
{
@@ -70,6 +70,10 @@ interface nsIStartupCache : nsISupports
boolean startupWriteComplete();
void resetStartupWriteTimer();
/* Instruct clients to always post cache ages to Telemetry, even in
cases where it would not normally make sense. */
void recordAgesAlways();
/* Allows clients to simulate the behavior of ObserverService. */
readonly attribute nsIObserver observer;
};