fix usage of mEventSet prior to initializing it (regression from bug 331166) r=marria

This commit is contained in:
bryner%brianryner.com 2006-03-28 01:40:22 +00:00
Родитель d13780a4b2
Коммит a7a6028139
2 изменённых файлов: 23 добавлений и 5 удалений

Просмотреть файл

@ -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)
// <upload interval="600"/>
// </config>
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;
}

Просмотреть файл

@ -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;
}