Chromium Code Reviews| Index: third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.h |
| diff --git a/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.h b/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.h |
| index 85fd3a1fc13e205ef84835777b8ff367834c404f..730ceac501ff6ea80e52d4de88588cc0f86bdf8f 100644 |
| --- a/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.h |
| +++ b/third_party/WebKit/Source/modules/serviceworkers/WaitUntilObserver.h |
| @@ -9,6 +9,7 @@ |
| #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| #include "platform/Timer.h" |
| #include "platform/wtf/Forward.h" |
| +#include "platform/wtf/Functional.h" |
| namespace blink { |
| @@ -21,6 +22,8 @@ class ScriptState; |
| class MODULES_EXPORT WaitUntilObserver final |
| : public GarbageCollectedFinalized<WaitUntilObserver> { |
| public: |
| + using PromiseSettledCallback = Function<void(const ScriptValue&)>; |
| + |
| enum EventType { |
| kActivate, |
| kFetch, |
| @@ -49,15 +52,12 @@ class MODULES_EXPORT WaitUntilObserver final |
| // Observes the promise and delays calling the continuation until |
|
falken
2017/05/25 07:23:24
s/the continuation/reporting to ServiceWorkerGloba
leonhsl(Using Gerrit)
2017/05/25 10:11:36
Done.
|
| // the given promise is resolved or rejected. |
|
falken
2017/05/25 07:23:24
WaitUntil may be called multiple times. The event
leonhsl(Using Gerrit)
2017/05/25 10:11:36
Done.
Thanks! Exactly what we should say here ;-)
|
| - void WaitUntil(ScriptState*, ScriptPromise, ExceptionState&); |
| - |
| - // These methods can be called when the lifecycle of ExtendableEvent |
| - // observed by this WaitUntilObserver should be extended by other reason |
| - // than ExtendableEvent.waitUntil. |
| - // Note: There is no need to call decrementPendingActivity() after the context |
| - // is being destroyed. |
| - void IncrementPendingActivity(); |
| - void DecrementPendingActivity(); |
| + void WaitUntil( |
| + ScriptState*, |
| + ScriptPromise, |
|
falken
2017/05/25 07:23:24
|promise|
leonhsl(Using Gerrit)
2017/05/25 10:11:36
Done.
|
| + ExceptionState&, |
| + std::unique_ptr<PromiseSettledCallback> on_promise_fulfilled = nullptr, |
| + std::unique_ptr<PromiseSettledCallback> on_promise_rejected = nullptr); |
| DECLARE_VIRTUAL_TRACE(); |
| @@ -66,31 +66,38 @@ class MODULES_EXPORT WaitUntilObserver final |
| class ThenFunction; |
| enum class EventDispatchState { |
| - // Event dispatch has not yet finished. |
| + // Event dispatch has not yet started. |
| kInitial, |
| + // Event dispatch has started but not yet finished. |
| + kDispatching, |
| // Event dispatch completed. There may still be outstanding waitUntil |
| // promises that must settle before notifying ServiceWorkerGlobalScopeClient |
| // that the event finished. |
| - kCompleted, |
| + kDispatched, |
| // Event dispatch failed. Any outstanding waitUntil promises are ignored. |
| kFailed |
| }; |
| WaitUntilObserver(ExecutionContext*, EventType, int event_id); |
| - // Called when a promise passed to a waitUntil() call that is associated with |
| - // this observer was fulfilled. |
| + void IncrementPendingPromise(); |
| + void DecrementPendingPromise(); |
|
falken
2017/05/25 07:23:24
IncrementPendingPromiseCount
DecrementPrendingProm
leonhsl(Using Gerrit)
2017/05/25 10:11:36
Done.
|
| + |
| + // Enqueued as a microtask when a promise passed to a waitUntil() call that is |
| + // associated with this observer was fulfilled. |
| void OnPromiseFulfilled(); |
| - // Called when a promise passed to a waitUntil() call that is associated with |
| - // this observer was rejected. |
| + // Enqueued as a microtask when a promise passed to a waitUntil() call that is |
| + // associated with this observer was rejected. |
| void OnPromiseRejected(); |
| void ConsumeWindowInteraction(TimerBase*); |
| + void MaybeCompleteEvent(); |
| + |
| Member<ExecutionContext> execution_context_; |
| EventType type_; |
| int event_id_; |
| - int pending_activity_ = 0; |
| + int pending_promises_ = 0; |
| EventDispatchState event_dispatch_state_ = EventDispatchState::kInitial; |
| bool has_rejected_promise_ = false; |
| double event_dispatch_time_ = 0; |