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 10 matching lines...) Expand all Loading... | |
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
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 #ifndef ContextLifecycleNotifier_h | 27 #ifndef ContextLifecycleNotifier_h |
28 #define ContextLifecycleNotifier_h | 28 #define ContextLifecycleNotifier_h |
29 | 29 |
30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
31 #include "core/dom/LifecycleNotifier.h" | |
31 #include "wtf/HashSet.h" | 32 #include "wtf/HashSet.h" |
32 #include "wtf/PassOwnPtr.h" | 33 #include "wtf/PassOwnPtr.h" |
33 | 34 |
34 namespace WTF { | 35 namespace WTF { |
35 class MemoryObjectInfo; | 36 class MemoryObjectInfo; |
36 } | 37 } |
37 | 38 |
38 namespace WebCore { | 39 namespace WebCore { |
39 | 40 |
40 class ActiveDOMObject; | 41 class ActiveDOMObject; |
41 class ContextLifecycleObserver; | 42 class ContextLifecycleObserver; |
42 class ScriptExecutionContext; | 43 class ScriptExecutionContext; |
43 | 44 |
44 class ContextLifecycleNotifier { | 45 class ContextLifecycleNotifier : public LifecycleNotifier { |
45 public: | 46 public: |
46 static PassOwnPtr<ContextLifecycleNotifier> create(ScriptExecutionContext*); | 47 static PassOwnPtr<ContextLifecycleNotifier> create(ScriptExecutionContext*); |
47 | 48 |
48 virtual ~ContextLifecycleNotifier(); | 49 virtual ~ContextLifecycleNotifier(); |
49 | 50 |
50 typedef HashSet<ContextLifecycleObserver*> ContextObserverSet; | |
51 typedef HashSet<ActiveDOMObject*> ActiveDOMObjectSet; | 51 typedef HashSet<ActiveDOMObject*> ActiveDOMObjectSet; |
52 | 52 |
53 const ActiveDOMObjectSet& activeDOMObjects() const { return m_activeDOMObjec ts; } | 53 const ActiveDOMObjectSet& activeDOMObjects() const { return m_activeDOMObjec ts; } |
54 | 54 |
55 virtual void addObserver(ContextLifecycleObserver*, ContextLifecycleObserver ::Type as); | 55 virtual void addObserver(LifecycleObserver*, LifecycleObserver::Type) OVERRI DE; |
56 virtual void removeObserver(ContextLifecycleObserver*, ContextLifecycleObser ver::Type as); | 56 virtual void removeObserver(LifecycleObserver*, LifecycleObserver::Type) OVE RRIDE; |
abarth-chromium
2013/07/09 18:27:52
I see.
Michael van Ouwerkerk
2013/07/10 13:25:09
Acknowledged.
| |
57 | 57 |
58 void notifyResumingActiveDOMObjects(); | 58 void notifyResumingActiveDOMObjects(); |
59 void notifySuspendingActiveDOMObjects(ActiveDOMObject::ReasonForSuspension); | 59 void notifySuspendingActiveDOMObjects(ActiveDOMObject::ReasonForSuspension); |
60 void notifyStoppingActiveDOMObjects(); | 60 void notifyStoppingActiveDOMObjects(); |
61 | 61 |
62 bool contains(ActiveDOMObject* object) const { return m_activeDOMObjects.con tains(object); } | 62 bool contains(ActiveDOMObject* object) const { return m_activeDOMObjects.con tains(object); } |
63 bool canSuspendActiveDOMObjects(); | 63 bool canSuspendActiveDOMObjects(); |
64 bool hasPendingActivity() const; | 64 bool hasPendingActivity() const; |
65 | 65 |
66 void reportMemoryUsage(WTF::MemoryObjectInfo*) const; | 66 void reportMemoryUsage(WTF::MemoryObjectInfo*) const; |
67 | 67 |
68 protected: | 68 protected: |
69 explicit ContextLifecycleNotifier(ScriptExecutionContext*); | 69 explicit ContextLifecycleNotifier(ScriptExecutionContext*); |
70 | 70 |
71 enum IterationType { | |
72 IteratingNone, | |
73 IteratingOverActiveDOMObjects, | |
74 IteratingOverContextObservers, | |
75 IteratingOverDocumentObservers | |
76 }; | |
77 | |
78 IterationType m_iterating; | |
79 | |
80 private: | 71 private: |
81 ScriptExecutionContext* m_context; | |
82 ContextObserverSet m_contextObservers; | |
83 ActiveDOMObjectSet m_activeDOMObjects; | 72 ActiveDOMObjectSet m_activeDOMObjects; |
84 bool m_inDestructor; | |
85 }; | 73 }; |
86 | 74 |
87 inline PassOwnPtr<ContextLifecycleNotifier> ContextLifecycleNotifier::create(Scr iptExecutionContext* context) | 75 inline PassOwnPtr<ContextLifecycleNotifier> ContextLifecycleNotifier::create(Scr iptExecutionContext* context) |
88 { | 76 { |
89 return adoptPtr(new ContextLifecycleNotifier(context)); | 77 return adoptPtr(new ContextLifecycleNotifier(context)); |
90 } | 78 } |
91 | 79 |
92 } // namespace WebCore | 80 } // namespace WebCore |
93 | 81 |
94 #endif // ContextLifecycleNotifier_h | 82 #endif // ContextLifecycleNotifier_h |
95 | |
OLD | NEW |