| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 template<typename T, typename Observer> | 101 template<typename T, typename Observer> |
| 102 inline void LifecycleNotifier<T, Observer>::notifyContextDestroyed() | 102 inline void LifecycleNotifier<T, Observer>::notifyContextDestroyed() |
| 103 { | 103 { |
| 104 // Don't notify contextDestroyed() twice. | 104 // Don't notify contextDestroyed() twice. |
| 105 if (m_didCallContextDestroyed) | 105 if (m_didCallContextDestroyed) |
| 106 return; | 106 return; |
| 107 | 107 |
| 108 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); | 108 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
| 109 Vector<Observer*> snapshotOfObservers; | 109 WillBeHeapVector<RawPtrWillBeMember<Observer>> snapshotOfObservers; |
| 110 copyToVector(m_observers, snapshotOfObservers); | 110 copyToVector(m_observers, snapshotOfObservers); |
| 111 for (Observer* observer : snapshotOfObservers) { | 111 for (Observer* observer : snapshotOfObservers) { |
| 112 // FIXME: Oilpan: At the moment, it's possible that the Observer is | 112 // FIXME: Oilpan: At the moment, it's possible that the Observer is |
| 113 // destructed during the iteration. Once we enable Oilpan by default | 113 // destructed during the iteration. Once we enable Oilpan by default |
| 114 // for Observers, we can remove the hack by making m_observers | 114 // for Observers, we can remove the hack by making m_observers |
| 115 // a HeapHashSet<WeakMember<Observers>>. (i.e., we can just iterate | 115 // a HeapHashSet<WeakMember<Observers>>. (i.e., we can just iterate |
| 116 // m_observers without taking a snapshot). | 116 // m_observers without taking a snapshot). |
| 117 if (m_observers.contains(observer)) { | 117 if (m_observers.contains(observer)) { |
| 118 ASSERT(observer->lifecycleContext() == context()); | 118 ASSERT(observer->lifecycleContext() == context()); |
| 119 observer->contextDestroyed(); | 119 observer->contextDestroyed(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 | 131 |
| 132 template<typename T, typename Observer> | 132 template<typename T, typename Observer> |
| 133 inline void LifecycleNotifier<T, Observer>::removeObserver(Observer* observer) | 133 inline void LifecycleNotifier<T, Observer>::removeObserver(Observer* observer) |
| 134 { | 134 { |
| 135 m_observers.remove(observer); | 135 m_observers.remove(observer); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace blink | 138 } // namespace blink |
| 139 | 139 |
| 140 #endif // LifecycleNotifier_h | 140 #endif // LifecycleNotifier_h |
| OLD | NEW |