diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 526008df5406..e294ca6db05e 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -885,9 +885,9 @@ InitJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSContext* aWorkerCx) // This is the real place where we set the max memory for the runtime. for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) { const JSSettings::JSGCSetting& setting = gcSettings[index]; - if (setting.IsSet()) { + if (setting.key.isSome()) { NS_ASSERTION(setting.value, "Can't handle 0 values!"); - JS_SetGCParameter(aWorkerCx, setting.key, setting.value); + JS_SetGCParameter(aWorkerCx, *setting.key, setting.value); } } @@ -1935,7 +1935,7 @@ RuntimeService::Init() } // Initialize JSSettings. - if (!sDefaultJSSettings.gcSettings[0].IsSet()) { + if (sDefaultJSSettings.gcSettings[0].key.isNothing()) { sDefaultJSSettings.contextOptions = JS::ContextOptions(); sDefaultJSSettings.chrome.maxScriptRuntime = -1; sDefaultJSSettings.chrome.compartmentOptions.behaviors().setVersion(JSVERSION_DEFAULT); diff --git a/dom/workers/Workers.h b/dom/workers/Workers.h index aa25ccffd578..fbcccd293f91 100644 --- a/dom/workers/Workers.h +++ b/dom/workers/Workers.h @@ -9,6 +9,7 @@ #include "jsapi.h" #include "mozilla/Attributes.h" +#include "mozilla/Maybe.h" #include "mozilla/Mutex.h" #include #include "nsAutoPtr.h" @@ -102,25 +103,12 @@ struct JSSettings struct JSGCSetting { - JSGCParamKey key; + mozilla::Maybe key; uint32_t value; JSGCSetting() - : key(static_cast(-1)), value(0) + : key(), value(0) { } - - bool - IsSet() const - { - return key != static_cast(-1); - } - - void - Unset() - { - key = static_cast(-1); - value = 0; - } }; // There are several settings that we know we need so it makes sense to @@ -166,11 +154,11 @@ struct JSSettings for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) { JSSettings::JSGCSetting& setting = gcSettings[index]; - if (setting.key == aKey) { + if (setting.key.isSome() && *setting.key == aKey) { foundSetting = &setting; break; } - if (!firstEmptySetting && !setting.IsSet()) { + if (!firstEmptySetting && setting.key.isNothing()) { firstEmptySetting = &setting; } } @@ -183,13 +171,13 @@ struct JSSettings return false; } } - foundSetting->key = aKey; + foundSetting->key = mozilla::Some(aKey); foundSetting->value = aValue; return true; } if (foundSetting) { - foundSetting->Unset(); + foundSetting->key.reset(); return true; }