Chromium Code Reviews| 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 066ece3338f87bf3745e4f81c75bb4801122eb48..68090dad7511d6e220e45b57a8620aa8947b31f1 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 { |
| @@ -340,15 +341,29 @@ void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent( |
| void ServiceWorkerGlobalScopeProxy::dispatchPaymentRequestEvent( |
| int eventID, |
| const WebPaymentAppRequest& webAppRequest) { |
| - WaitUntilObserver* observer = WaitUntilObserver::create( |
| + ScriptState::Scope scope( |
|
nhiroki
2017/03/08 02:28:16
You enter the scope because toPaymentAppRequestDat
haraken
2017/03/08 09:28:06
Alternately, how about making toPaymentAppRequest
zino
2017/03/10 17:57:52
Done.
|
| + 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() { |