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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 { | 49 { |
50 LifecycleNotifier<ExecutionContext, ContextLifecycleObserver>::removeObserve
r(observer); | 50 LifecycleNotifier<ExecutionContext, ContextLifecycleObserver>::removeObserve
r(observer); |
51 } | 51 } |
52 | 52 |
53 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() | 53 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() |
54 { | 54 { |
55 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje
cts); | 55 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje
cts); |
56 Vector<ContextLifecycleObserver*> snapshotOfObservers; | 56 Vector<ContextLifecycleObserver*> snapshotOfObservers; |
57 copyToVector(m_observers, snapshotOfObservers); | 57 copyToVector(m_observers, snapshotOfObservers); |
58 for (ContextLifecycleObserver* observer : snapshotOfObservers) { | 58 for (ContextLifecycleObserver* observer : snapshotOfObservers) { |
59 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjec
tType) | |
60 continue; | |
61 // FIXME: Oilpan: At the moment, it's possible that a ActiveDOMObject | 59 // FIXME: Oilpan: At the moment, it's possible that a ActiveDOMObject |
62 // observer is destructed while iterating. Once we enable Oilpan by defa
ult | 60 // observer is destructed while iterating. Once we enable Oilpan by defa
ult |
63 // for all LifecycleObserver<T>s, we can remove the hack by making m_obs
ervers | 61 // for all LifecycleObserver<T>s, we can remove the hack by making m_obs
ervers |
64 // a HeapHashSet<WeakMember<LifecycleObserver<T>>>. | 62 // a HeapHashSet<WeakMember<LifecycleObserver<T>>>. |
65 // (i.e., we can just iterate m_observers without taking a snapshot). | 63 // (i.e., we can just iterate m_observers without taking a snapshot). |
66 // For more details, see https://codereview.chromium.org/247253002/. | 64 // For more details, see https://codereview.chromium.org/247253002/. |
67 if (m_observers.contains(observer)) { | 65 if (m_observers.contains(observer)) { |
| 66 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) |
| 67 continue; |
68 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); | 68 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); |
69 ASSERT(activeDOMObject->executionContext() == context()); | 69 ASSERT(activeDOMObject->executionContext() == context()); |
70 ASSERT(activeDOMObject->suspendIfNeededCalled()); | 70 ASSERT(activeDOMObject->suspendIfNeededCalled()); |
71 activeDOMObject->resume(); | 71 activeDOMObject->resume(); |
72 } | 72 } |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects() | 76 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects() |
77 { | 77 { |
78 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje
cts); | 78 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje
cts); |
79 Vector<ContextLifecycleObserver*> snapshotOfObservers; | 79 Vector<ContextLifecycleObserver*> snapshotOfObservers; |
80 copyToVector(m_observers, snapshotOfObservers); | 80 copyToVector(m_observers, snapshotOfObservers); |
81 for (ContextLifecycleObserver* observer : snapshotOfObservers) { | 81 for (ContextLifecycleObserver* observer : snapshotOfObservers) { |
82 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjec
tType) | |
83 continue; | |
84 // It's possible that the ActiveDOMObject is already destructed. | 82 // It's possible that the ActiveDOMObject is already destructed. |
85 // See a FIXME above. | 83 // See a FIXME above. |
86 if (m_observers.contains(observer)) { | 84 if (m_observers.contains(observer)) { |
| 85 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) |
| 86 continue; |
87 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); | 87 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); |
88 ASSERT(activeDOMObject->executionContext() == context()); | 88 ASSERT(activeDOMObject->executionContext() == context()); |
89 ASSERT(activeDOMObject->suspendIfNeededCalled()); | 89 ASSERT(activeDOMObject->suspendIfNeededCalled()); |
90 activeDOMObject->suspend(); | 90 activeDOMObject->suspend(); |
91 } | 91 } |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects() | 95 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects() |
96 { | 96 { |
97 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje
cts); | 97 TemporaryChange<IterationType> scope(m_iterating, IteratingOverActiveDOMObje
cts); |
98 Vector<ContextLifecycleObserver*> snapshotOfObservers; | 98 Vector<ContextLifecycleObserver*> snapshotOfObservers; |
99 copyToVector(m_observers, snapshotOfObservers); | 99 copyToVector(m_observers, snapshotOfObservers); |
100 for (ContextLifecycleObserver* observer : snapshotOfObservers) { | 100 for (ContextLifecycleObserver* observer : snapshotOfObservers) { |
101 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjec
tType) | |
102 continue; | |
103 // It's possible that the ActiveDOMObject is already destructed. | 101 // It's possible that the ActiveDOMObject is already destructed. |
104 // See a FIXME above. | 102 // See a FIXME above. |
105 if (m_observers.contains(observer)) { | 103 if (m_observers.contains(observer)) { |
| 104 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) |
| 105 continue; |
106 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); | 106 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); |
107 ASSERT(activeDOMObject->executionContext() == context()); | 107 ASSERT(activeDOMObject->executionContext() == context()); |
108 ASSERT(activeDOMObject->suspendIfNeededCalled()); | 108 ASSERT(activeDOMObject->suspendIfNeededCalled()); |
109 activeDOMObject->stop(); | 109 activeDOMObject->stop(); |
110 } | 110 } |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 unsigned ContextLifecycleNotifier::activeDOMObjectCount() const | 114 unsigned ContextLifecycleNotifier::activeDOMObjectCount() const |
115 { | 115 { |
(...skipping 26 matching lines...) Expand all Loading... |
142 continue; | 142 continue; |
143 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observe
r); | 143 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observe
r); |
144 if (activeDOMObject == object) | 144 if (activeDOMObject == object) |
145 return true; | 145 return true; |
146 } | 146 } |
147 return false; | 147 return false; |
148 } | 148 } |
149 #endif | 149 #endif |
150 | 150 |
151 } // namespace blink | 151 } // namespace blink |
OLD | NEW |