| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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/Event.h" | |
| 31 #include "core/events/EventTarget.h" | 30 #include "core/events/EventTarget.h" |
| 32 #include "core/html/HTMLMediaElement.h" | 31 #include "core/html/HTMLMediaElement.h" |
| 33 #include "platform/Timer.h" | |
| 34 #include "wtf/PassRefPtr.h" | 32 #include "wtf/PassRefPtr.h" |
| 35 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
| 36 #include "wtf/Vector.h" | 34 #include "wtf/Vector.h" |
| 37 | 35 |
| 38 namespace WebCore { | 36 namespace WebCore { |
| 39 | 37 |
| 40 class Clock; | 38 class Clock; |
| 41 class Event; | |
| 42 class ExceptionState; | 39 class ExceptionState; |
| 43 class ExecutionContext; | 40 class ExecutionContext; |
| 41 class GenericEventQueue; |
| 44 | 42 |
| 45 class MediaController FINAL : public RefCounted<MediaController>, public ScriptW
rappable, public EventTargetWithInlineData { | 43 class MediaController FINAL : public RefCounted<MediaController>, public ScriptW
rappable, public EventTargetWithInlineData { |
| 46 REFCOUNTED_EVENT_TARGET(MediaController); | 44 REFCOUNTED_EVENT_TARGET(MediaController); |
| 47 public: | 45 public: |
| 48 static PassRefPtr<MediaController> create(ExecutionContext*); | 46 static PassRefPtr<MediaController> create(ExecutionContext*); |
| 49 virtual ~MediaController(); | 47 virtual ~MediaController(); |
| 50 | 48 |
| 51 void addMediaElement(HTMLMediaElement*); | 49 void addMediaElement(HTMLMediaElement*); |
| 52 void removeMediaElement(HTMLMediaElement*); | 50 void removeMediaElement(HTMLMediaElement*); |
| 53 | 51 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void clearExecutionContext() { m_executionContext = 0; } | 86 void clearExecutionContext() { m_executionContext = 0; } |
| 89 | 87 |
| 90 private: | 88 private: |
| 91 MediaController(ExecutionContext*); | 89 MediaController(ExecutionContext*); |
| 92 void reportControllerState(); | 90 void reportControllerState(); |
| 93 void updateReadyState(); | 91 void updateReadyState(); |
| 94 void updatePlaybackState(); | 92 void updatePlaybackState(); |
| 95 void updateMediaElements(); | 93 void updateMediaElements(); |
| 96 void bringElementUpToSpeed(HTMLMediaElement*); | 94 void bringElementUpToSpeed(HTMLMediaElement*); |
| 97 void scheduleEvent(const AtomicString& eventName); | 95 void scheduleEvent(const AtomicString& eventName); |
| 98 void asyncEventTimerFired(Timer<MediaController>*); | |
| 99 void clearPositionTimerFired(Timer<MediaController>*); | 96 void clearPositionTimerFired(Timer<MediaController>*); |
| 100 bool hasEnded() const; | 97 bool hasEnded() const; |
| 101 void scheduleTimeupdateEvent(); | 98 void scheduleTimeupdateEvent(); |
| 102 void timeupdateTimerFired(Timer<MediaController>*); | 99 void timeupdateTimerFired(Timer<MediaController>*); |
| 103 void startTimeupdateTimer(); | 100 void startTimeupdateTimer(); |
| 104 | 101 |
| 105 // EventTarget | 102 // EventTarget |
| 106 virtual const AtomicString& interfaceName() const OVERRIDE; | 103 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 107 virtual ExecutionContext* executionContext() const OVERRIDE { return m_execu
tionContext; } | 104 virtual ExecutionContext* executionContext() const OVERRIDE { return m_execu
tionContext; } |
| 108 | 105 |
| 109 friend class HTMLMediaElement; | 106 friend class HTMLMediaElement; |
| 110 friend class MediaControllerEventListener; | 107 friend class MediaControllerEventListener; |
| 111 Vector<HTMLMediaElement*> m_mediaElements; | 108 Vector<HTMLMediaElement*> m_mediaElements; |
| 112 bool m_paused; | 109 bool m_paused; |
| 113 double m_defaultPlaybackRate; | 110 double m_defaultPlaybackRate; |
| 114 double m_volume; | 111 double m_volume; |
| 115 mutable double m_position; | 112 mutable double m_position; |
| 116 bool m_muted; | 113 bool m_muted; |
| 117 ReadyState m_readyState; | 114 ReadyState m_readyState; |
| 118 PlaybackState m_playbackState; | 115 PlaybackState m_playbackState; |
| 119 WillBePersistentHeapVector<RefPtrWillBeMember<Event> > m_pendingEvents; | 116 OwnPtr<GenericEventQueue> m_pendingEventsQueue; |
| 120 Timer<MediaController> m_asyncEventTimer; | |
| 121 mutable Timer<MediaController> m_clearPositionTimer; | 117 mutable Timer<MediaController> m_clearPositionTimer; |
| 122 OwnPtr<Clock> m_clock; | 118 OwnPtr<Clock> m_clock; |
| 123 ExecutionContext* m_executionContext; | 119 ExecutionContext* m_executionContext; |
| 124 Timer<MediaController> m_timeupdateTimer; | 120 Timer<MediaController> m_timeupdateTimer; |
| 125 double m_previousTimeupdateTime; | 121 double m_previousTimeupdateTime; |
| 126 }; | 122 }; |
| 127 | 123 |
| 128 } // namespace WebCore | 124 } // namespace WebCore |
| 129 | 125 |
| 130 #endif | 126 #endif |
| OLD | NEW |