| 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 #ifndef TrackListBase_h | 5 #ifndef TrackListBase_h |
| 6 #define TrackListBase_h | 6 #define TrackListBase_h |
| 7 | 7 |
| 8 #include "core/events/EventTarget.h" | 8 #include "core/events/EventTarget.h" |
| 9 | 9 |
| 10 #include "core/html/HTMLMediaElement.h" | 10 #include "core/html/HTMLMediaElement.h" |
| 11 #include "core/html/track/TrackEvent.h" | 11 #include "core/html/track/TrackEvent.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 template<class T> | 15 template<class T> |
| 16 class TrackListBase : public RefCountedWillBeGarbageCollectedFinalized<TrackList
Base<T> >, public EventTargetWithInlineData { | 16 class TrackListBase : public RefCountedWillBeGarbageCollectedFinalized<TrackList
Base<T>>, public EventTargetWithInlineData { |
| 17 REFCOUNTED_EVENT_TARGET(TrackListBase); | 17 REFCOUNTED_EVENT_TARGET(TrackListBase); |
| 18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TrackListBase); | 18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TrackListBase); |
| 19 public: | 19 public: |
| 20 explicit TrackListBase(HTMLMediaElement* mediaElement) | 20 explicit TrackListBase(HTMLMediaElement* mediaElement) |
| 21 : m_mediaElement(mediaElement) | 21 : m_mediaElement(mediaElement) |
| 22 { | 22 { |
| 23 } | 23 } |
| 24 | 24 |
| 25 virtual ~TrackListBase() | 25 virtual ~TrackListBase() |
| 26 { | 26 { |
| 27 #if !ENABLE(OILPAN) | 27 #if !ENABLE(OILPAN) |
| 28 ASSERT(m_tracks.isEmpty()); | 28 ASSERT(m_tracks.isEmpty()); |
| 29 ASSERT(!m_mediaElement); | 29 ASSERT(!m_mediaElement); |
| 30 #endif | 30 #endif |
| 31 } | 31 } |
| 32 | 32 |
| 33 unsigned length() const { return m_tracks.size(); } | 33 unsigned length() const { return m_tracks.size(); } |
| 34 T* anonymousIndexedGetter(unsigned index) const | 34 T* anonymousIndexedGetter(unsigned index) const |
| 35 { | 35 { |
| 36 if (index >= m_tracks.size()) | 36 if (index >= m_tracks.size()) |
| 37 return 0; | 37 return nullptr; |
| 38 return m_tracks[index].get(); | 38 return m_tracks[index].get(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 T* getTrackById(const String& id) const | 41 T* getTrackById(const String& id) const |
| 42 { | 42 { |
| 43 for (unsigned i = 0; i < m_tracks.size(); ++i) { | 43 for (unsigned i = 0; i < m_tracks.size(); ++i) { |
| 44 if (m_tracks[i]->id() == id) | 44 if (m_tracks[i]->id() == id) |
| 45 return m_tracks[i].get(); | 45 return m_tracks[i].get(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 return 0; | 48 return nullptr; |
| 49 } | 49 } |
| 50 | 50 |
| 51 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 51 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 52 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack); | 52 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack); |
| 53 DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack); | 53 DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack); |
| 54 | 54 |
| 55 // EventTarget interface | 55 // EventTarget interface |
| 56 virtual ExecutionContext* executionContext() const override | 56 virtual ExecutionContext* executionContext() const override |
| 57 { | 57 { |
| 58 if (m_mediaElement) | 58 if (m_mediaElement) |
| 59 return m_mediaElement->executionContext(); | 59 return m_mediaElement->executionContext(); |
| 60 return 0; | 60 return nullptr; |
| 61 } | 61 } |
| 62 | 62 |
| 63 #if !ENABLE(OILPAN) | 63 #if !ENABLE(OILPAN) |
| 64 void shutdown() | 64 void shutdown() |
| 65 { | 65 { |
| 66 removeAll(); | 66 removeAll(); |
| 67 m_mediaElement = nullptr; | 67 m_mediaElement = nullptr; |
| 68 } | 68 } |
| 69 #endif | 69 #endif |
| 70 | 70 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 { | 120 { |
| 121 TrackEventInit initializer; | 121 TrackEventInit initializer; |
| 122 initializer.track = track; | 122 initializer.track = track; |
| 123 initializer.bubbles = false; | 123 initializer.bubbles = false; |
| 124 initializer.cancelable = false; | 124 initializer.cancelable = false; |
| 125 RefPtrWillBeRawPtr<Event> event = TrackEvent::create(eventName, initiali
zer); | 125 RefPtrWillBeRawPtr<Event> event = TrackEvent::create(eventName, initiali
zer); |
| 126 event->setTarget(this); | 126 event->setTarget(this); |
| 127 m_mediaElement->scheduleEvent(event); | 127 m_mediaElement->scheduleEvent(event); |
| 128 } | 128 } |
| 129 | 129 |
| 130 WillBeHeapVector<RefPtrWillBeMember<T> > m_tracks; | 130 WillBeHeapVector<RefPtrWillBeMember<T>> m_tracks; |
| 131 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; | 131 RawPtrWillBeMember<HTMLMediaElement> m_mediaElement; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } | 134 } |
| 135 | 135 |
| 136 #endif | 136 #endif |
| OLD | NEW |