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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }; | 72 }; |
73 | 73 |
74 // Iteration state is recorded while iterating the observer set, | 74 // Iteration state is recorded while iterating the observer set, |
75 // optionally barring add or remove mutations. | 75 // optionally barring add or remove mutations. |
76 IterationState m_iterationState; | 76 IterationState m_iterationState; |
77 ObserverSet m_observers; | 77 ObserverSet m_observers; |
78 }; | 78 }; |
79 | 79 |
80 template <typename T, typename Observer> | 80 template <typename T, typename Observer> |
81 inline LifecycleNotifier<T, Observer>::~LifecycleNotifier() { | 81 inline LifecycleNotifier<T, Observer>::~LifecycleNotifier() { |
82 // FIXME: Enable the following ASSERT. Also see a FIXME in Document::detachLay
outTree(). | 82 // FIXME: Enable the following ASSERT. Also see a FIXME in |
| 83 // Document::detachLayoutTree(). |
83 // ASSERT(!m_observers.size()); | 84 // ASSERT(!m_observers.size()); |
84 } | 85 } |
85 | 86 |
86 template <typename T, typename Observer> | 87 template <typename T, typename Observer> |
87 inline void LifecycleNotifier<T, Observer>::notifyContextDestroyed() { | 88 inline void LifecycleNotifier<T, Observer>::notifyContextDestroyed() { |
88 // Observer unregistration is allowed, but effectively a no-op. | 89 // Observer unregistration is allowed, but effectively a no-op. |
89 AutoReset<IterationState> scope(&m_iterationState, AllowingRemoval); | 90 AutoReset<IterationState> scope(&m_iterationState, AllowingRemoval); |
90 ObserverSet observers; | 91 ObserverSet observers; |
91 m_observers.swap(observers); | 92 m_observers.swap(observers); |
92 for (Observer* observer : observers) { | 93 for (Observer* observer : observers) { |
(...skipping 29 matching lines...) Expand all Loading... |
122 // the table is likely to become garbage soon. | 123 // the table is likely to become garbage soon. |
123 ThreadState::NoAllocationScope scope(ThreadState::current()); | 124 ThreadState::NoAllocationScope scope(ThreadState::current()); |
124 observers.removeAll(m_observers); | 125 observers.removeAll(m_observers); |
125 } | 126 } |
126 m_observers.swap(observers); | 127 m_observers.swap(observers); |
127 } | 128 } |
128 | 129 |
129 } // namespace blink | 130 } // namespace blink |
130 | 131 |
131 #endif // LifecycleNotifier_h | 132 #endif // LifecycleNotifier_h |
OLD | NEW |