зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1251045 part 4. Remove the JSContext argument of WorkerRunnable::Dispatch. r=khuey
This commit is contained in:
Родитель
878fd26e89
Коммит
7345c5edb1
|
@ -371,7 +371,7 @@ private:
|
|||
|
||||
RefPtr<WorkerControlRunnable> runnable =
|
||||
new ConsoleReleaseRunnable(mWorkerPrivate, this);
|
||||
runnable->Dispatch(nullptr);
|
||||
runnable->Dispatch();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -2546,7 +2546,7 @@ WebSocketImpl::Cancel(nsresult aStatus)
|
|||
MOZ_ASSERT(mWorkerPrivate);
|
||||
RefPtr<CancelRunnable> runnable =
|
||||
new CancelRunnable(mWorkerPrivate, this);
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -2749,7 +2749,7 @@ WebSocketImpl::Dispatch(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFlags)
|
|||
RefPtr<WorkerRunnableDispatcher> event =
|
||||
new WorkerRunnableDispatcher(this, mWorkerPrivate, event_ref.forget());
|
||||
|
||||
if (!event->Dispatch(nullptr)) {
|
||||
if (!event->Dispatch()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -894,7 +894,7 @@ AsyncFulfillImageBitmapPromise(Promise* aPromise, ImageBitmap* aImageBitmap)
|
|||
} else {
|
||||
RefPtr<FulfillImageBitmapPromiseWorkerTask> task =
|
||||
new FulfillImageBitmapPromiseWorkerTask(aPromise, aImageBitmap);
|
||||
task->Dispatch(GetCurrentThreadWorkerPrivate()->GetJSContext()); // Actually, to the current worker-thread.
|
||||
task->Dispatch(); // Actually, to the current worker-thread.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1167,7 @@ AsyncCreateImageBitmapFromBlob(Promise* aPromise, nsIGlobalObject* aGlobal,
|
|||
} else {
|
||||
RefPtr<CreateImageBitmapFromBlobWorkerTask> task =
|
||||
new CreateImageBitmapFromBlobWorkerTask(aPromise, aGlobal, aBlob, aCropRect);
|
||||
task->Dispatch(GetCurrentThreadWorkerPrivate()->GetJSContext()); // Actually, to the current worker-thread.
|
||||
task->Dispatch(); // Actually, to the current worker-thread.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -326,9 +326,7 @@ WorkerFetchResolver::OnResponseAvailableInternal(InternalResponse* aResponse)
|
|||
new WorkerFetchResponseRunnable(mPromiseProxy->GetWorkerPrivate(), this,
|
||||
aResponse);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (!r->Dispatch(jsapi.cx())) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch fetch response");
|
||||
}
|
||||
}
|
||||
|
@ -345,9 +343,7 @@ WorkerFetchResolver::OnResponseEnd()
|
|||
RefPtr<WorkerFetchResponseEndRunnable> r =
|
||||
new WorkerFetchResponseEndRunnable(mPromiseProxy->GetWorkerPrivate(), this);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (!r->Dispatch(jsapi.cx())) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch fetch response end");
|
||||
}
|
||||
}
|
||||
|
@ -611,8 +607,7 @@ public:
|
|||
if (mBody->mWorkerPrivate) {
|
||||
RefPtr<FailConsumeBodyWorkerRunnable<Derived>> r =
|
||||
new FailConsumeBodyWorkerRunnable<Derived>(mBody);
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
MOZ_CRASH("We are going to leak");
|
||||
}
|
||||
} else {
|
||||
|
@ -662,8 +657,7 @@ public:
|
|||
aStatus,
|
||||
aResultLength,
|
||||
nonconstResult);
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
// XXXcatalinb: The worker is shutting down, the pump will be canceled
|
||||
// by FetchBodyFeature::Notify.
|
||||
NS_WARNING("Could not dispatch ConsumeBodyRunnable");
|
||||
|
|
|
@ -943,7 +943,7 @@ public:
|
|||
RefPtr<WorkerPermissionOperationCompleted> runnable =
|
||||
new WorkerPermissionOperationCompleted(mWorkerPrivate, this);
|
||||
|
||||
MOZ_ALWAYS_TRUE(runnable->Dispatch(nullptr));
|
||||
MOZ_ALWAYS_TRUE(runnable->Dispatch());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -503,12 +503,10 @@ public:
|
|||
RefPtr<ReleaseNotificationRunnable> r =
|
||||
new ReleaseNotificationRunnable(notification);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (!r->Dispatch(jsapi.cx())) {
|
||||
if (!r->Dispatch()) {
|
||||
RefPtr<ReleaseNotificationControlRunnable> r =
|
||||
new ReleaseNotificationControlRunnable(notification);
|
||||
MOZ_ALWAYS_TRUE(r->Dispatch(jsapi.cx()));
|
||||
MOZ_ALWAYS_TRUE(r->Dispatch());
|
||||
}
|
||||
} else {
|
||||
notification->AssertIsOnTargetThread();
|
||||
|
@ -1554,8 +1552,7 @@ WorkerNotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
}
|
||||
|
||||
MOZ_ASSERT(r);
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch event to worker notification");
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -1726,8 +1723,7 @@ Notification::ShowInternal()
|
|||
RefPtr<NotificationEventWorkerRunnable> r =
|
||||
new NotificationEventWorkerRunnable(this,
|
||||
NS_LITERAL_STRING("error"));
|
||||
AutoSafeJSContext cx;
|
||||
if (!r->Dispatch(cx)) {
|
||||
if (!r->Dispatch()) {
|
||||
NS_WARNING("Could not dispatch event to worker notification");
|
||||
}
|
||||
} else {
|
||||
|
@ -2153,7 +2149,7 @@ public:
|
|||
proxy,
|
||||
Move(mStrings));
|
||||
|
||||
r->Dispatch(aCx);
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -2905,7 +2905,7 @@ PromiseWorkerProxy::RunCallback(JSContext* aCx,
|
|||
RefPtr<PromiseWorkerProxyRunnable> runnable =
|
||||
new PromiseWorkerProxyRunnable(this, aFunc);
|
||||
|
||||
runnable->Dispatch(aCx);
|
||||
runnable->Dispatch();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -84,9 +84,7 @@ class WorkerPrivate;
|
|||
//
|
||||
// RefPtr<FinishTaskWorkerRunnable> runnable =
|
||||
// new FinishTaskWorkerRunnable(proxy->GetWorkerPrivate(), proxy, result);
|
||||
// AutoJSAPI jsapi;
|
||||
// jsapi.Init();
|
||||
// if (!r->Dispatch(jsapi.cx())) {
|
||||
// if (!r->Dispatch()) {
|
||||
// // Worker is alive but not Running any more, so the Promise can't
|
||||
// // be resolved, give up. The proxy will get Release()d at some
|
||||
// // point.
|
||||
|
|
|
@ -442,12 +442,9 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
|
||||
RefPtr<UnsubscribeResultRunnable> r =
|
||||
new UnsubscribeResultRunnable(proxy, aStatus, aSuccess);
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -644,9 +641,6 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
|
||||
nsAutoString endpoint;
|
||||
nsTArray<uint8_t> rawP256dhKey, authSecret;
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
|
@ -661,7 +655,7 @@ public:
|
|||
mScope,
|
||||
rawP256dhKey,
|
||||
authSecret);
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -913,11 +907,9 @@ public:
|
|||
state
|
||||
);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
RefPtr<PermissionResultRunnable> r =
|
||||
new PermissionResultRunnable(mProxy, rv, state);
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -954,11 +954,7 @@ DataStoreChangeEventProxy::HandleEvent(nsIDOMEvent* aEvent)
|
|||
RefPtr<DispatchDataStoreChangeEventRunnable> runnable =
|
||||
new DispatchDataStoreChangeEventRunnable(this, event);
|
||||
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoRequest ar(cx);
|
||||
runnable->Dispatch(cx);
|
||||
}
|
||||
runnable->Dispatch();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -601,7 +601,7 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
bool
|
||||
Dispatch(JSContext* aCx)
|
||||
Dispatch()
|
||||
{
|
||||
AutoSyncLoopHolder syncLoop(mWorkerPrivate);
|
||||
|
||||
|
@ -609,7 +609,6 @@ public:
|
|||
MOZ_ASSERT(mSyncLoopTarget);
|
||||
|
||||
if (NS_FAILED(NS_DispatchToMainThread(this))) {
|
||||
JS_ReportError(aCx, "Failed to dispatch to main thread!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -642,9 +641,7 @@ ContentSecurityPolicyAllows(JSContext* aCx)
|
|||
RefPtr<LogViolationDetailsRunnable> runnable =
|
||||
new LogViolationDetailsRunnable(worker, fileName, lineNum);
|
||||
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
JS_ReportPendingException(aCx);
|
||||
}
|
||||
runnable->Dispatch();
|
||||
}
|
||||
|
||||
return worker->IsEvalAllowed();
|
||||
|
@ -1255,7 +1252,7 @@ WorkerCrossThreadDispatcher::PostTask(WorkerTask* aTask)
|
|||
|
||||
RefPtr<WorkerTaskRunnable> runnable =
|
||||
new WorkerTaskRunnable(mWorkerPrivate, aTask);
|
||||
return runnable->Dispatch(nullptr);
|
||||
return runnable->Dispatch();
|
||||
}
|
||||
|
||||
WorkerPrivate*
|
||||
|
@ -2587,7 +2584,7 @@ LogViolationDetailsRunnable::Run()
|
|||
RefPtr<MainThreadStopSyncLoopRunnable> response =
|
||||
new MainThreadStopSyncLoopRunnable(mWorkerPrivate, mSyncLoopTarget.forget(),
|
||||
true);
|
||||
MOZ_ALWAYS_TRUE(response->Dispatch(nullptr));
|
||||
MOZ_ALWAYS_TRUE(response->Dispatch());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1252,7 +1252,7 @@ private:
|
|||
RefPtr<ScriptExecutorRunnable> runnable =
|
||||
new ScriptExecutorRunnable(*this, mSyncLoopTarget, IsMainWorkerScript(),
|
||||
firstIndex, lastIndex);
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
MOZ_ASSERT(false, "This should never fail!");
|
||||
}
|
||||
}
|
||||
|
@ -1682,7 +1682,7 @@ public:
|
|||
RefPtr<MainThreadStopSyncLoopRunnable> runnable =
|
||||
new MainThreadStopSyncLoopRunnable(mParentWorker,
|
||||
mSyncLoopTarget.forget(), true);
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_ERROR("This should never fail!");
|
||||
}
|
||||
|
||||
|
|
|
@ -132,9 +132,7 @@ public:
|
|||
rv.StealNSResult());
|
||||
rv.SuppressException();
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
@ -212,9 +210,7 @@ public:
|
|||
new ResolvePromiseWorkerRunnable(mPromiseProxy->GetWorkerPrivate(),
|
||||
mPromiseProxy, result);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
@ -292,9 +288,7 @@ public:
|
|||
RefPtr<ResolveClaimRunnable> r =
|
||||
new ResolveClaimRunnable(workerPrivate, mPromiseProxy, rv);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
@ -405,10 +399,7 @@ public:
|
|||
new ResolveOpenWindowRunnable(mPromiseProxy,
|
||||
Move(clientInfo),
|
||||
NS_OK);
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
r->Dispatch(cx);
|
||||
r->Dispatch();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -553,9 +544,7 @@ public:
|
|||
RefPtr<ResolveOpenWindowRunnable> resolveRunnable =
|
||||
new ResolveOpenWindowRunnable(mPromiseProxy, nullptr, rv);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
NS_WARN_IF(!resolveRunnable->Dispatch(jsapi.cx()));
|
||||
NS_WARN_IF(!resolveRunnable->Dispatch());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -163,9 +163,7 @@ ServiceWorkerPrivate::CheckScriptEvaluation(LifeCycleEventCallback* aCallback)
|
|||
RefPtr<WorkerRunnable> r = new CheckScriptEvaluationWithCallback(mWorkerPrivate,
|
||||
mKeepAliveToken,
|
||||
aCallback);
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
if (NS_WARN_IF(!r->Dispatch())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -548,9 +546,7 @@ ServiceWorkerPrivate::SendLifeCycleEvent(const nsAString& aEventType,
|
|||
mKeepAliveToken,
|
||||
aEventType,
|
||||
aCallback);
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
if (NS_WARN_IF(!r->Dispatch())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -680,9 +676,7 @@ ServiceWorkerPrivate::SendPushEvent(const Maybe<nsTArray<uint8_t>>& aData,
|
|||
|
||||
MOZ_ASSERT(mInfo->State() == ServiceWorkerState::Activated);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
if (NS_WARN_IF(!r->Dispatch())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -702,9 +696,7 @@ ServiceWorkerPrivate::SendPushSubscriptionChangeEvent()
|
|||
MOZ_ASSERT(mKeepAliveToken);
|
||||
RefPtr<WorkerRunnable> r =
|
||||
new SendPushSubscriptionChangeEventRunnable(mWorkerPrivate, mKeepAliveToken);
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
if (NS_WARN_IF(!r->Dispatch())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -976,9 +968,7 @@ ServiceWorkerPrivate::SendNotificationClickEvent(const nsAString& aID,
|
|||
aID, aTitle, aDir, aLang,
|
||||
aBody, aTag, aIcon, aData,
|
||||
aBehavior, aScope);
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
if (NS_WARN_IF(!r->Dispatch())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1351,9 +1341,7 @@ ServiceWorkerPrivate::SendFetchEvent(nsIInterceptedChannel* aChannel,
|
|||
|
||||
MOZ_ASSERT(mInfo->State() == ServiceWorkerState::Activated);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
if (NS_WARN_IF(!r->Dispatch())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1543,9 +1531,7 @@ ServiceWorkerPrivate::Activated()
|
|||
|
||||
for (uint32_t i = 0; i < pendingEvents.Length(); ++i) {
|
||||
RefPtr<WorkerRunnable> r = pendingEvents[i].forget();
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
if (NS_WARN_IF(!r->Dispatch())) {
|
||||
NS_WARNING("Failed to dispatch pending functional event!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -388,12 +388,9 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
|
||||
RefPtr<UpdateResultRunnable> r =
|
||||
new UpdateResultRunnable(proxy, aStatus);
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -555,9 +552,7 @@ private:
|
|||
RefPtr<WorkerRunnable> r =
|
||||
new FulfillUnregisterPromiseRunnable(proxy, aState);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
r->Dispatch(jsapi.cx());
|
||||
r->Dispatch();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1201,10 +1196,7 @@ WorkerListener::UpdateFound()
|
|||
if (mWorkerPrivate) {
|
||||
RefPtr<FireUpdateFoundRunnable> r =
|
||||
new FireUpdateFoundRunnable(mWorkerPrivate, this);
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (NS_WARN_IF(!r->Dispatch(jsapi.cx()))) {
|
||||
}
|
||||
NS_WARN_IF(!r->Dispatch());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,9 +118,7 @@ private:
|
|||
new ResolveOrRejectPromiseRunnable(mPromiseProxy->GetWorkerPrivate(),
|
||||
mPromiseProxy, Move(aClientInfo));
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
resolveRunnable->Dispatch(jsapi.cx());
|
||||
resolveRunnable->Dispatch();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -466,14 +466,6 @@ public:
|
|||
mIncrease(aIncrease)
|
||||
{ }
|
||||
|
||||
// We don't need a JSContext to dispatch, since we know our PreDispatch and
|
||||
// DispatchInternal don't throw any exceptions.
|
||||
bool
|
||||
Dispatch()
|
||||
{
|
||||
return WorkerControlRunnable::Dispatch(nullptr);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
|
||||
|
@ -853,14 +845,6 @@ public:
|
|||
aStatus == Canceling || aStatus == Killing);
|
||||
}
|
||||
|
||||
// We can be dispatched without a JSContext, because all we do with the
|
||||
// JSContext passed to Dispatch() normally for worker runnables is call
|
||||
// ModifyBusyCount... but that doesn't actually use its JSContext argument.
|
||||
bool Dispatch()
|
||||
{
|
||||
return WorkerControlRunnable::Dispatch(nullptr);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool
|
||||
PreDispatch(WorkerPrivate* aWorkerPrivate) override
|
||||
|
@ -1070,7 +1054,7 @@ public:
|
|||
new ReportErrorRunnable(aWorkerPrivate, aMessage, aFilename, aLine,
|
||||
aLineNumber, aColumnNumber, aFlags,
|
||||
aErrorNumber, aExnType, aMutedError);
|
||||
return runnable->Dispatch(aCx);
|
||||
return runnable->Dispatch();
|
||||
}
|
||||
|
||||
// Otherwise log an error to the error console.
|
||||
|
@ -1755,7 +1739,7 @@ TimerThreadEventTarget::Dispatch(already_AddRefed<nsIRunnable>&& aRunnable, uint
|
|||
|
||||
// This can fail if we're racing to terminate or cancel, should be handled
|
||||
// by the terminate or cancel code.
|
||||
mWorkerRunnable->Dispatch(nullptr);
|
||||
mWorkerRunnable->Dispatch();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2633,7 +2617,7 @@ WorkerPrivateParent<Derived>::Freeze(JSContext* aCx,
|
|||
|
||||
RefPtr<FreezeRunnable> runnable =
|
||||
new FreezeRunnable(ParentAsWorkerPrivate());
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2715,7 +2699,7 @@ WorkerPrivateParent<Derived>::Thaw(JSContext* aCx, nsPIDOMWindowInner* aWindow)
|
|||
|
||||
RefPtr<ThawRunnable> runnable =
|
||||
new ThawRunnable(ParentAsWorkerPrivate());
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2927,7 +2911,7 @@ WorkerPrivateParent<Derived>::PostMessageInternal(
|
|||
|
||||
runnable->SetMessageSource(Move(aClientInfo));
|
||||
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -2969,9 +2953,8 @@ WorkerPrivateParent<Derived>::UpdateRuntimeOptions(
|
|||
|
||||
RefPtr<UpdateRuntimeOptionsRunnable> runnable =
|
||||
new UpdateRuntimeOptionsRunnable(ParentAsWorkerPrivate(), aRuntimeOptions);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to update worker context options!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2984,9 +2967,8 @@ WorkerPrivateParent<Derived>::UpdatePreference(JSContext* aCx, WorkerPreference
|
|||
|
||||
RefPtr<UpdatePreferenceRunnable> runnable =
|
||||
new UpdatePreferenceRunnable(ParentAsWorkerPrivate(), aPref, aValue);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to update worker preferences!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2999,9 +2981,8 @@ WorkerPrivateParent<Derived>::UpdateLanguages(JSContext* aCx,
|
|||
|
||||
RefPtr<UpdateLanguagesRunnable> runnable =
|
||||
new UpdateLanguagesRunnable(ParentAsWorkerPrivate(), aLanguages);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to update worker languages!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3024,9 +3005,8 @@ WorkerPrivateParent<Derived>::UpdateJSWorkerMemoryParameter(JSContext* aCx,
|
|||
RefPtr<UpdateJSWorkerMemoryParameterRunnable> runnable =
|
||||
new UpdateJSWorkerMemoryParameterRunnable(ParentAsWorkerPrivate(), aKey,
|
||||
aValue);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to update memory parameter!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3047,9 +3027,8 @@ WorkerPrivateParent<Derived>::UpdateGCZeal(JSContext* aCx, uint8_t aGCZeal,
|
|||
|
||||
RefPtr<UpdateGCZealRunnable> runnable =
|
||||
new UpdateGCZealRunnable(ParentAsWorkerPrivate(), aGCZeal, aFrequency);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to update worker gczeal!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3063,9 +3042,8 @@ WorkerPrivateParent<Derived>::GarbageCollect(JSContext* aCx, bool aShrinking)
|
|||
RefPtr<GarbageCollectRunnable> runnable =
|
||||
new GarbageCollectRunnable(ParentAsWorkerPrivate(), aShrinking,
|
||||
/* collectChildren = */ true);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to GC worker!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3078,9 +3056,8 @@ WorkerPrivateParent<Derived>::CycleCollect(JSContext* aCx, bool aDummy)
|
|||
RefPtr<CycleCollectRunnable> runnable =
|
||||
new CycleCollectRunnable(ParentAsWorkerPrivate(),
|
||||
/* collectChildren = */ true);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to CC worker!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3092,9 +3069,8 @@ WorkerPrivateParent<Derived>::OfflineStatusChangeEvent(JSContext* aCx, bool aIsO
|
|||
|
||||
RefPtr<OfflineStatusChangeRunnable> runnable =
|
||||
new OfflineStatusChangeRunnable(ParentAsWorkerPrivate(), aIsOffline);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to dispatch offline status change event!");
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3148,7 +3124,7 @@ WorkerPrivateParent<Derived>::RegisterSharedWorker(JSContext* aCx,
|
|||
if (IsSharedWorker()) {
|
||||
RefPtr<MessagePortRunnable> runnable =
|
||||
new MessagePortRunnable(ParentAsWorkerPrivate(), aPort);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3810,7 +3786,7 @@ WorkerDebugger::Initialize(const nsAString& aURL, JSContext* aCx)
|
|||
if (!mIsInitialized) {
|
||||
RefPtr<CompileDebuggerScriptRunnable> runnable =
|
||||
new CompileDebuggerScriptRunnable(mWorkerPrivate, aURL);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -3831,7 +3807,7 @@ WorkerDebugger::PostMessageMoz(const nsAString& aMessage, JSContext* aCx)
|
|||
|
||||
RefPtr<DebuggerMessageEventRunnable> runnable =
|
||||
new DebuggerMessageEventRunnable(mWorkerPrivate, aMessage);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -4118,7 +4094,7 @@ WorkerPrivate::Constructor(JSContext* aCx,
|
|||
|
||||
RefPtr<CompileScriptRunnable> compiler =
|
||||
new CompileScriptRunnable(worker, aScriptURL);
|
||||
if (!compiler->Dispatch(aCx)) {
|
||||
if (!compiler->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -4778,7 +4754,7 @@ WorkerPrivate::ScheduleDeletion(WorkerRanOrNot aRanOrNot)
|
|||
if (WorkerPrivate* parent = GetParent()) {
|
||||
RefPtr<WorkerFinishedRunnable> runnable =
|
||||
new WorkerFinishedRunnable(parent, this);
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to dispatch runnable!");
|
||||
}
|
||||
}
|
||||
|
@ -5504,7 +5480,7 @@ WorkerPrivate::PostMessageToParentInternal(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -5595,7 +5571,7 @@ WorkerPrivate::SetDebuggerImmediate(JSContext* aCx, dom::Function& aHandler,
|
|||
|
||||
RefPtr<DebuggerImmediateRunnable> runnable =
|
||||
new DebuggerImmediateRunnable(this, aHandler);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -5697,7 +5673,7 @@ WorkerPrivate::NotifyInternal(JSContext* aCx, Status aStatus)
|
|||
if (aStatus == Closing) {
|
||||
// Notify parent to stop sending us messages and balance our busy count.
|
||||
RefPtr<CloseRunnable> runnable = new CloseRunnable(this);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,12 +87,9 @@ WorkerRunnable::PreDispatch(WorkerPrivate* aWorkerPrivate)
|
|||
}
|
||||
|
||||
bool
|
||||
WorkerRunnable::Dispatch(JSContext* aCx)
|
||||
WorkerRunnable::Dispatch()
|
||||
{
|
||||
bool ok;
|
||||
|
||||
if (!aCx) {
|
||||
ok = PreDispatch(mWorkerPrivate);
|
||||
bool ok = PreDispatch(mWorkerPrivate);
|
||||
if (ok) {
|
||||
ok = DispatchInternal();
|
||||
}
|
||||
|
@ -100,31 +97,6 @@ WorkerRunnable::Dispatch(JSContext* aCx)
|
|||
return ok;
|
||||
}
|
||||
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
if (global) {
|
||||
ac.emplace(aCx, global);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
|
||||
|
||||
ok = PreDispatch(mWorkerPrivate);
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
|
||||
|
||||
if (ok && !DispatchInternal()) {
|
||||
ok = false;
|
||||
}
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
|
||||
|
||||
PostDispatch(mWorkerPrivate, ok);
|
||||
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
WorkerRunnable::DispatchInternal()
|
||||
{
|
||||
|
@ -599,7 +571,7 @@ WorkerMainThreadRunnable::Run()
|
|||
mSyncLoopTarget.forget(),
|
||||
runResult);
|
||||
|
||||
MOZ_ALWAYS_TRUE(response->Dispatch(nullptr));
|
||||
MOZ_ALWAYS_TRUE(response->Dispatch());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -73,12 +73,10 @@ public:
|
|||
// appropriately.
|
||||
NS_DECL_NSICANCELABLERUNNABLE
|
||||
|
||||
// Passing a JSContext here is required for the WorkerThreadModifyBusyCount
|
||||
// behavior. It also guarantees that any failure (false return) will throw an
|
||||
// exception on the given context. If a context is not passed then failures
|
||||
// must be dealt with by the caller.
|
||||
// The return value is true if and only if both PreDispatch and
|
||||
// DispatchInternal return true.
|
||||
bool
|
||||
Dispatch(JSContext* aCx);
|
||||
Dispatch();
|
||||
|
||||
// See above note about Cancel().
|
||||
virtual bool
|
||||
|
|
|
@ -599,9 +599,7 @@ public:
|
|||
RefPtr<SkipWaitingResultRunnable> runnable =
|
||||
new SkipWaitingResultRunnable(workerPrivate, mPromiseProxy);
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
if (!runnable->Dispatch(jsapi.cx())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_WARNING("Failed to dispatch SkipWaitingResultRunnable to the worker.");
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -223,7 +223,7 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
bool
|
||||
Dispatch(JSContext* aCx)
|
||||
Dispatch()
|
||||
{
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
|
@ -231,7 +231,6 @@ public:
|
|||
mSyncLoopTarget = syncLoop.EventTarget();
|
||||
|
||||
if (NS_FAILED(NS_DispatchToMainThread(this))) {
|
||||
JS_ReportError(aCx, "Failed to dispatch to main thread!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -595,10 +594,6 @@ public:
|
|||
mScopeObj(nsContentUtils::RootingCxForThread(), aScopeObj)
|
||||
{ }
|
||||
|
||||
void Dispatch()
|
||||
{
|
||||
MainThreadProxyRunnable::Dispatch(nullptr);
|
||||
}
|
||||
private:
|
||||
~EventRunnable()
|
||||
{ }
|
||||
|
@ -974,7 +969,7 @@ Proxy::Teardown(bool aSendUnpin)
|
|||
if (aSendUnpin) {
|
||||
RefPtr<XHRUnpinRunnable> runnable =
|
||||
new XHRUnpinRunnable(mWorkerPrivate, mXMLHttpRequestPrivate);
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_RUNTIMEABORT("We're going to hang at shutdown anyways.");
|
||||
}
|
||||
}
|
||||
|
@ -985,7 +980,7 @@ Proxy::Teardown(bool aSendUnpin)
|
|||
new MainThreadStopSyncLoopRunnable(mWorkerPrivate,
|
||||
mSyncLoopTarget.forget(),
|
||||
false);
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_RUNTIMEABORT("We're going to hang at shutdown anyways.");
|
||||
}
|
||||
}
|
||||
|
@ -1146,7 +1141,7 @@ LoadStartDetectionRunnable::Run()
|
|||
RefPtr<ProxyCompleteRunnable> runnable =
|
||||
new ProxyCompleteRunnable(mWorkerPrivate, mProxy,
|
||||
mXMLHttpRequestPrivate, mChannelId);
|
||||
if (runnable->Dispatch(nullptr)) {
|
||||
if (runnable->Dispatch()) {
|
||||
mProxy->mWorkerPrivate = nullptr;
|
||||
mProxy->mSyncLoopTarget = nullptr;
|
||||
mProxy->mOutstandingSendCount--;
|
||||
|
@ -1447,7 +1442,7 @@ WorkerThreadProxySyncRunnable::Run()
|
|||
|
||||
RefPtr<ResponseRunnable> response =
|
||||
new ResponseRunnable(mWorkerPrivate, mProxy, rv);
|
||||
if (!response->Dispatch(nullptr)) {
|
||||
if (!response->Dispatch()) {
|
||||
MOZ_ASSERT(false, "Failed to dispatch response!");
|
||||
}
|
||||
|
||||
|
@ -1692,7 +1687,7 @@ XMLHttpRequest::ReleaseProxy(ReleaseType aType)
|
|||
new SyncTeardownRunnable(mWorkerPrivate, mProxy);
|
||||
mProxy = nullptr;
|
||||
|
||||
if (!runnable->Dispatch(nullptr)) {
|
||||
if (!runnable->Dispatch()) {
|
||||
NS_ERROR("Failed to dispatch teardown runnable!");
|
||||
}
|
||||
}
|
||||
|
@ -1869,12 +1864,10 @@ XMLHttpRequest::SendInternal(SendRunnable* aRunnable,
|
|||
|
||||
mProxy->mOuterChannelId++;
|
||||
|
||||
JSContext* cx = mWorkerPrivate->GetJSContext();
|
||||
|
||||
aRunnable->SetSyncLoopTarget(syncLoopTarget);
|
||||
aRunnable->SetHaveUploadListeners(hasUploadListeners);
|
||||
|
||||
if (!aRunnable->Dispatch(cx)) {
|
||||
if (!aRunnable->Dispatch()) {
|
||||
// Dispatch() may have spun the event loop and we may have already unrooted.
|
||||
// If so we don't want autoUnpin to try again.
|
||||
if (!mRooted) {
|
||||
|
@ -1941,7 +1934,7 @@ XMLHttpRequest::Open(const nsACString& aMethod, const nsAString& aUrl,
|
|||
mTimeout);
|
||||
|
||||
++mProxy->mOpenCount;
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
if (!--mProxy->mOpenCount) {
|
||||
ReleaseProxy();
|
||||
}
|
||||
|
@ -1978,7 +1971,7 @@ XMLHttpRequest::SetRequestHeader(const nsACString& aHeader,
|
|||
|
||||
RefPtr<SetRequestHeaderRunnable> runnable =
|
||||
new SetRequestHeaderRunnable(mWorkerPrivate, mProxy, aHeader, aValue);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2004,7 +1997,7 @@ XMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
|
|||
|
||||
RefPtr<SetTimeoutRunnable> runnable =
|
||||
new SetTimeoutRunnable(mWorkerPrivate, mProxy, aTimeout);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2030,7 +2023,7 @@ XMLHttpRequest::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
|
|||
|
||||
RefPtr<SetWithCredentialsRunnable> runnable =
|
||||
new SetWithCredentialsRunnable(mWorkerPrivate, mProxy, aWithCredentials);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2058,7 +2051,7 @@ XMLHttpRequest::SetMozBackgroundRequest(bool aBackgroundRequest,
|
|||
RefPtr<SetBackgroundRequestRunnable> runnable =
|
||||
new SetBackgroundRequestRunnable(mWorkerPrivate, mProxy,
|
||||
aBackgroundRequest);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2290,7 +2283,7 @@ XMLHttpRequest::Abort(ErrorResult& aRv)
|
|||
mProxy->mOuterEventStreamId++;
|
||||
|
||||
RefPtr<AbortRunnable> runnable = new AbortRunnable(mWorkerPrivate, mProxy);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2316,7 +2309,7 @@ XMLHttpRequest::GetResponseHeader(const nsACString& aHeader,
|
|||
RefPtr<GetResponseHeaderRunnable> runnable =
|
||||
new GetResponseHeaderRunnable(mWorkerPrivate, mProxy, aHeader,
|
||||
responseHeader);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2342,7 +2335,7 @@ XMLHttpRequest::GetAllResponseHeaders(nsACString& aResponseHeaders,
|
|||
nsCString responseHeaders;
|
||||
RefPtr<GetAllResponseHeadersRunnable> runnable =
|
||||
new GetAllResponseHeadersRunnable(mWorkerPrivate, mProxy, responseHeaders);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2374,7 +2367,7 @@ XMLHttpRequest::OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv)
|
|||
|
||||
RefPtr<OverrideMimeTypeRunnable> runnable =
|
||||
new OverrideMimeTypeRunnable(mWorkerPrivate, mProxy, aMimeType);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -2409,7 +2402,7 @@ XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType,
|
|||
|
||||
RefPtr<SetResponseTypeRunnable> runnable =
|
||||
new SetResponseTypeRunnable(mWorkerPrivate, mProxy, responseType);
|
||||
if (!runnable->Dispatch(mWorkerPrivate->GetJSContext())) {
|
||||
if (!runnable->Dispatch()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче