Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 2705293010: PaymentApp: Implement respondWith() in PaymentRequestEvent. (blink side) (Closed)
Patch Set: PaymentApp: Implement respondWith() in PaymentRequestEvent. (blink side) Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "web/ServiceWorkerGlobalScopeProxy.h" 31 #include "web/ServiceWorkerGlobalScopeProxy.h"
32 32
33 #include <memory>
34 #include <utility>
33 #include "bindings/core/v8/SourceLocation.h" 35 #include "bindings/core/v8/SourceLocation.h"
34 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 36 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
35 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
36 #include "core/dom/ExecutionContext.h" 38 #include "core/dom/ExecutionContext.h"
37 #include "core/dom/ExecutionContextTask.h" 39 #include "core/dom/ExecutionContextTask.h"
38 #include "core/dom/MessagePort.h" 40 #include "core/dom/MessagePort.h"
39 #include "core/inspector/ConsoleMessage.h" 41 #include "core/inspector/ConsoleMessage.h"
40 #include "core/origin_trials/OriginTrials.h" 42 #include "core/origin_trials/OriginTrials.h"
41 #include "core/workers/ParentFrameTaskRunners.h" 43 #include "core/workers/ParentFrameTaskRunners.h"
42 #include "core/workers/WorkerGlobalScope.h" 44 #include "core/workers/WorkerGlobalScope.h"
43 #include "core/workers/WorkerThread.h" 45 #include "core/workers/WorkerThread.h"
44 #include "modules/background_sync/SyncEvent.h" 46 #include "modules/background_sync/SyncEvent.h"
45 #include "modules/fetch/Headers.h" 47 #include "modules/fetch/Headers.h"
46 #include "modules/notifications/Notification.h" 48 #include "modules/notifications/Notification.h"
47 #include "modules/notifications/NotificationEvent.h" 49 #include "modules/notifications/NotificationEvent.h"
48 #include "modules/notifications/NotificationEventInit.h" 50 #include "modules/notifications/NotificationEventInit.h"
49 #include "modules/payments/PaymentAppRequest.h" 51 #include "modules/payments/PaymentAppRequest.h"
50 #include "modules/payments/PaymentAppRequestConversion.h" 52 #include "modules/payments/PaymentAppRequestConversion.h"
51 #include "modules/payments/PaymentRequestEvent.h" 53 #include "modules/payments/PaymentRequestEvent.h"
54 #include "modules/payments/PaymentRequestRespondWithObserver.h"
52 #include "modules/push_messaging/PushEvent.h" 55 #include "modules/push_messaging/PushEvent.h"
53 #include "modules/push_messaging/PushMessageData.h" 56 #include "modules/push_messaging/PushMessageData.h"
54 #include "modules/serviceworkers/ExtendableEvent.h" 57 #include "modules/serviceworkers/ExtendableEvent.h"
55 #include "modules/serviceworkers/ExtendableMessageEvent.h" 58 #include "modules/serviceworkers/ExtendableMessageEvent.h"
56 #include "modules/serviceworkers/FetchEvent.h" 59 #include "modules/serviceworkers/FetchEvent.h"
57 #include "modules/serviceworkers/ForeignFetchEvent.h" 60 #include "modules/serviceworkers/ForeignFetchEvent.h"
58 #include "modules/serviceworkers/InstallEvent.h" 61 #include "modules/serviceworkers/InstallEvent.h"
59 #include "modules/serviceworkers/ServiceWorkerClient.h" 62 #include "modules/serviceworkers/ServiceWorkerClient.h"
60 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 63 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
61 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" 64 #include "modules/serviceworkers/ServiceWorkerWindowClient.h"
62 #include "modules/serviceworkers/WaitUntilObserver.h" 65 #include "modules/serviceworkers/WaitUntilObserver.h"
63 #include "platform/RuntimeEnabledFeatures.h" 66 #include "platform/RuntimeEnabledFeatures.h"
64 #include "public/platform/modules/notifications/WebNotificationData.h" 67 #include "public/platform/modules/notifications/WebNotificationData.h"
65 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" 68 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h"
66 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" 69 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
67 #include "public/web/WebSerializedScriptValue.h" 70 #include "public/web/WebSerializedScriptValue.h"
68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 71 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
69 #include "web/WebEmbeddedWorkerImpl.h" 72 #include "web/WebEmbeddedWorkerImpl.h"
70 #include "wtf/Assertions.h" 73 #include "wtf/Assertions.h"
71 #include "wtf/Functional.h" 74 #include "wtf/Functional.h"
72 #include "wtf/PtrUtil.h" 75 #include "wtf/PtrUtil.h"
73 #include <memory>
74 #include <utility>
75 76
76 namespace blink { 77 namespace blink {
77 78
78 ServiceWorkerGlobalScopeProxy* ServiceWorkerGlobalScopeProxy::create( 79 ServiceWorkerGlobalScopeProxy* ServiceWorkerGlobalScopeProxy::create(
79 WebEmbeddedWorkerImpl& embeddedWorker, 80 WebEmbeddedWorkerImpl& embeddedWorker,
80 Document& document, 81 Document& document,
81 WebServiceWorkerContextClient& client) { 82 WebServiceWorkerContextClient& client) {
82 return new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client); 83 return new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client);
83 } 84 }
84 85
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 WaitUntilObserver* observer = WaitUntilObserver::create( 335 WaitUntilObserver* observer = WaitUntilObserver::create(
335 workerGlobalScope(), WaitUntilObserver::Sync, eventID); 336 workerGlobalScope(), WaitUntilObserver::Sync, eventID);
336 Event* event = SyncEvent::create(EventTypeNames::sync, tag, 337 Event* event = SyncEvent::create(EventTypeNames::sync, tag,
337 lastChance == IsLastChance, observer); 338 lastChance == IsLastChance, observer);
338 workerGlobalScope()->dispatchExtendableEvent(event, observer); 339 workerGlobalScope()->dispatchExtendableEvent(event, observer);
339 } 340 }
340 341
341 void ServiceWorkerGlobalScopeProxy::dispatchPaymentRequestEvent( 342 void ServiceWorkerGlobalScopeProxy::dispatchPaymentRequestEvent(
342 int eventID, 343 int eventID,
343 const WebPaymentAppRequest& webAppRequest) { 344 const WebPaymentAppRequest& webAppRequest) {
344 WaitUntilObserver* observer = WaitUntilObserver::create( 345 WaitUntilObserver* waitUntilObserver = WaitUntilObserver::create(
345 workerGlobalScope(), WaitUntilObserver::PaymentRequest, eventID); 346 workerGlobalScope(), WaitUntilObserver::PaymentRequest, eventID);
347 RespondWithObserver* respondWithObserver =
348 PaymentRequestRespondWithObserver::create(workerGlobalScope(), eventID,
349 waitUntilObserver);
350
346 Event* event = PaymentRequestEvent::create( 351 Event* event = PaymentRequestEvent::create(
347 EventTypeNames::paymentrequest, 352 EventTypeNames::paymentrequest,
348 PaymentAppRequestConversion::toPaymentAppRequest( 353 PaymentAppRequestConversion::toPaymentAppRequest(
349 workerGlobalScope()->scriptController()->getScriptState(), 354 workerGlobalScope()->scriptController()->getScriptState(),
350 webAppRequest), 355 webAppRequest),
351 observer); 356 respondWithObserver, waitUntilObserver);
352 workerGlobalScope()->dispatchExtendableEvent(event, observer); 357
358 waitUntilObserver->willDispatchEvent();
359 respondWithObserver->willDispatchEvent();
360 DispatchEventResult dispatchResult =
361 workerGlobalScope()->dispatchEvent(event);
362 respondWithObserver->didDispatchEvent(dispatchResult);
363 // false is okay because waitUntil for payment request event doesn't care
364 // about the promise rejection or an uncaught runtime script error.
365 waitUntilObserver->didDispatchEvent(false /* errorOccurred */);
353 } 366 }
354 367
355 bool ServiceWorkerGlobalScopeProxy::hasFetchEventHandler() { 368 bool ServiceWorkerGlobalScopeProxy::hasFetchEventHandler() {
356 DCHECK(m_workerGlobalScope); 369 DCHECK(m_workerGlobalScope);
357 return m_workerGlobalScope->hasEventListeners(EventTypeNames::fetch); 370 return m_workerGlobalScope->hasEventListeners(EventTypeNames::fetch);
358 } 371 }
359 372
360 void ServiceWorkerGlobalScopeProxy::countFeature(UseCounter::Feature feature) { 373 void ServiceWorkerGlobalScopeProxy::countFeature(UseCounter::Feature feature) {
361 client().countFeature(static_cast<uint32_t>(feature)); 374 client().countFeature(static_cast<uint32_t>(feature));
362 } 375 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return *m_document; 497 return *m_document;
485 } 498 }
486 499
487 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() 500 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope()
488 const { 501 const {
489 DCHECK(m_workerGlobalScope); 502 DCHECK(m_workerGlobalScope);
490 return m_workerGlobalScope; 503 return m_workerGlobalScope;
491 } 504 }
492 505
493 } // namespace blink 506 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698