mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
fixes bug 334774 "reset mEventCount upon upload" r=bryner
This commit is contained in:
parent
222a48fcf5
commit
54f6bc3d00
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user