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 30 matching lines...) Expand all Loading... |
41 // FIXME: Oilpan: At the moment, it's possible that a ActiveDOMObject | 41 // FIXME: Oilpan: At the moment, it's possible that a ActiveDOMObject |
42 // observer is destructed while iterating. Once we enable Oilpan by defa
ult | 42 // observer is destructed while iterating. Once we enable Oilpan by defa
ult |
43 // for all LifecycleObserver<T>s, we can remove the hack by making m_obs
ervers | 43 // for all LifecycleObserver<T>s, we can remove the hack by making m_obs
ervers |
44 // a HeapHashSet<WeakMember<LifecycleObserver<T>>>. | 44 // a HeapHashSet<WeakMember<LifecycleObserver<T>>>. |
45 // (i.e., we can just iterate m_observers without taking a snapshot). | 45 // (i.e., we can just iterate m_observers without taking a snapshot). |
46 // For more details, see https://codereview.chromium.org/247253002/. | 46 // For more details, see https://codereview.chromium.org/247253002/. |
47 if (m_observers.contains(observer)) { | 47 if (m_observers.contains(observer)) { |
48 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) | 48 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) |
49 continue; | 49 continue; |
50 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); | 50 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); |
51 ASSERT(activeDOMObject->executionContext() == context()); | 51 ASSERT(activeDOMObject->getExecutionContext() == context()); |
52 ASSERT(activeDOMObject->suspendIfNeededCalled()); | 52 ASSERT(activeDOMObject->suspendIfNeededCalled()); |
53 activeDOMObject->resume(); | 53 activeDOMObject->resume(); |
54 } | 54 } |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects() | 58 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects() |
59 { | 59 { |
60 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); | 60 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
61 Vector<RawPtrWillBeUntracedMember<ContextLifecycleObserver>> snapshotOfObser
vers; | 61 Vector<RawPtrWillBeUntracedMember<ContextLifecycleObserver>> snapshotOfObser
vers; |
62 copyToVector(m_observers, snapshotOfObservers); | 62 copyToVector(m_observers, snapshotOfObservers); |
63 for (ContextLifecycleObserver* observer : snapshotOfObservers) { | 63 for (ContextLifecycleObserver* observer : snapshotOfObservers) { |
64 // It's possible that the ActiveDOMObject is already destructed. | 64 // It's possible that the ActiveDOMObject is already destructed. |
65 // See a FIXME above. | 65 // See a FIXME above. |
66 if (m_observers.contains(observer)) { | 66 if (m_observers.contains(observer)) { |
67 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) | 67 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) |
68 continue; | 68 continue; |
69 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); | 69 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); |
70 ASSERT(activeDOMObject->executionContext() == context()); | 70 ASSERT(activeDOMObject->getExecutionContext() == context()); |
71 ASSERT(activeDOMObject->suspendIfNeededCalled()); | 71 ASSERT(activeDOMObject->suspendIfNeededCalled()); |
72 activeDOMObject->suspend(); | 72 activeDOMObject->suspend(); |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects() | 77 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects() |
78 { | 78 { |
79 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); | 79 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
80 Vector<RawPtrWillBeUntracedMember<ContextLifecycleObserver>> snapshotOfObser
vers; | 80 Vector<RawPtrWillBeUntracedMember<ContextLifecycleObserver>> snapshotOfObser
vers; |
81 copyToVector(m_observers, snapshotOfObservers); | 81 copyToVector(m_observers, snapshotOfObservers); |
82 for (ContextLifecycleObserver* observer : snapshotOfObservers) { | 82 for (ContextLifecycleObserver* observer : snapshotOfObservers) { |
83 // It's possible that the ActiveDOMObject is already destructed. | 83 // It's possible that the ActiveDOMObject is already destructed. |
84 // See a FIXME above. | 84 // See a FIXME above. |
85 if (m_observers.contains(observer)) { | 85 if (m_observers.contains(observer)) { |
86 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) | 86 if (observer->observerType() != ContextLifecycleObserver::ActiveDOMO
bjectType) |
87 continue; | 87 continue; |
88 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); | 88 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(obs
erver); |
89 ASSERT(activeDOMObject->executionContext() == context()); | 89 ASSERT(activeDOMObject->getExecutionContext() == context()); |
90 ASSERT(activeDOMObject->suspendIfNeededCalled()); | 90 ASSERT(activeDOMObject->suspendIfNeededCalled()); |
91 activeDOMObject->stop(); | 91 activeDOMObject->stop(); |
92 } | 92 } |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 unsigned ContextLifecycleNotifier::activeDOMObjectCount() const | 96 unsigned ContextLifecycleNotifier::activeDOMObjectCount() const |
97 { | 97 { |
98 unsigned activeDOMObjects = 0; | 98 unsigned activeDOMObjects = 0; |
99 for (ContextLifecycleObserver* observer : m_observers) { | 99 for (ContextLifecycleObserver* observer : m_observers) { |
(...skipping 12 matching lines...) Expand all Loading... |
112 continue; | 112 continue; |
113 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observe
r); | 113 ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observe
r); |
114 if (activeDOMObject == object) | 114 if (activeDOMObject == object) |
115 return true; | 115 return true; |
116 } | 116 } |
117 return false; | 117 return false; |
118 } | 118 } |
119 #endif | 119 #endif |
120 | 120 |
121 } // namespace blink | 121 } // namespace blink |
OLD | NEW |