| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #define EventSender_h | 27 #define EventSender_h |
| 28 | 28 |
| 29 #include "platform/Timer.h" | 29 #include "platform/Timer.h" |
| 30 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
| 31 #include "wtf/Vector.h" | 31 #include "wtf/Vector.h" |
| 32 #include "wtf/text/AtomicString.h" | 32 #include "wtf/text/AtomicString.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 template<typename T> | 36 template<typename T> |
| 37 class EventSender final : public NoBaseWillBeGarbageCollectedFinalized<EventSend
er<T>> { | 37 class EventSender final : public GarbageCollectedFinalized<EventSender<T>> { |
| 38 WTF_MAKE_NONCOPYABLE(EventSender); | 38 WTF_MAKE_NONCOPYABLE(EventSender); |
| 39 USING_FAST_MALLOC_WILL_BE_REMOVED(EventSender); | |
| 40 public: | 39 public: |
| 41 static PassOwnPtrWillBeRawPtr<EventSender> create(const AtomicString& eventT
ype) | 40 static RawPtr<EventSender> create(const AtomicString& eventType) |
| 42 { | 41 { |
| 43 return adoptPtrWillBeNoop(new EventSender(eventType)); | 42 return new EventSender(eventType); |
| 44 } | 43 } |
| 45 | 44 |
| 46 const AtomicString& eventType() const { return m_eventType; } | 45 const AtomicString& eventType() const { return m_eventType; } |
| 47 void dispatchEventSoon(T*); | 46 void dispatchEventSoon(T*); |
| 48 void cancelEvent(T*); | 47 void cancelEvent(T*); |
| 49 void dispatchPendingEvents(); | 48 void dispatchPendingEvents(); |
| 50 | 49 |
| 51 #if ENABLE(ASSERT) | 50 #if ENABLE(ASSERT) |
| 52 bool hasPendingEvents(T* sender) const | 51 bool hasPendingEvents(T* sender) const |
| 53 { | 52 { |
| 54 return m_dispatchSoonList.find(sender) != kNotFound || m_dispatchingList
.find(sender) != kNotFound; | 53 return m_dispatchSoonList.find(sender) != kNotFound || m_dispatchingList
.find(sender) != kNotFound; |
| 55 } | 54 } |
| 56 #endif | 55 #endif |
| 57 | 56 |
| 58 DEFINE_INLINE_TRACE() | 57 DEFINE_INLINE_TRACE() |
| 59 { | 58 { |
| 60 visitor->trace(m_dispatchSoonList); | 59 visitor->trace(m_dispatchSoonList); |
| 61 visitor->trace(m_dispatchingList); | 60 visitor->trace(m_dispatchingList); |
| 62 } | 61 } |
| 63 | 62 |
| 64 private: | 63 private: |
| 65 explicit EventSender(const AtomicString& eventType); | 64 explicit EventSender(const AtomicString& eventType); |
| 66 | 65 |
| 67 void timerFired(Timer<EventSender<T>>*) { dispatchPendingEvents(); } | 66 void timerFired(Timer<EventSender<T>>*) { dispatchPendingEvents(); } |
| 68 | 67 |
| 69 AtomicString m_eventType; | 68 AtomicString m_eventType; |
| 70 Timer<EventSender<T>> m_timer; | 69 Timer<EventSender<T>> m_timer; |
| 71 WillBeHeapVector<RawPtrWillBeMember<T>> m_dispatchSoonList; | 70 HeapVector<Member<T>> m_dispatchSoonList; |
| 72 WillBeHeapVector<RawPtrWillBeMember<T>> m_dispatchingList; | 71 HeapVector<Member<T>> m_dispatchingList; |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 template<typename T> EventSender<T>::EventSender(const AtomicString& eventType) | 74 template<typename T> EventSender<T>::EventSender(const AtomicString& eventType) |
| 76 : m_eventType(eventType) | 75 : m_eventType(eventType) |
| 77 , m_timer(this, &EventSender::timerFired) | 76 , m_timer(this, &EventSender::timerFired) |
| 78 { | 77 { |
| 79 } | 78 } |
| 80 | 79 |
| 81 template<typename T> void EventSender<T>::dispatchEventSoon(T* sender) | 80 template<typename T> void EventSender<T>::dispatchEventSoon(T* sender) |
| 82 { | 81 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 m_dispatchingList[i] = nullptr; | 117 m_dispatchingList[i] = nullptr; |
| 119 sender->dispatchPendingEvent(this); | 118 sender->dispatchPendingEvent(this); |
| 120 } | 119 } |
| 121 } | 120 } |
| 122 m_dispatchingList.clear(); | 121 m_dispatchingList.clear(); |
| 123 } | 122 } |
| 124 | 123 |
| 125 } // namespace blink | 124 } // namespace blink |
| 126 | 125 |
| 127 #endif // EventSender_h | 126 #endif // EventSender_h |
| OLD | NEW |