OLD | NEW |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "core/workers/WorkerGlobalScope.h" | 43 #include "core/workers/WorkerGlobalScope.h" |
44 #include "core/workers/WorkerThread.h" | 44 #include "core/workers/WorkerThread.h" |
45 #include "modules/background_sync/SyncEvent.h" | 45 #include "modules/background_sync/SyncEvent.h" |
46 #include "modules/fetch/Headers.h" | 46 #include "modules/fetch/Headers.h" |
47 #include "modules/notifications/Notification.h" | 47 #include "modules/notifications/Notification.h" |
48 #include "modules/notifications/NotificationEvent.h" | 48 #include "modules/notifications/NotificationEvent.h" |
49 #include "modules/notifications/NotificationEventInit.h" | 49 #include "modules/notifications/NotificationEventInit.h" |
50 #include "modules/payments/PaymentAppRequest.h" | 50 #include "modules/payments/PaymentAppRequest.h" |
51 #include "modules/payments/PaymentAppRequestConversion.h" | 51 #include "modules/payments/PaymentAppRequestConversion.h" |
52 #include "modules/payments/PaymentRequestEvent.h" | 52 #include "modules/payments/PaymentRequestEvent.h" |
| 53 #include "modules/payments/PaymentRequestRespondWithObserver.h" |
53 #include "modules/push_messaging/PushEvent.h" | 54 #include "modules/push_messaging/PushEvent.h" |
54 #include "modules/push_messaging/PushMessageData.h" | 55 #include "modules/push_messaging/PushMessageData.h" |
55 #include "modules/serviceworkers/ExtendableEvent.h" | 56 #include "modules/serviceworkers/ExtendableEvent.h" |
56 #include "modules/serviceworkers/ExtendableMessageEvent.h" | 57 #include "modules/serviceworkers/ExtendableMessageEvent.h" |
57 #include "modules/serviceworkers/FetchEvent.h" | 58 #include "modules/serviceworkers/FetchEvent.h" |
58 #include "modules/serviceworkers/ForeignFetchEvent.h" | 59 #include "modules/serviceworkers/ForeignFetchEvent.h" |
59 #include "modules/serviceworkers/InstallEvent.h" | 60 #include "modules/serviceworkers/InstallEvent.h" |
60 #include "modules/serviceworkers/ServiceWorkerClient.h" | 61 #include "modules/serviceworkers/ServiceWorkerClient.h" |
61 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" | 62 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" |
62 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 63 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |