| Index: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
|
| diff --git a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
|
| index e22ac3b405e330206b0533c0d1184ea982b97bb7..3de2d8f8e1d9566dbbf5cf062ec2d9b3ac8c469e 100644
|
| --- a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
|
| +++ b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
|
| @@ -30,6 +30,8 @@
|
|
|
| #include "web/ServiceWorkerGlobalScopeProxy.h"
|
|
|
| +#include <memory>
|
| +#include <utility>
|
| #include "bindings/core/v8/SourceLocation.h"
|
| #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
|
| #include "core/dom/Document.h"
|
| @@ -56,6 +58,7 @@
|
| #include "modules/serviceworkers/FetchEvent.h"
|
| #include "modules/serviceworkers/ForeignFetchEvent.h"
|
| #include "modules/serviceworkers/InstallEvent.h"
|
| +#include "modules/serviceworkers/PaymentRequestRespondWithObserver.h"
|
| #include "modules/serviceworkers/ServiceWorkerClient.h"
|
| #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
|
| #include "modules/serviceworkers/ServiceWorkerWindowClient.h"
|
| @@ -70,8 +73,6 @@
|
| #include "wtf/Assertions.h"
|
| #include "wtf/Functional.h"
|
| #include "wtf/PtrUtil.h"
|
| -#include <memory>
|
| -#include <utility>
|
|
|
| namespace blink {
|
|
|
| @@ -164,7 +165,7 @@ void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(
|
| workerGlobalScope()->scriptController()->getScriptState());
|
| WaitUntilObserver* waitUntilObserver = WaitUntilObserver::create(
|
| workerGlobalScope(), WaitUntilObserver::Fetch, fetchEventID);
|
| - RespondWithObserver* respondWithObserver = RespondWithObserver::create(
|
| + RespondWithObserver* respondWithObserver = FetchRespondWithObserver::create(
|
| workerGlobalScope(), fetchEventID, webRequest.url(), webRequest.mode(),
|
| webRequest.redirectMode(), webRequest.frameType(),
|
| webRequest.requestContext(), waitUntilObserver);
|
| @@ -340,15 +341,29 @@ void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(
|
| void ServiceWorkerGlobalScopeProxy::dispatchPaymentRequestEvent(
|
| int eventID,
|
| const WebPaymentAppRequest& webAppRequest) {
|
| - WaitUntilObserver* observer = WaitUntilObserver::create(
|
| + ScriptState::Scope scope(
|
| + workerGlobalScope()->scriptController()->getScriptState());
|
| + WaitUntilObserver* waitUntilObserver = WaitUntilObserver::create(
|
| workerGlobalScope(), WaitUntilObserver::PaymentRequest, eventID);
|
| + RespondWithObserver* respondWithObserver =
|
| + PaymentRequestRespondWithObserver::create(workerGlobalScope(), eventID,
|
| + waitUntilObserver);
|
| +
|
| Event* event = PaymentRequestEvent::create(
|
| EventTypeNames::paymentrequest,
|
| PaymentAppRequestConversion::toPaymentAppRequest(
|
| workerGlobalScope()->scriptController()->getScriptState(),
|
| webAppRequest),
|
| - observer);
|
| - workerGlobalScope()->dispatchExtendableEvent(event, observer);
|
| + respondWithObserver, waitUntilObserver);
|
| +
|
| + waitUntilObserver->willDispatchEvent();
|
| + respondWithObserver->willDispatchEvent();
|
| + DispatchEventResult dispatchResult =
|
| + workerGlobalScope()->dispatchEvent(event);
|
| + respondWithObserver->didDispatchEvent(dispatchResult);
|
| + // false is okay because waitUntil for payment request event doesn't care
|
| + // about the promise rejection or an uncaught runtime script error.
|
| + waitUntilObserver->didDispatchEvent(false /* errorOccurred */);
|
| }
|
|
|
| bool ServiceWorkerGlobalScopeProxy::hasFetchEventHandler() {
|
|
|