Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WaitUntilObserver_h | 5 #ifndef WaitUntilObserver_h |
| 6 #define WaitUntilObserver_h | 6 #define WaitUntilObserver_h |
| 7 | 7 |
| 8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
| 9 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
| 10 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 10 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 11 #include "platform/Timer.h" | 11 #include "platform/Timer.h" |
| 12 #include "wtf/Forward.h" | 12 #include "wtf/Forward.h" |
| 13 #include "wtf/RefCounted.h" | 13 #include "wtf/RefCounted.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class ExceptionState; | 17 class ExceptionState; |
| 18 class ExecutionContext; | 18 class ExecutionContext; |
| 19 class ScriptPromise; | |
| 19 class ScriptState; | 20 class ScriptState; |
| 20 class ScriptValue; | 21 class ScriptValue; |
|
yhirano
2015/07/29 06:28:40
-ScriptValue
jungkees
2015/07/29 07:55:46
It seems reportError() uses the type.
yhirano
2015/07/29 08:00:02
You're right, sorry.
| |
| 21 | 22 |
| 22 // Created for each ExtendableEvent instance. | 23 // Created for each ExtendableEvent instance. |
| 23 class MODULES_EXPORT WaitUntilObserver final : public GarbageCollectedFinalized< WaitUntilObserver>, public ContextLifecycleObserver { | 24 class MODULES_EXPORT WaitUntilObserver final : public GarbageCollectedFinalized< WaitUntilObserver>, public ContextLifecycleObserver { |
| 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WaitUntilObserver); | 25 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WaitUntilObserver); |
| 25 public: | 26 public: |
| 26 enum EventType { | 27 enum EventType { |
| 27 Activate, | 28 Activate, |
| 28 Install, | 29 Install, |
| 29 NotificationClick, | 30 NotificationClick, |
| 30 Push, | 31 Push, |
| 31 Sync | 32 Sync |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 static WaitUntilObserver* create(ExecutionContext*, EventType, int eventID); | 35 static WaitUntilObserver* create(ExecutionContext*, EventType, int eventID); |
| 35 | 36 |
| 36 // Must be called before and after dispatching the event. | 37 // Must be called before and after dispatching the event. |
| 37 void willDispatchEvent(); | 38 void willDispatchEvent(); |
| 38 void didDispatchEvent(bool errorOccurred); | 39 void didDispatchEvent(bool errorOccurred); |
| 39 | 40 |
| 40 // Observes the promise and delays calling the continuation until | 41 // Observes the promise and delays calling the continuation until |
| 41 // the given promise is resolved or rejected. | 42 // the given promise is resolved or rejected. |
| 42 void waitUntil(ScriptState*, const ScriptValue&, ExceptionState&); | 43 void waitUntil(ScriptState*, ScriptPromise, ExceptionState&); |
| 43 | 44 |
| 44 DECLARE_VIRTUAL_TRACE(); | 45 DECLARE_VIRTUAL_TRACE(); |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 friend class InternalsServiceWorker; | 48 friend class InternalsServiceWorker; |
| 48 class ThenFunction; | 49 class ThenFunction; |
| 49 | 50 |
| 50 WaitUntilObserver(ExecutionContext*, EventType, int eventID); | 51 WaitUntilObserver(ExecutionContext*, EventType, int eventID); |
| 51 | 52 |
| 52 void reportError(const ScriptValue&); | 53 void reportError(const ScriptValue&); |
| 53 | 54 |
| 54 void incrementPendingActivity(); | 55 void incrementPendingActivity(); |
| 55 void decrementPendingActivity(); | 56 void decrementPendingActivity(); |
| 56 | 57 |
| 57 void consumeWindowInteraction(Timer<WaitUntilObserver>*); | 58 void consumeWindowInteraction(Timer<WaitUntilObserver>*); |
| 58 | 59 |
| 59 EventType m_type; | 60 EventType m_type; |
| 60 int m_eventID; | 61 int m_eventID; |
| 61 int m_pendingActivity; | 62 int m_pendingActivity; |
| 62 bool m_hasError; | 63 bool m_hasError; |
| 63 bool m_eventDispatched; | 64 bool m_eventDispatched; |
| 64 Timer<WaitUntilObserver> m_consumeWindowInteractionTimer; | 65 Timer<WaitUntilObserver> m_consumeWindowInteractionTimer; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 } // namespace blink | 68 } // namespace blink |
| 68 | 69 |
| 69 #endif // WaitUntilObserver_h | 70 #endif // WaitUntilObserver_h |
| OLD | NEW |