Backed out aef22bc75f1f (bug 711297) - wrong comment in commit

This commit is contained in:
Vladan Djeric
2012-02-22 14:02:02 -05:00
parent 9af17ba5b4
commit b6fb90cf0d
3 changed files with 8 additions and 54 deletions

View File

@@ -40,7 +40,6 @@
#include "prio.h" #include "prio.h"
#include "prtypes.h" #include "prtypes.h"
#include "pldhash.h" #include "pldhash.h"
#include "nsXPCOMStrings.h"
#include "mozilla/scache/StartupCache.h" #include "mozilla/scache/StartupCache.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
@@ -67,7 +66,6 @@
#include "mozilla/Omnijar.h" #include "mozilla/Omnijar.h"
#include "prenv.h" #include "prenv.h"
#include "mozilla/FunctionTimer.h" #include "mozilla/FunctionTimer.h"
#include "mozilla/Telemetry.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
#include "nsIProtocolHandler.h" #include "nsIProtocolHandler.h"
@@ -239,7 +237,7 @@ StartupCache::Init()
false); false);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = LoadArchive(RECORD_AGE); rv = LoadArchive();
// Sometimes we don't have a cache yet, that's ok. // Sometimes we don't have a cache yet, that's ok.
// If it's corrupted, just remove it and start over. // If it's corrupted, just remove it and start over.
@@ -260,7 +258,7 @@ StartupCache::Init()
* LoadArchive can be called from the main thread or while reloading cache on write thread. * LoadArchive can be called from the main thread or while reloading cache on write thread.
*/ */
nsresult nsresult
StartupCache::LoadArchive(enum TelemetrifyAge flag) StartupCache::LoadArchive()
{ {
bool exists; bool exists;
mArchive = NULL; mArchive = NULL;
@@ -269,34 +267,7 @@ StartupCache::LoadArchive(enum TelemetrifyAge flag)
return NS_ERROR_FILE_NOT_FOUND; return NS_ERROR_FILE_NOT_FOUND;
mArchive = new nsZipArchive(); mArchive = new nsZipArchive();
rv = mArchive->OpenArchive(mFile); return mArchive->OpenArchive(mFile);
if (NS_FAILED(rv) || flag == IGNORE_AGE)
return rv;
nsCString comment;
if (!mArchive->GetComment(comment)) {
return rv;
}
const char *data;
size_t len = NS_CStringGetData(comment, &data);
PRTime creationStamp;
// We might not have a comment if the startup cache file was created
// before we started recording creation times in the comment.
if (len == sizeof(creationStamp)) {
memcpy(&creationStamp, data, len);
PRTime current = PR_Now();
PRInt64 diff = current - creationStamp;
// We can't use AccumulateTimeDelta here because we have no way of
// reifying a TimeStamp from creationStamp.
PRInt64 usec_per_hour = PR_USEC_PER_SEC * PRInt64(3600);
PRInt64 hour_diff = (diff + usec_per_hour - 1) / usec_per_hour;
mozilla::Telemetry::Accumulate(Telemetry::STARTUP_CACHE_AGE_HOURS,
hour_diff);
}
return rv;
} }
namespace { namespace {
@@ -464,17 +435,6 @@ StartupCache::WriteToDisk()
return; return;
} }
// If we didn't have an mArchive member, that means that we failed to
// open the startup cache for reading. Therefore, we need to record
// the time of creation in a zipfile comment; this will be useful for
// Telemetry statistics.
PRTime now = PR_Now();
if (!mArchive) {
nsCString comment;
comment.Assign((char *)&now, sizeof(now));
zipW->SetComment(comment);
}
nsCOMPtr<nsIStringInputStream> stream nsCOMPtr<nsIStringInputStream> stream
= do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv); = do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@@ -485,7 +445,7 @@ StartupCache::WriteToDisk()
CacheWriteHolder holder; CacheWriteHolder holder;
holder.stream = stream; holder.stream = stream;
holder.writer = zipW; holder.writer = zipW;
holder.time = now; holder.time = PR_Now();
mTable.Enumerate(CacheCloseHelper, &holder); mTable.Enumerate(CacheCloseHelper, &holder);
@@ -493,8 +453,8 @@ StartupCache::WriteToDisk()
mArchive = NULL; mArchive = NULL;
zipW->Close(); zipW->Close();
// Our reader's view of the archive is outdated now, reload it. // our reader's view of the archive is outdated now, reload it.
LoadArchive(IGNORE_AGE); LoadArchive();
return; return;
} }
@@ -506,7 +466,7 @@ StartupCache::InvalidateCache()
mTable.Clear(); mTable.Clear();
mArchive = NULL; mArchive = NULL;
mFile->Remove(false); mFile->Remove(false);
LoadArchive(IGNORE_AGE); LoadArchive();
} }
/* /*

View File

@@ -164,12 +164,7 @@ private:
StartupCache(); StartupCache();
~StartupCache(); ~StartupCache();
enum TelemetrifyAge { nsresult LoadArchive();
IGNORE_AGE = 0,
RECORD_AGE = 1
};
nsresult LoadArchive(enum TelemetrifyAge flag);
nsresult Init(); nsresult Init();
void WriteToDisk(); void WriteToDisk();
nsresult ResetStartupWriteTimer(); nsresult ResetStartupWriteTimer();

View File

@@ -131,7 +131,6 @@ HISTOGRAM(MAC_INITFONTLIST_TOTAL, 1, 30000, 10, EXPONENTIAL, "gfxMacPlatformFont
HISTOGRAM(SYSTEM_FONT_FALLBACK, 1, 100000, 50, EXPONENTIAL, "System font fallback (us)") HISTOGRAM(SYSTEM_FONT_FALLBACK, 1, 100000, 50, EXPONENTIAL, "System font fallback (us)")
HISTOGRAM(SYSTEM_FONT_FALLBACK_FIRST, 1, 40000, 20, EXPONENTIAL, "System font fallback, first call (ms)") HISTOGRAM(SYSTEM_FONT_FALLBACK_FIRST, 1, 40000, 20, EXPONENTIAL, "System font fallback, first call (ms)")
HISTOGRAM(STARTUP_CACHE_AGE_HOURS, 1, 3000, 20, EXPONENTIAL, "Startup cache age (hours)")
/** /**
* Word cache - one count for overall lookups, the other for the number of times a word is found * Word cache - one count for overall lookups, the other for the number of times a word is found