OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 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 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef MediaController_h | 26 #ifndef MediaController_h |
27 #define MediaController_h | 27 #define MediaController_h |
28 | 28 |
29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
30 #include "core/events/EventTarget.h" | 30 #include "core/events/EventTarget.h" |
31 #include "core/html/HTMLMediaElement.h" | 31 #include "core/html/HTMLMediaElement.h" |
| 32 #include "wtf/LinkedHashSet.h" |
32 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
33 #include "wtf/RefCounted.h" | 34 #include "wtf/RefCounted.h" |
34 #include "wtf/Vector.h" | |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 class Clock; | 38 class Clock; |
39 class ExceptionState; | 39 class ExceptionState; |
40 class ExecutionContext; | 40 class ExecutionContext; |
41 class GenericEventQueue; | 41 class GenericEventQueue; |
42 | 42 |
43 class MediaController FINAL : public RefCountedWillBeRefCountedGarbageCollected<
MediaController>, public ScriptWrappable, public EventTargetWithInlineData { | 43 class MediaController FINAL : public RefCountedWillBeRefCountedGarbageCollected<
MediaController>, public ScriptWrappable, public EventTargetWithInlineData { |
44 REFCOUNTED_EVENT_TARGET(MediaController); | 44 REFCOUNTED_EVENT_TARGET(MediaController); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ReadyState readyState() const { return m_readyState; } | 79 ReadyState readyState() const { return m_readyState; } |
80 | 80 |
81 enum PlaybackState { WAITING, PLAYING, ENDED }; | 81 enum PlaybackState { WAITING, PLAYING, ENDED }; |
82 const AtomicString& playbackState() const; | 82 const AtomicString& playbackState() const; |
83 | 83 |
84 bool isRestrained() const; | 84 bool isRestrained() const; |
85 bool isBlocked() const; | 85 bool isBlocked() const; |
86 | 86 |
87 void clearExecutionContext() { m_executionContext = 0; } | 87 void clearExecutionContext() { m_executionContext = 0; } |
88 | 88 |
| 89 virtual void trace(Visitor*) OVERRIDE; |
| 90 |
89 private: | 91 private: |
90 MediaController(ExecutionContext*); | 92 MediaController(ExecutionContext*); |
91 void reportControllerState(); | 93 void reportControllerState(); |
92 void updateReadyState(); | 94 void updateReadyState(); |
93 void updatePlaybackState(); | 95 void updatePlaybackState(); |
94 void updateMediaElements(); | 96 void updateMediaElements(); |
95 void bringElementUpToSpeed(HTMLMediaElement*); | 97 void bringElementUpToSpeed(HTMLMediaElement*); |
96 void scheduleEvent(const AtomicString& eventName); | 98 void scheduleEvent(const AtomicString& eventName); |
97 void clearPositionTimerFired(Timer<MediaController>*); | 99 void clearPositionTimerFired(Timer<MediaController>*); |
98 bool hasEnded() const; | 100 bool hasEnded() const; |
99 void scheduleTimeupdateEvent(); | 101 void scheduleTimeupdateEvent(); |
100 void timeupdateTimerFired(Timer<MediaController>*); | 102 void timeupdateTimerFired(Timer<MediaController>*); |
101 void startTimeupdateTimer(); | 103 void startTimeupdateTimer(); |
102 | 104 |
103 // EventTarget | 105 // EventTarget |
104 virtual const AtomicString& interfaceName() const OVERRIDE; | 106 virtual const AtomicString& interfaceName() const OVERRIDE; |
105 virtual ExecutionContext* executionContext() const OVERRIDE { return m_execu
tionContext; } | 107 virtual ExecutionContext* executionContext() const OVERRIDE { return m_execu
tionContext; } |
106 | 108 |
107 friend class HTMLMediaElement; | 109 friend class HTMLMediaElement; |
108 friend class MediaControllerEventListener; | 110 friend class MediaControllerEventListener; |
109 Vector<HTMLMediaElement*> m_mediaElements; | 111 // FIXME: A MediaController should ideally keep an otherwise |
| 112 // unreferenced slaved media element alive. When Oilpan is |
| 113 // enabled by default, consider making the hash set references |
| 114 // strong to accomplish that. crbug.com/383072 |
| 115 typedef WillBeHeapLinkedHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > M
ediaElementSequence; |
| 116 MediaElementSequence m_mediaElements; |
110 bool m_paused; | 117 bool m_paused; |
111 double m_defaultPlaybackRate; | 118 double m_defaultPlaybackRate; |
112 double m_volume; | 119 double m_volume; |
113 mutable double m_position; | 120 mutable double m_position; |
114 bool m_muted; | 121 bool m_muted; |
115 ReadyState m_readyState; | 122 ReadyState m_readyState; |
116 PlaybackState m_playbackState; | 123 PlaybackState m_playbackState; |
117 OwnPtr<GenericEventQueue> m_pendingEventsQueue; | 124 OwnPtr<GenericEventQueue> m_pendingEventsQueue; |
118 mutable Timer<MediaController> m_clearPositionTimer; | 125 mutable Timer<MediaController> m_clearPositionTimer; |
119 OwnPtr<Clock> m_clock; | 126 OwnPtr<Clock> m_clock; |
120 ExecutionContext* m_executionContext; | 127 ExecutionContext* m_executionContext; |
121 Timer<MediaController> m_timeupdateTimer; | 128 Timer<MediaController> m_timeupdateTimer; |
122 double m_previousTimeupdateTime; | 129 double m_previousTimeupdateTime; |
123 }; | 130 }; |
124 | 131 |
125 } // namespace WebCore | 132 } // namespace WebCore |
126 | 133 |
127 #endif | 134 #endif |
OLD | NEW |