fixes bug 334774 "reset mEventCount upon upload" r=bryner

This commit is contained in:
darin%meer.net 2006-04-20 05:07:59 +00:00
parent 222a48fcf5
commit 54f6bc3d00
2 changed files with 17 additions and 4 deletions

View File

@ -393,10 +393,7 @@ nsMetricsService::Flush()
NS_ENSURE_STATE(succeeded);
// Write current event count to prefs
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
NS_ENSURE_STATE(prefs);
rv = prefs->SetIntPref("metrics.event-count", mEventCount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_STATE(PersistEventCount());
// Create a new mRoot
rv = CreateRoot();
@ -429,6 +426,10 @@ nsMetricsService::Upload()
NS_WARNING("failed to remove data file");
}
// Reset event count and persist.
mEventCount = 0;
NS_ENSURE_STATE(PersistEventCount());
return NS_OK;
}
@ -1043,6 +1044,15 @@ nsMetricsService::GenerateClientID(nsCString &clientID)
return hasher->Finish(PR_TRUE, clientID);
}
PRBool
nsMetricsService::PersistEventCount()
{
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
NS_ENSURE_TRUE(prefs, PR_FALSE);
return NS_SUCCEEDED(prefs->SetIntPref("metrics.event-count", mEventCount));
}
/* static */ PRUint32
nsMetricsService::GetWindowID(nsIDOMWindow *window)
{

View File

@ -157,6 +157,9 @@ private:
nsresult BuildEventItem(nsIMetricsEventItem *item,
nsIDOMElement **itemElement);
// Called to persist mEventCount. Returns "true" if succeeded.
PRBool PersistEventCount();
private:
// Pointer to the metrics service singleton
static nsMetricsService* sMetricsService;