Bug 1030707 - Part 5: Replace AutoPushJSContext in SynchronizeAndResumeRunnable::Run. r=bholley

This commit is contained in:
Bob Owen 2014-07-01 11:25:27 +01:00
Родитель 424d94c7f3
Коммит 635fbe5acc
3 изменённых файлов: 15 добавлений и 16 удалений

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

@ -2133,7 +2133,7 @@ RuntimeService::ResumeWorkersForWindow(nsPIDOMWindow* aWindow)
nsContentUtils::GetSafeJSContext());
for (uint32_t index = 0; index < workers.Length(); index++) {
if (!workers[index]->SynchronizeAndResume(cx, aWindow, scx)) {
if (!workers[index]->SynchronizeAndResume(cx, aWindow)) {
JS_ReportPendingException(cx);
}
}

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

@ -47,6 +47,7 @@
#include "mozilla/dom/MessageEvent.h"
#include "mozilla/dom/MessageEventBinding.h"
#include "mozilla/dom/MessagePortList.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/WorkerBinding.h"
#include "mozilla/Preferences.h"
#include "nsAlgorithm.h"
@ -1843,14 +1844,11 @@ class WorkerPrivateParent<Derived>::SynchronizeAndResumeRunnable MOZ_FINAL
WorkerPrivate* mWorkerPrivate;
nsCOMPtr<nsPIDOMWindow> mWindow;
nsCOMPtr<nsIScriptContext> mScriptContext;
public:
SynchronizeAndResumeRunnable(WorkerPrivate* aWorkerPrivate,
nsPIDOMWindow* aWindow,
nsIScriptContext* aScriptContext)
: mWorkerPrivate(aWorkerPrivate), mWindow(aWindow),
mScriptContext(aScriptContext)
nsPIDOMWindow* aWindow)
: mWorkerPrivate(aWorkerPrivate), mWindow(aWindow)
{
AssertIsOnMainThread();
MOZ_ASSERT(aWorkerPrivate);
@ -1868,9 +1866,11 @@ private:
AssertIsOnMainThread();
if (mWorkerPrivate) {
AutoPushJSContext cx(mScriptContext ?
mScriptContext->GetNativeContext() :
nsContentUtils::GetSafeJSContext());
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(mWindow))) {
return NS_OK;
}
JSContext* cx = jsapi.cx();
if (!mWorkerPrivate->Resume(cx, mWindow)) {
JS_ReportPendingException(cx);
@ -1889,7 +1889,6 @@ private:
mWorkerPrivate = nullptr;
mWindow = nullptr;
mScriptContext = nullptr;
}
};
@ -2609,8 +2608,7 @@ template <class Derived>
bool
WorkerPrivateParent<Derived>::SynchronizeAndResume(
JSContext* aCx,
nsPIDOMWindow* aWindow,
nsIScriptContext* aScriptContext)
nsPIDOMWindow* aWindow)
{
AssertIsOnMainThread();
MOZ_ASSERT(!GetParent());
@ -2623,8 +2621,7 @@ WorkerPrivateParent<Derived>::SynchronizeAndResume(
// the messages.
nsRefPtr<SynchronizeAndResumeRunnable> runnable =
new SynchronizeAndResumeRunnable(ParentAsWorkerPrivate(), aWindow,
aScriptContext);
new SynchronizeAndResumeRunnable(ParentAsWorkerPrivate(), aWindow);
if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) {
JS_ReportError(aCx, "Failed to dispatch to current thread!");
return false;

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

@ -339,6 +339,9 @@ public:
return Notify(aCx, Killing);
}
// We can assume that an nsPIDOMWindow will be available for Suspend, Resume
// and SynchronizeAndResume as these are only used for globals going in and
// out of the bfcache.
bool
Suspend(JSContext* aCx, nsPIDOMWindow* aWindow);
@ -346,8 +349,7 @@ public:
Resume(JSContext* aCx, nsPIDOMWindow* aWindow);
bool
SynchronizeAndResume(JSContext* aCx, nsPIDOMWindow* aWindow,
nsIScriptContext* aScriptContext);
SynchronizeAndResume(JSContext* aCx, nsPIDOMWindow* aWindow);
bool
Terminate(JSContext* aCx)