OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 11 matching lines...) Expand all Loading... |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #ifndef ContextLifecycleNotifier_h | 28 #ifndef ContextLifecycleNotifier_h |
29 #define ContextLifecycleNotifier_h | 29 #define ContextLifecycleNotifier_h |
30 | 30 |
31 #include "platform/LifecycleNotifier.h" | 31 #include "platform/LifecycleNotifier.h" |
32 #include "wtf/HashSet.h" | |
33 | 32 |
34 namespace blink { | 33 namespace blink { |
35 | 34 |
36 class ActiveDOMObject; | 35 class ActiveDOMObject; |
37 class ContextLifecycleObserver; | 36 class ContextLifecycleObserver; |
38 class ExecutionContext; | 37 class ExecutionContext; |
39 | 38 |
40 class ContextLifecycleNotifier : public LifecycleNotifier<ExecutionContext, Cont
extLifecycleObserver> { | 39 class ContextLifecycleNotifier : public LifecycleNotifier<ExecutionContext, Cont
extLifecycleObserver> { |
41 public: | 40 public: |
42 void addObserver(ContextLifecycleObserver*); | 41 void addObserver(ContextLifecycleObserver*); |
43 void removeObserver(ContextLifecycleObserver*); | 42 void removeObserver(ContextLifecycleObserver*); |
44 | 43 |
45 void notifyResumingActiveDOMObjects(); | 44 void notifyResumingActiveDOMObjects(); |
46 void notifySuspendingActiveDOMObjects(); | 45 void notifySuspendingActiveDOMObjects(); |
47 void notifyStoppingActiveDOMObjects(); | 46 void notifyStoppingActiveDOMObjects(); |
48 | 47 |
49 using ActiveDOMObjectSet = HashSet<ActiveDOMObject*>; | 48 unsigned activeDOMObjectCount() const; |
50 | |
51 const ActiveDOMObjectSet& activeDOMObjects() const { return m_activeDOMObjec
ts; } | |
52 bool contains(ActiveDOMObject* object) const { return m_activeDOMObjects.con
tains(object); } | |
53 bool hasPendingActivity() const; | 49 bool hasPendingActivity() const; |
54 | 50 |
55 protected: | 51 protected: |
56 explicit ContextLifecycleNotifier(ExecutionContext*); | 52 explicit ContextLifecycleNotifier(ExecutionContext*); |
57 | 53 |
58 private: | 54 #if ENABLE(ASSERT) |
59 ActiveDOMObjectSet m_activeDOMObjects; | 55 bool contains(ActiveDOMObject*) const; |
| 56 #endif |
60 }; | 57 }; |
61 | 58 |
62 } // namespace blink | 59 } // namespace blink |
63 | 60 |
64 #endif // ContextLifecycleNotifier_h | 61 #endif // ContextLifecycleNotifier_h |
OLD | NEW |