зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1188545 - respondWith promise should extend the service worker's lifetime. r=nsm
This commit is contained in:
Родитель
518e55a5ed
Коммит
cce3b797b1
|
@ -408,6 +408,9 @@ FetchEvent::RespondWith(Promise& aArg, ErrorResult& aRv)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!mPromise) {
|
||||
mPromise = &aArg;
|
||||
}
|
||||
nsRefPtr<InternalRequest> ir = mRequest->GetInternalRequest();
|
||||
mWaitToRespond = true;
|
||||
nsRefPtr<RespondWithHandler> handler =
|
||||
|
@ -440,7 +443,8 @@ NS_IMPL_RELEASE_INHERITED(FetchEvent, Event)
|
|||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FetchEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(Event)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(FetchEvent, Event, mRequest, mClient)
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(FetchEvent, Event, mRequest, mClient,
|
||||
mPromise)
|
||||
|
||||
ExtendableEvent::ExtendableEvent(EventTarget* aOwner)
|
||||
: Event(aOwner, nullptr, nullptr)
|
||||
|
|
|
@ -55,6 +55,7 @@ class FetchEvent final : public Event
|
|||
nsRefPtr<Request> mRequest;
|
||||
nsCString mScriptSpec;
|
||||
UniquePtr<ServiceWorkerClientInfo> mClientInfo;
|
||||
nsRefPtr<Promise> mPromise;
|
||||
bool mIsReload;
|
||||
bool mWaitToRespond;
|
||||
protected:
|
||||
|
@ -105,6 +106,13 @@ public:
|
|||
void
|
||||
RespondWith(Promise& aArg, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
GetPromise() const
|
||||
{
|
||||
nsRefPtr<Promise> p = mPromise;
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
ForwardTo(const nsAString& aUrl);
|
||||
|
||||
|
|
|
@ -1068,6 +1068,12 @@ private:
|
|||
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(runnable)));
|
||||
}
|
||||
|
||||
nsRefPtr<Promise> respondWithPromise = event->GetPromise();
|
||||
if (respondWithPromise) {
|
||||
nsRefPtr<KeepAliveHandler> keepAliveHandler =
|
||||
new KeepAliveHandler(mKeepAliveToken);
|
||||
respondWithPromise->AppendNativeHandler(keepAliveHandler);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче