| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/frame/PlatformEventDispatcher.h" | 6 #include "core/frame/PlatformEventDispatcher.h" |
| 7 | 7 |
| 8 #include "core/frame/PlatformEventController.h" | 8 #include "core/frame/PlatformEventController.h" |
| 9 #include "wtf/TemporaryChange.h" | 9 #include "wtf/TemporaryChange.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 PlatformEventDispatcher::PlatformEventDispatcher() | 13 PlatformEventDispatcher::PlatformEventDispatcher() |
| 14 : m_needsPurge(false) | 14 : m_needsPurge(false) |
| 15 , m_isDispatching(false) | 15 , m_isDispatching(false) |
| 16 { | 16 { |
| 17 } | 17 } |
| 18 | 18 |
| 19 PlatformEventDispatcher::~PlatformEventDispatcher() | |
| 20 { | |
| 21 } | |
| 22 | |
| 23 void PlatformEventDispatcher::addController(PlatformEventController* controller) | 19 void PlatformEventDispatcher::addController(PlatformEventController* controller) |
| 24 { | 20 { |
| 25 bool wasEmpty = m_controllers.isEmpty(); | 21 bool wasEmpty = m_controllers.isEmpty(); |
| 26 if (!m_controllers.contains(controller)) | 22 if (!m_controllers.contains(controller)) |
| 27 m_controllers.append(controller); | 23 m_controllers.append(controller); |
| 28 if (wasEmpty) | 24 if (wasEmpty) |
| 29 startListening(); | 25 startListening(); |
| 30 } | 26 } |
| 31 | 27 |
| 32 void PlatformEventDispatcher::removeController(PlatformEventController* controll
er) | 28 void PlatformEventDispatcher::removeController(PlatformEventController* controll
er) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 for (size_t i = 0; i < size; ++i) { | 73 for (size_t i = 0; i < size; ++i) { |
| 78 if (m_controllers[i]) | 74 if (m_controllers[i]) |
| 79 m_controllers[i]->didUpdateData(); | 75 m_controllers[i]->didUpdateData(); |
| 80 } | 76 } |
| 81 } | 77 } |
| 82 | 78 |
| 83 if (m_needsPurge) | 79 if (m_needsPurge) |
| 84 purgeControllers(); | 80 purgeControllers(); |
| 85 } | 81 } |
| 86 | 82 |
| 83 void PlatformEventDispatcher::trace(Visitor* visitor) |
| 84 { |
| 85 #if ENABLE(OILPAN) |
| 86 // Trace the backing store, the weak(&bare) element references won't be. |
| 87 visitor->trace(m_controllers); |
| 88 visitor->registerWeakMembers<PlatformEventDispatcher, &PlatformEventDispatch
er::clearWeakMembers>(this); |
| 89 #endif |
| 90 } |
| 91 |
| 92 #if ENABLE(OILPAN) |
| 93 void PlatformEventDispatcher::clearWeakMembers(Visitor* visitor) |
| 94 { |
| 95 for (size_t i = 0; i < m_controllers.size(); ++i) { |
| 96 if (!visitor->isAlive(m_controllers[i])) { |
| 97 m_controllers[i] = nullptr; |
| 98 m_needsPurge = true; |
| 99 } |
| 100 } |
| 101 // Next notification will purge the empty slots. |
| 102 } |
| 103 #endif |
| 104 |
| 87 } // namespace blink | 105 } // namespace blink |
| OLD | NEW |