Bug 860438 - Simplify JSContext handling {Cancel,Suspend,Resume}WorkersForWindow. r=gabor

The only functional difference here is the removal of a bug in which we were
constructing a dom::workers::AutoSafeJSContext around aCx, but then continuing
to pass aCx to the callee. If aCx were to be null, we'd end up with a mismatch
between the stack and the active cx. But it looks likes stuff depends on cx
being non-null anyway, so that probably never happened.
This commit is contained in:
Bobby Holley 2013-04-18 11:36:04 -04:00
Родитель 84f44bb3d9
Коммит 77c247ce12
2 изменённых файлов: 9 добавлений и 6 удалений

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

@ -1423,8 +1423,10 @@ nsGlobalWindow::FreeInnerObjects()
NotifyDOMWindowDestroyed(this);
// Kill all of the workers for this window.
// We push a cx so that exceptions get reported in the right DOM Window.
nsIScriptContext *scx = GetContextInternal();
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nullptr);
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nsContentUtils::GetSafeJSContext());
JSAutoRequest ar(cx);
mozilla::dom::workers::CancelWorkersForWindow(cx, this);
// Close all offline storages for this window.
@ -11018,8 +11020,10 @@ nsGlobalWindow::SuspendTimeouts(uint32_t aIncrease,
DisableGamepadUpdates();
// Suspend all of the workers for this window.
// We push a cx so that exceptions get reported in the right DOM Window.
nsIScriptContext *scx = GetContextInternal();
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nullptr);
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nsContentUtils::GetSafeJSContext());
JSAutoRequest ar(cx);
mozilla::dom::workers::SuspendWorkersForWindow(cx, this);
TimeStamp now = TimeStamp::Now();
@ -11109,8 +11113,10 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
}
// Resume all of the workers for this window.
// We push a cx so that exceptions get reported in the right DOM Window.
nsIScriptContext *scx = GetContextInternal();
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nullptr);
AutoPushJSContext cx(scx ? scx->GetNativeContext() : nsContentUtils::GetSafeJSContext());
JSAutoRequest ar(cx);
mozilla::dom::workers::ResumeWorkersForWindow(cx, this);
// Restore all of the timeouts, using the stored time remaining

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

@ -1284,7 +1284,6 @@ RuntimeService::CancelWorkersForWindow(JSContext* aCx,
GetWorkersForWindow(aWindow, workers);
if (!workers.IsEmpty()) {
AutoSafeJSContext cx(aCx);
for (uint32_t index = 0; index < workers.Length(); index++) {
if (!workers[index]->Cancel(aCx)) {
NS_WARNING("Failed to cancel worker!");
@ -1303,7 +1302,6 @@ RuntimeService::SuspendWorkersForWindow(JSContext* aCx,
GetWorkersForWindow(aWindow, workers);
if (!workers.IsEmpty()) {
AutoSafeJSContext cx(aCx);
for (uint32_t index = 0; index < workers.Length(); index++) {
if (!workers[index]->Suspend(aCx)) {
NS_WARNING("Failed to cancel worker!");
@ -1322,7 +1320,6 @@ RuntimeService::ResumeWorkersForWindow(JSContext* aCx,
GetWorkersForWindow(aWindow, workers);
if (!workers.IsEmpty()) {
AutoSafeJSContext cx(aCx);
for (uint32_t index = 0; index < workers.Length(); index++) {
if (!workers[index]->Resume(aCx)) {
NS_WARNING("Failed to cancel worker!");