Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / MediaController.h
index 484b37f..8d1b6c4 100644 (file)
 #ifndef MediaController_h
 #define MediaController_h
 
-#include "bindings/v8/ScriptWrappable.h"
-#include "core/events/Event.h"
 #include "core/events/EventTarget.h"
 #include "core/html/HTMLMediaElement.h"
-#include "core/html/MediaControllerInterface.h"
-#include "platform/Timer.h"
+#include "wtf/LinkedHashSet.h"
 #include "wtf/PassRefPtr.h"
 #include "wtf/RefCounted.h"
-#include "wtf/Vector.h"
 
-namespace WebCore {
+namespace blink {
 
 class Clock;
-class Event;
 class ExceptionState;
 class ExecutionContext;
+class GenericEventQueue;
 
-class MediaController FINAL : public RefCounted<MediaController>, public ScriptWrappable, public MediaControllerInterface, public EventTargetWithInlineData {
+class MediaController FINAL : public RefCountedWillBeRefCountedGarbageCollected<MediaController>, public EventTargetWithInlineData {
     REFCOUNTED_EVENT_TARGET(MediaController);
+    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaController);
 public:
-    static PassRefPtr<MediaController> create(ExecutionContext*);
+    static PassRefPtrWillBeRawPtr<MediaController> create(ExecutionContext*);
     virtual ~MediaController();
 
     void addMediaElement(HTMLMediaElement*);
     void removeMediaElement(HTMLMediaElement*);
-    bool containsMediaElement(HTMLMediaElement*) const;
 
-    PassRefPtr<TimeRanges> buffered() const;
-    PassRefPtr<TimeRanges> seekable() const;
-    PassRefPtr<TimeRanges> played();
+    PassRefPtrWillBeRawPtr<TimeRanges> buffered() const;
+    PassRefPtrWillBeRawPtr<TimeRanges> seekable() const;
+    PassRefPtrWillBeRawPtr<TimeRanges> played();
 
-    virtual double duration() const OVERRIDE;
-    virtual double currentTime() const OVERRIDE;
-    virtual void setCurrentTime(double, ExceptionState&) OVERRIDE;
+    double duration() const;
+    double currentTime() const;
+    void setCurrentTime(double, ExceptionState&);
 
     bool paused() const { return m_paused; }
     void play();
@@ -72,11 +68,11 @@ public:
     double playbackRate() const;
     void setPlaybackRate(double);
 
-    virtual double volume() const OVERRIDE { return m_volume; }
-    virtual void setVolume(double, ExceptionState&) OVERRIDE;
+    double volume() const { return m_volume; }
+    void setVolume(double, ExceptionState&);
 
-    virtual bool muted() const OVERRIDE { return m_muted; }
-    virtual void setMuted(bool) OVERRIDE;
+    bool muted() const { return m_muted; }
+    void setMuted(bool);
 
     typedef HTMLMediaElement::ReadyState ReadyState;
     ReadyState readyState() const { return m_readyState; }
@@ -84,12 +80,14 @@ public:
     enum PlaybackState { WAITING, PLAYING, ENDED };
     const AtomicString& playbackState() const;
 
-    virtual bool hasAudio() const OVERRIDE;
-
     bool isRestrained() const;
     bool isBlocked() const;
 
-    void clearExecutionContext() { m_executionContext = 0; }
+#if !ENABLE(OILPAN)
+    void clearExecutionContext() { m_executionContext = nullptr; }
+#endif
+
+    virtual void trace(Visitor*) OVERRIDE;
 
 private:
     MediaController(ExecutionContext*);
@@ -99,7 +97,6 @@ private:
     void updateMediaElements();
     void bringElementUpToSpeed(HTMLMediaElement*);
     void scheduleEvent(const AtomicString& eventName);
-    void asyncEventTimerFired(Timer<MediaController>*);
     void clearPositionTimerFired(Timer<MediaController>*);
     bool hasEnded() const;
     void scheduleTimeupdateEvent();
@@ -112,7 +109,12 @@ private:
 
     friend class HTMLMediaElement;
     friend class MediaControllerEventListener;
-    Vector<HTMLMediaElement*> m_mediaElements;
+    // FIXME: A MediaController should ideally keep an otherwise
+    // unreferenced slaved media element alive. When Oilpan is
+    // enabled by default, consider making the hash set references
+    // strong to accomplish that. crbug.com/383072
+    typedef WillBeHeapLinkedHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > MediaElementSequence;
+    MediaElementSequence m_mediaElements;
     bool m_paused;
     double m_defaultPlaybackRate;
     double m_volume;
@@ -120,15 +122,14 @@ private:
     bool m_muted;
     ReadyState m_readyState;
     PlaybackState m_playbackState;
-    Vector<RefPtr<Event> > m_pendingEvents;
-    Timer<MediaController> m_asyncEventTimer;
+    OwnPtrWillBeMember<GenericEventQueue> m_pendingEventsQueue;
     mutable Timer<MediaController> m_clearPositionTimer;
     OwnPtr<Clock> m_clock;
-    ExecutionContext* m_executionContext;
+    RawPtrWillBeWeakMember<ExecutionContext> m_executionContext;
     Timer<MediaController> m_timeupdateTimer;
     double m_previousTimeupdateTime;
 };
 
-} // namespace WebCore
+} // namespace blink
 
 #endif