| Index: third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp
|
| diff --git a/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp b/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp
|
| index e233f906a948890ee118987916c53ebb8b512f1b..daf6d1bbd4e81d23fa8e8d9577f0de22d4561119 100644
|
| --- a/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp
|
| +++ b/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.cpp
|
| @@ -80,7 +80,14 @@ class WaitUntilObserver::ThenFunction final : public ScriptFunction {
|
| WaitUntilObserver* WaitUntilObserver::create(ExecutionContext* context,
|
| EventType type,
|
| int eventID) {
|
| - return new WaitUntilObserver(context, type, eventID);
|
| + return new WaitUntilObserver(context, type, eventID, nullptr);
|
| +}
|
| +
|
| +WaitUntilObserver* WaitUntilObserver::create(
|
| + ExecutionContext* context,
|
| + EventType type,
|
| + std::unique_ptr<Callback> callback) {
|
| + return new WaitUntilObserver(context, type, -1, std::move(callback));
|
| }
|
|
|
| void WaitUntilObserver::willDispatchEvent() {
|
| @@ -132,13 +139,15 @@ void WaitUntilObserver::waitUntil(ScriptState* scriptState,
|
|
|
| WaitUntilObserver::WaitUntilObserver(ExecutionContext* context,
|
| EventType type,
|
| - int eventID)
|
| + int eventID,
|
| + std::unique_ptr<Callback> callback)
|
| : ContextLifecycleObserver(context),
|
| m_type(type),
|
| m_eventID(eventID),
|
| m_consumeWindowInteractionTimer(
|
| this,
|
| - &WaitUntilObserver::consumeWindowInteraction) {}
|
| + &WaitUntilObserver::consumeWindowInteraction),
|
| + m_callback(std::move(callback)) {}
|
|
|
| void WaitUntilObserver::reportError(const ScriptValue& value) {
|
| // FIXME: Propagate error message to the client for onerror handling.
|
| @@ -189,7 +198,11 @@ void WaitUntilObserver::decrementPendingActivity() {
|
| client->didHandlePushEvent(m_eventID, result, m_eventDispatchTime);
|
| break;
|
| case Sync:
|
| - client->didHandleSyncEvent(m_eventID, result, m_eventDispatchTime);
|
| + DCHECK(m_callback);
|
| + (*m_callback)(m_hasError
|
| + ? blink::mojom::ServiceWorkerEventStatus::REJECTED
|
| + : blink::mojom::ServiceWorkerEventStatus::COMPLETED,
|
| + m_eventDispatchTime);
|
| break;
|
| }
|
| setContext(nullptr);
|
| @@ -201,6 +214,16 @@ void WaitUntilObserver::consumeWindowInteraction(TimerBase*) {
|
| getExecutionContext()->consumeWindowInteraction();
|
| }
|
|
|
| +void WaitUntilObserver::contextDestroyed() {
|
| + if (m_type == Sync && !m_eventDispatched) {
|
| + DCHECK(m_callback);
|
| + (*m_callback)(blink::mojom::ServiceWorkerEventStatus::ABORTED,
|
| + WTF::currentTime());
|
| + m_eventDispatched = true;
|
| + }
|
| + ContextLifecycleObserver::contextDestroyed();
|
| +}
|
| +
|
| DEFINE_TRACE(WaitUntilObserver) {
|
| ContextLifecycleObserver::trace(visitor);
|
| }
|
|
|