| 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 "heap/Handle.h" | |
| 10 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 9 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 11 #include "wtf/Forward.h" | 10 #include "wtf/Forward.h" |
| 12 #include "wtf/RefCounted.h" | 11 #include "wtf/RefCounted.h" |
| 13 | 12 |
| 14 namespace WebCore { | 13 namespace WebCore { |
| 15 | 14 |
| 16 class ExecutionContext; | 15 class ExecutionContext; |
| 17 class ScriptValue; | 16 class ScriptValue; |
| 18 | 17 |
| 19 // Created for each InstallPhaseEvent instance. | 18 // Created for each InstallPhaseEvent instance. |
| 20 class WaitUntilObserver FINAL : | 19 class WaitUntilObserver FINAL : |
| 21 public RefCountedWillBeGarbageCollectedFinalized<WaitUntilObserver>, | 20 public ContextLifecycleObserver, |
| 22 public ContextLifecycleObserver { | 21 public RefCounted<WaitUntilObserver> { |
| 23 DECLARE_GC_INFO; | |
| 24 public: | 22 public: |
| 25 static PassRefPtrWillBeRawPtr<WaitUntilObserver> create(ExecutionContext*, i
nt eventID); | 23 static PassRefPtr<WaitUntilObserver> create(ExecutionContext*, int eventID); |
| 26 | 24 |
| 27 ~WaitUntilObserver(); | 25 ~WaitUntilObserver(); |
| 28 | 26 |
| 29 // Must be called before and after dispatching the event. | 27 // Must be called before and after dispatching the event. |
| 30 void willDispatchEvent(); | 28 void willDispatchEvent(); |
| 31 void didDispatchEvent(); | 29 void didDispatchEvent(); |
| 32 | 30 |
| 33 // Observes the promise and delays calling didHandleInstallEvent() until | 31 // Observes the promise and delays calling didHandleInstallEvent() until |
| 34 // the given promise is resolved or rejected. | 32 // the given promise is resolved or rejected. |
| 35 void waitUntil(const ScriptValue&); | 33 void waitUntil(const ScriptValue&); |
| 36 | 34 |
| 37 void trace(Visitor*) { } | |
| 38 | |
| 39 private: | 35 private: |
| 40 class ThenFunction; | 36 class ThenFunction; |
| 41 | 37 |
| 42 WaitUntilObserver(ExecutionContext*, int eventID); | 38 WaitUntilObserver(ExecutionContext*, int eventID); |
| 43 | 39 |
| 44 void reportError(const ScriptValue&); | 40 void reportError(const ScriptValue&); |
| 45 | 41 |
| 46 void incrementPendingActivity(); | 42 void incrementPendingActivity(); |
| 47 void decrementPendingActivity(); | 43 void decrementPendingActivity(); |
| 48 | 44 |
| 49 int m_eventID; | 45 int m_eventID; |
| 50 int m_pendingActivity; | 46 int m_pendingActivity; |
| 51 }; | 47 }; |
| 52 | 48 |
| 53 } // namespace WebCore | 49 } // namespace WebCore |
| 54 | 50 |
| 55 #endif // WaitUntilObserver_h | 51 #endif // WaitUntilObserver_h |
| OLD | NEW |