From 874bb2a08c4d902d8d36dada04fbf20a2902c597 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 22 Feb 2012 14:07:18 -0500 Subject: [PATCH] Bug 711297 - add recordAgesAlways method to nsIStartupCache; r=mwu --- startupcache/StartupCache.cpp | 18 ++++++++++++++++-- startupcache/StartupCache.h | 3 +++ startupcache/nsIStartupCache.idl | 6 +++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index 180d58db5fc..2d06b0b159a 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -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 diff --git a/startupcache/StartupCache.h b/startupcache/StartupCache.h index ad328558e57..8bfe48bd23f 100644 --- a/startupcache/StartupCache.h +++ b/startupcache/StartupCache.h @@ -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(); diff --git a/startupcache/nsIStartupCache.idl b/startupcache/nsIStartupCache.idl index 542947d7eb8..ccc03c46cbb 100644 --- a/startupcache/nsIStartupCache.idl +++ b/startupcache/nsIStartupCache.idl @@ -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; };