 Chromium Code Reviews
 Chromium Code Reviews Issue 1576283003:
  Have HTMLMediaElement::play() return a Promise.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1576283003:
  Have HTMLMediaElement::play() return a Promise.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: third_party/WebKit/Source/core/html/HTMLMediaElement.h | 
| diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.h b/third_party/WebKit/Source/core/html/HTMLMediaElement.h | 
| index e6741a883068274ca5de8f7ed99653c217296099..a0a2cf8932e98b7c3f6054c0660b8865ef981485 100644 | 
| --- a/third_party/WebKit/Source/core/html/HTMLMediaElement.h | 
| +++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.h | 
| @@ -26,8 +26,10 @@ | 
| #ifndef HTMLMediaElement_h | 
| #define HTMLMediaElement_h | 
| +#include "bindings/core/v8/ScriptPromise.h" | 
| #include "core/CoreExport.h" | 
| #include "core/dom/ActiveDOMObject.h" | 
| +#include "core/dom/ExceptionCode.h" | 
| #include "core/events/GenericEventQueue.h" | 
| #include "core/html/AutoplayExperimentHelper.h" | 
| #include "core/html/HTMLElement.h" | 
| @@ -52,6 +54,7 @@ class KURL; | 
| class MediaControls; | 
| class MediaError; | 
| class HTMLMediaSource; | 
| +class ScriptState; | 
| class TextTrackContainer; | 
| class TextTrackList; | 
| class TimeRanges; | 
| @@ -136,7 +139,8 @@ public: | 
| bool shouldAutoplay(const RecordMetricsBehavior = RecordMetricsBehavior::DoNotRecord); | 
| bool loop() const; | 
| void setLoop(bool); | 
| - void play(); | 
| + ScriptPromise playForBindings(ScriptState*); | 
| + Nullable<ExceptionCode> play(); | 
| void pause(); | 
| void requestRemotePlayback(); | 
| void requestRemotePlaybackControl(); | 
| @@ -445,6 +449,16 @@ private: | 
| // TODO(liberato): remove once autoplay gesture override experiment concludes. | 
| void triggerAutoplayViewportCheckForTesting(); | 
| + void scheduleResolvePlayPromises(); | 
| + void scheduleRejectPlayPromises(ExceptionCode); | 
| + void scheduleNotifyPlaying(); | 
| + | 
| + void resolvePlayPromises(); | 
| + // TODO(mlamouri): this is used for cancellabel tasks because we can't pass | 
| 
philipj_slow
2016/02/25 14:06:48
Typo. Amusing that we have "cancelable" in DOM but
 
mlamouri (slow - plz ping)
2016/02/25 14:40:06
:)
 | 
| + // parameters. | 
| + void rejectPlayPromises(); | 
| + void rejectPlayPromises(ExceptionCode, const String&); | 
| + | 
| UnthrottledTimer<HTMLMediaElement> m_loadTimer; | 
| UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; | 
| UnthrottledTimer<HTMLMediaElement> m_playbackProgressTimer; | 
| @@ -553,6 +567,11 @@ private: | 
| OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 
| + PersistentHeapVectorWillBeHeapVector<Member<ScriptPromiseResolver>> m_playResolvers; | 
| + OwnPtr<CancellableTaskFactory> m_playPromiseResolveTask; | 
| + OwnPtr<CancellableTaskFactory> m_playPromiseRejectTask; | 
| + ExceptionCode m_playPromiseErrorCode; | 
| + | 
| // This is a weak reference, since m_audioSourceNode holds a reference to us. | 
| // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan where strong cycles are not a problem. | 
| GC_PLUGIN_IGNORE("http://crbug.com/404577") |