diff --git a/extensions/metrics/src/nsMetricsConfig.cpp b/extensions/metrics/src/nsMetricsConfig.cpp index 45928c8ad902..550865a224c2 100644 --- a/extensions/metrics/src/nsMetricsConfig.cpp +++ b/extensions/metrics/src/nsMetricsConfig.cpp @@ -75,7 +75,16 @@ ReadIntegerAttr(nsIDOMElement *elem, const nsAString &attrName, PRInt32 *result) nsMetricsConfig::nsMetricsConfig() { +} + +PRBool +nsMetricsConfig::Init() +{ + if (!mEventSet.Init()) { + return PR_FALSE; + } Reset(); + return PR_TRUE; } void @@ -83,6 +92,8 @@ nsMetricsConfig::Reset() { // By default, we have no event limit, but all collectors are disabled // until we're told by the server to enable them. + NS_ASSERTION(mEventSet.IsInitialized(), "nsMetricsConfig::Init not called"); + mEventSet.Clear(); mEventLimit = PR_INT32_MAX; mUploadInterval = NS_DEFAULT_UPLOAD_INTERVAL; @@ -105,6 +116,8 @@ nsMetricsConfig::Load(nsIFile *file) // // + NS_ASSERTION(mEventSet.IsInitialized(), "nsMetricsConfig::Init not called"); + PRInt64 fileSize; nsresult rv = file->GetFileSize(&fileSize); NS_ENSURE_SUCCESS(rv, rv); @@ -213,5 +226,6 @@ PRBool nsMetricsConfig::IsEventEnabled(const nsAString &eventNS, const nsAString &eventName) const { + NS_ASSERTION(mEventSet.IsInitialized(), "nsMetricsConfig::Init not called"); return mEventSet.GetEntry(MakeKey(eventNS, eventName)) != nsnull; } diff --git a/extensions/metrics/src/nsMetricsConfig.h b/extensions/metrics/src/nsMetricsConfig.h index 4e1a1bef33f8..a939619f3981 100644 --- a/extensions/metrics/src/nsMetricsConfig.h +++ b/extensions/metrics/src/nsMetricsConfig.h @@ -53,9 +53,7 @@ public: /** * This method must be called before using an instance of this class. */ - PRBool Init() { - return mEventSet.Init(); - } + PRBool Init(); /** * Restore the default configuration. @@ -77,14 +75,18 @@ public: /** * Get the limit on the number of events that should be collected. */ - PRInt32 EventLimit() { + PRInt32 EventLimit() const { + NS_ASSERTION(mEventSet.IsInitialized(), + "nsMetricsConfig::Init not called"); return mEventLimit; } /** * Get the upload interval (measured in seconds). */ - PRInt32 UploadInterval() { + PRInt32 UploadInterval() const { + NS_ASSERTION(mEventSet.IsInitialized(), + "nsMetricsConfig::Init not called"); return mUploadInterval; } @@ -92,6 +94,8 @@ public: * Set the upload interval (measured in seconds). */ void SetUploadInterval(PRInt32 uploadInterval) { + NS_ASSERTION(mEventSet.IsInitialized(), + "nsMetricsConfig::Init not called"); mUploadInterval = uploadInterval; }