Title: [207007] trunk/Source/WebCore
Revision
207007
Author
da...@apple.com
Date
2016-10-10 10:25:48 -0700 (Mon, 10 Oct 2016)

Log Message

Move media source from legacy to new DOM exceptions
https://bugs.webkit.org/show_bug.cgi?id=163201

Reviewed by Chris Dumez.

* Modules/mediasource/MediaSource.cpp: Removed unneeded includes.
(WebCore::MediaSource::create): Use auto.
(WebCore::MediaSource::MediaSource): Initialize m_mediaElement in class definition.
(WebCore::MediaSource::setLiveSeekableRange): Use ExceptionOr.
(WebCore::MediaSource::clearLiveSeekableRange): Ditto.
(WebCore::MediaSource::setDuration): Ditto.
(WebCore::MediaSource::setDurationInternal): Ditto.
(WebCore::MediaSource::endOfStream): Ditto.
(WebCore::MediaSource::streamEndedWithError): Use bufferedInternal.
(WebCore::MediaSource::addSourceBuffer): Use ExceptionOr.
(WebCore::MediaSource::removeSourceBuffer): Ditto.
(WebCore::MediaSource::detachFromElement): Use removeSourceBuffer
without IGNORE_EXCEPTION since that is now the default behavior.
(WebCore::MediaSource::activeRanges): Use bufferedInternal.
(WebCore::MediaSource::createSourceBufferPrivate): Use ExceptionOr.

* Modules/mediasource/MediaSource.h: Removed unneeded includes.
Made more things private and also private rather than protected.

* Modules/mediasource/MediaSource.idl: Use non-legacy exceptions.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::buffered): Use ExceptionOr.
(WebCore::SourceBuffer::setTimestampOffset): Ditto.
(WebCore::SourceBuffer::setAppendWindowStart): Ditto.
(WebCore::SourceBuffer::setAppendWindowEnd): Ditto.
(WebCore::SourceBuffer::appendBuffer): Ditto.
(WebCore::SourceBuffer::abort): Ditto.
(WebCore::SourceBuffer::remove): Ditto.
(WebCore::SourceBuffer::appendBufferInternal): Ditto.
(WebCore::SourceBuffer::setMode): Ditto.

* Modules/mediasource/SourceBuffer.h: Removed unneeded includes.
Updated for above changes. Made more things private.

* Modules/mediasource/SourceBuffer.idl: Use non-legacy exceptions.

* platform/graphics/gstreamer/WebKitMediaSourceGStreamer.h:
Added now-needed include of MediaSourcePrivate.h.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207006 => 207007)


--- trunk/Source/WebCore/ChangeLog	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/ChangeLog	2016-10-10 17:25:48 UTC (rev 207007)
@@ -1,3 +1,50 @@
+2016-10-10  Darin Adler  <da...@apple.com>
+
+        Move media source from legacy to new DOM exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=163201
+
+        Reviewed by Chris Dumez.
+
+        * Modules/mediasource/MediaSource.cpp: Removed unneeded includes.
+        (WebCore::MediaSource::create): Use auto.
+        (WebCore::MediaSource::MediaSource): Initialize m_mediaElement in class definition.
+        (WebCore::MediaSource::setLiveSeekableRange): Use ExceptionOr.
+        (WebCore::MediaSource::clearLiveSeekableRange): Ditto.
+        (WebCore::MediaSource::setDuration): Ditto.
+        (WebCore::MediaSource::setDurationInternal): Ditto.
+        (WebCore::MediaSource::endOfStream): Ditto.
+        (WebCore::MediaSource::streamEndedWithError): Use bufferedInternal.
+        (WebCore::MediaSource::addSourceBuffer): Use ExceptionOr.
+        (WebCore::MediaSource::removeSourceBuffer): Ditto.
+        (WebCore::MediaSource::detachFromElement): Use removeSourceBuffer
+        without IGNORE_EXCEPTION since that is now the default behavior.
+        (WebCore::MediaSource::activeRanges): Use bufferedInternal.
+        (WebCore::MediaSource::createSourceBufferPrivate): Use ExceptionOr.
+
+        * Modules/mediasource/MediaSource.h: Removed unneeded includes.
+        Made more things private and also private rather than protected.
+
+        * Modules/mediasource/MediaSource.idl: Use non-legacy exceptions.
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::buffered): Use ExceptionOr.
+        (WebCore::SourceBuffer::setTimestampOffset): Ditto.
+        (WebCore::SourceBuffer::setAppendWindowStart): Ditto.
+        (WebCore::SourceBuffer::setAppendWindowEnd): Ditto.
+        (WebCore::SourceBuffer::appendBuffer): Ditto.
+        (WebCore::SourceBuffer::abort): Ditto.
+        (WebCore::SourceBuffer::remove): Ditto.
+        (WebCore::SourceBuffer::appendBufferInternal): Ditto.
+        (WebCore::SourceBuffer::setMode): Ditto.
+
+        * Modules/mediasource/SourceBuffer.h: Removed unneeded includes.
+        Updated for above changes. Made more things private.
+
+        * Modules/mediasource/SourceBuffer.idl: Use non-legacy exceptions.
+
+        * platform/graphics/gstreamer/WebKitMediaSourceGStreamer.h:
+        Added now-needed include of MediaSourcePrivate.h.
+
 2016-10-10  Jer Noble  <jer.no...@apple.com>
 
         Address flaky airplay-* LayouTests

Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp (207006 => 207007)


--- trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp	2016-10-10 17:25:48 UTC (rev 207007)
@@ -34,33 +34,24 @@
 
 #if ENABLE(MEDIA_SOURCE)
 
-#include "AudioTrack.h"
 #include "AudioTrackList.h"
 #include "ContentType.h"
 #include "Event.h"
 #include "EventNames.h"
-#include "ExceptionCode.h"
-#include "ExceptionCodePlaceholder.h"
-#include "GenericEventQueue.h"
 #include "HTMLMediaElement.h"
 #include "Logging.h"
-#include "MIMETypeRegistry.h"
-#include "MediaError.h"
-#include "MediaPlayer.h"
+#include "MediaSourcePrivate.h"
 #include "MediaSourceRegistry.h"
+#include "SourceBuffer.h"
+#include "SourceBufferList.h"
 #include "SourceBufferPrivate.h"
-#include "TextTrack.h"
 #include "TextTrackList.h"
 #include "TimeRanges.h"
-#include "VideoTrack.h"
 #include "VideoTrackList.h"
-#include <runtime/Uint8Array.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-URLRegistry* MediaSource::s_registry = 0;
+URLRegistry* MediaSource::s_registry;
 
 void MediaSource::setRegistry(URLRegistry* registry)
 {
@@ -70,7 +61,7 @@
 
 Ref<MediaSource> MediaSource::create(ScriptExecutionContext& context)
 {
-    Ref<MediaSource> mediaSource(adoptRef(*new MediaSource(context)));
+    auto mediaSource = adoptRef(*new MediaSource(context));
     mediaSource->suspendIfNeeded();
     return mediaSource;
 }
@@ -77,7 +68,6 @@
 
 MediaSource::MediaSource(ScriptExecutionContext& context)
     : ActiveDOMObject(&context)
-    , m_mediaElement(nullptr)
     , m_duration(MediaTime::invalidTime())
     , m_pendingSeekTime(MediaTime::invalidTime())
     , m_readyState(closedKeyword())
@@ -295,45 +285,41 @@
         return TimeRanges::create({MediaTime::zeroTime(), buffered->maximumBufferedTime()});
     }
 
-
     // ↳ Otherwise:
     // Return a single range with a start time of 0 and an end time equal to duration.
     return TimeRanges::create({MediaTime::zeroTime(), m_duration});
 }
 
-void MediaSource::setLiveSeekableRange(double start, double end, ExceptionCode& ec)
+ExceptionOr<void> MediaSource::setLiveSeekableRange(double start, double end)
 {
     // W3C Editor's Draft 16 September 2016
     // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#dom-mediasource-setliveseekablerange
 
     // If the readyState attribute is not "open" then throw an InvalidStateError exception and abort these steps.
-    if (!isOpen()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (!isOpen())
+        return Exception { INVALID_STATE_ERR };
 
     // If start is negative or greater than end, then throw a TypeError exception and abort these steps.
-    if (start < 0 || start > end) {
-        ec = TypeError;
-        return;
-    }
+    if (start < 0 || start > end)
+        return Exception { TypeError };
 
     // Set live seekable range to be a new normalized TimeRanges object containing a single range
     // whose start position is start and end position is end.
     m_liveSeekable = std::make_unique<PlatformTimeRanges>(MediaTime::createWithDouble(start), MediaTime::createWithDouble(end));
+
+    return { };
 }
 
-void MediaSource::clearLiveSeekableRange(ExceptionCode& ec)
+ExceptionOr<void> MediaSource::clearLiveSeekableRange()
 {
     // W3C Editor's Draft 16 September 2016
     // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#dom-mediasource-clearliveseekablerange
 
     // If the readyState attribute is not "open" then throw an InvalidStateError exception and abort these steps.
-    if (!isOpen()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (!isOpen())
+        return Exception { INVALID_STATE_ERR };
     m_liveSeekable = nullptr;
+    return { };
 }
 
 const MediaTime& MediaSource::currentTimeFudgeFactor()
@@ -461,7 +447,7 @@
     // 4. Abort these steps.
 }
 
-void MediaSource::setDuration(double duration, ExceptionCode& ec)
+ExceptionOr<void> MediaSource::setDuration(double duration)
 {
     // 2.1 Attributes - Duration
     // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#attributes
@@ -468,33 +454,25 @@
 
     // On setting, run the following steps:
     // 1. If the value being set is negative or NaN then throw an INVALID_ACCESS_ERR exception and abort these steps.
-    if (duration < 0.0 || std::isnan(duration)) {
-        ec = INVALID_ACCESS_ERR;
-        return;
-    }
+    if (duration < 0.0 || std::isnan(duration))
+        return Exception { INVALID_ACCESS_ERR };
 
     // 2. If the readyState attribute is not "open" then throw an INVALID_STATE_ERR exception and abort these steps.
-    if (!isOpen()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (!isOpen())
+        return Exception { INVALID_STATE_ERR };
 
     // 3. If the updating attribute equals true on any SourceBuffer in sourceBuffers, then throw an INVALID_STATE_ERR
     // exception and abort these steps.
     for (auto& sourceBuffer : *m_sourceBuffers) {
-        if (sourceBuffer->updating()) {
-            ec = INVALID_STATE_ERR;
-            return;
-        }
+        if (sourceBuffer->updating())
+            return Exception { INVALID_STATE_ERR };
     }
 
     // 4. Run the duration change algorithm with new duration set to the value being assigned to this attribute.
-    auto result = setDurationInternal(MediaTime::createWithDouble(duration));
-    if (result)
-        ec = result.value();
+    return setDurationInternal(MediaTime::createWithDouble(duration));
 }
 
-Optional<ExceptionCode> MediaSource::setDurationInternal(const MediaTime& duration)
+ExceptionOr<void> MediaSource::setDurationInternal(const MediaTime& duration)
 {
     // 2.4.6 Duration Change
     // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#duration-change-algorithm
@@ -514,10 +492,10 @@
     MediaTime highestEndTime;
     for (auto& sourceBuffer : *m_sourceBuffers) {
         highestPresentationTimestamp = std::max(highestPresentationTimestamp, sourceBuffer->highestPresentationTimestamp());
-        highestEndTime = std::max(highestEndTime, sourceBuffer->buffered()->ranges().maximumBufferedTime());
+        highestEndTime = std::max(highestEndTime, sourceBuffer->bufferedInternal().ranges().maximumBufferedTime());
     }
     if (highestPresentationTimestamp.isValid() && newDuration < highestPresentationTimestamp)
-        return INVALID_STATE_ERR;
+        return Exception { INVALID_STATE_ERR };
 
     // 4. If new duration is less than highest end time, then
     // 4.1. Update new duration to equal highest end time.
@@ -549,25 +527,23 @@
     onReadyStateChange(oldState, state);
 }
 
-void MediaSource::endOfStream(Optional<EndOfStreamError> error, ExceptionCode& ec)
+ExceptionOr<void> MediaSource::endOfStream(Optional<EndOfStreamError> error)
 {
     // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-MediaSource-endOfStream-void-EndOfStreamError-error
     // 1. If the readyState attribute is not in the "open" state then throw an
     // INVALID_STATE_ERR exception and abort these steps.
-    if (!isOpen()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (!isOpen())
+        return Exception { INVALID_STATE_ERR };
 
     // 2. If the updating attribute equals true on any SourceBuffer in sourceBuffers, then throw an
     // INVALID_STATE_ERR exception and abort these steps.
-    if (std::any_of(m_sourceBuffers->begin(), m_sourceBuffers->end(), [](auto& sourceBuffer) { return sourceBuffer->updating(); })) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (std::any_of(m_sourceBuffers->begin(), m_sourceBuffers->end(), [](auto& sourceBuffer) { return sourceBuffer->updating(); }))
+        return Exception { INVALID_STATE_ERR };
 
     // 3. Run the end of stream algorithm with the error parameter set to error.
     streamEndedWithError(error);
+
+    return { };
 }
 
 void MediaSource::streamEndedWithError(Optional<EndOfStreamError> error)
@@ -587,8 +563,8 @@
         // the buffered attribute across all SourceBuffer objects in sourceBuffers.
         MediaTime maxEndTime;
         for (auto& sourceBuffer : *m_sourceBuffers) {
-            if (auto length = sourceBuffer->buffered()->length())
-                maxEndTime = std::max(sourceBuffer->buffered()->ranges().end(length - 1), maxEndTime);
+            if (auto length = sourceBuffer->bufferedInternal().length())
+                maxEndTime = std::max(sourceBuffer->bufferedInternal().ranges().end(length - 1), maxEndTime);
         }
         setDurationInternal(maxEndTime);
 
@@ -629,7 +605,7 @@
     }
 }
 
-SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec)
+ExceptionOr<SourceBuffer*> MediaSource::addSourceBuffer(const String& type)
 {
     LOG(MediaSource, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this);
 
@@ -637,37 +613,30 @@
     // When this method is invoked, the user agent must run the following steps:
 
     // 1. If type is an empty string then throw a TypeError exception and abort these steps.
-    if (type.isEmpty()) {
-        ec = TypeError;
-        return nullptr;
-    }
+    if (type.isEmpty())
+        return Exception { TypeError };
 
     // 2. If type contains a MIME type that is not supported ..., then throw a
     // NOT_SUPPORTED_ERR exception and abort these steps.
-    if (!isTypeSupported(type)) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
+    if (!isTypeSupported(type))
+        return Exception { NOT_SUPPORTED_ERR };
 
     // 4. If the readyState attribute is not in the "open" state then throw an
     // INVALID_STATE_ERR exception and abort these steps.
-    if (!isOpen()) {
-        ec = INVALID_STATE_ERR;
-        return nullptr;
-    }
+    if (!isOpen())
+        return Exception { INVALID_STATE_ERR };
 
     // 5. Create a new SourceBuffer object and associated resources.
     ContentType contentType(type);
-    RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec);
+    auto sourceBufferPrivate = createSourceBufferPrivate(contentType);
 
-    if (!sourceBufferPrivate) {
-        ASSERT(ec == NOT_SUPPORTED_ERR || ec == QUOTA_EXCEEDED_ERR);
+    if (sourceBufferPrivate.hasException()) {
         // 2. If type contains a MIME type that is not supported ..., then throw a NOT_SUPPORTED_ERR exception and abort these steps.
         // 3. If the user agent can't handle any more SourceBuffer objects then throw a QUOTA_EXCEEDED_ERR exception and abort these steps
-        return nullptr;
+        return sourceBufferPrivate.releaseException();
     }
 
-    Ref<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.releaseNonNull(), this);
+    auto buffer = SourceBuffer::create(sourceBufferPrivate.releaseReturnValue(), this);
 
     // 6. Set the generate timestamps flag on the new object to the value in the "Generate Timestamps Flag"
     // column of the byte stream format registry [MSE-REGISTRY] entry that is associated with type.
@@ -680,7 +649,7 @@
     // ↳ Set the mode attribute on the new object to "sequence".
     // Otherwise:
     // ↳ Set the mode attribute on the new object to "segments".
-    buffer->setMode(shouldGenerateTimestamps ? SourceBuffer::AppendMode::Sequence : SourceBuffer::AppendMode::Segments, IGNORE_EXCEPTION);
+    buffer->setMode(shouldGenerateTimestamps ? SourceBuffer::AppendMode::Sequence : SourceBuffer::AppendMode::Segments);
 
     SourceBuffer* result = buffer.ptr();
 
@@ -689,10 +658,10 @@
     regenerateActiveSourceBuffers();
 
     // 9. Return the new object to the caller.
-    return result;
+    return WTFMove(result);
 }
 
-void MediaSource::removeSourceBuffer(SourceBuffer& buffer, ExceptionCode& ec)
+ExceptionOr<void> MediaSource::removeSourceBuffer(SourceBuffer& buffer)
 {
     LOG(MediaSource, "MediaSource::removeSourceBuffer() %p", this);
     Ref<SourceBuffer> protect(buffer);
@@ -699,10 +668,8 @@
 
     // 2. If sourceBuffer specifies an object that is not in sourceBuffers then
     // throw a NOT_FOUND_ERR exception and abort these steps.
-    if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) {
-        ec = NOT_FOUND_ERR;
-        return;
-    }
+    if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer))
+        return Exception { NOT_FOUND_ERR };
 
     // 3. If the sourceBuffer.updating attribute equals true, then run the following steps: ...
     buffer.abortIfUpdating();
@@ -820,23 +787,24 @@
             // cancelable, and that uses the TrackEvent interface, at the SourceBuffer textTracks list.
             textTracks->remove(track);
         }
-        
+
         // 9.4 If the removed enabled text track flag equals true, then queue a task to fire a simple event
         // named change at the HTMLMediaElement textTracks list.
         if (removedEnabledTextTrack)
             mediaElement()->textTracks().scheduleChangeEvent();
     }
-    
-    
+
     // 10. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer from activeSourceBuffers ...
     m_activeSourceBuffers->remove(buffer);
-    
+
     // 11. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event
     // on that object.
     m_sourceBuffers->remove(buffer);
-    
+
     // 12. Destroy all resources for sourceBuffer.
     buffer.removedFromMediaSource();
+
+    return { };
 }
 
 bool MediaSource::isTypeSupported(const String& type)
@@ -905,12 +873,12 @@
     // 3. Remove all the SourceBuffer objects from activeSourceBuffers.
     // 4. Queue a task to fire a simple event named removesourcebuffer at activeSourceBuffers.
     while (m_activeSourceBuffers->length())
-        removeSourceBuffer(*m_activeSourceBuffers->item(0), IGNORE_EXCEPTION);
+        removeSourceBuffer(*m_activeSourceBuffers->item(0));
 
     // 5. Remove all the SourceBuffer objects from sourceBuffers.
     // 6. Queue a task to fire a simple event named removesourcebuffer at sourceBuffers.
     while (m_sourceBuffers->length())
-        removeSourceBuffer(*m_sourceBuffers->item(0), IGNORE_EXCEPTION);
+        removeSourceBuffer(*m_sourceBuffers->item(0));
 
     m_private = nullptr;
     m_mediaElement = nullptr;
@@ -988,34 +956,31 @@
 {
     Vector<PlatformTimeRanges> activeRanges;
     for (auto& sourceBuffer : *m_activeSourceBuffers)
-        activeRanges.append(sourceBuffer->buffered()->ranges());
+        activeRanges.append(sourceBuffer->bufferedInternal().ranges());
     return activeRanges;
 }
 
-RefPtr<SourceBufferPrivate> MediaSource::createSourceBufferPrivate(const ContentType& type, ExceptionCode& ec)
+ExceptionOr<Ref<SourceBufferPrivate>> MediaSource::createSourceBufferPrivate(const ContentType& type)
 {
     RefPtr<SourceBufferPrivate> sourceBufferPrivate;
     switch (m_private->addSourceBuffer(type, sourceBufferPrivate)) {
-    case MediaSourcePrivate::Ok: {
-        return sourceBufferPrivate;
-    }
+    case MediaSourcePrivate::Ok:
+        return sourceBufferPrivate.releaseNonNull();
     case MediaSourcePrivate::NotSupported:
         // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
         // Step 2: If type contains a MIME type ... that is not supported with the types
         // specified for the other SourceBuffer objects in sourceBuffers, then throw
         // a NOT_SUPPORTED_ERR exception and abort these steps.
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
+        return Exception { NOT_SUPPORTED_ERR };
     case MediaSourcePrivate::ReachedIdLimit:
         // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
         // Step 3: If the user agent can't handle any more SourceBuffer objects then throw
         // a QUOTA_EXCEEDED_ERR exception and abort these steps.
-        ec = QUOTA_EXCEEDED_ERR;
-        return nullptr;
+        return Exception { QUOTA_EXCEEDED_ERR };
     }
 
     ASSERT_NOT_REACHED();
-    return nullptr;
+    return Exception { QUOTA_EXCEEDED_ERR };
 }
 
 void MediaSource::scheduleEvent(const AtomicString& eventName)

Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.h (207006 => 207007)


--- trunk/Source/WebCore/Modules/mediasource/MediaSource.h	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.h	2016-10-10 17:25:48 UTC (rev 207007)
@@ -34,29 +34,25 @@
 
 #include "ActiveDOMObject.h"
 #include "EventTarget.h"
+#include "ExceptionOr.h"
 #include "GenericEventQueue.h"
-#include "MediaSourcePrivate.h"
 #include "MediaSourcePrivateClient.h"
-#include "ScriptWrappable.h"
-#include "SourceBuffer.h"
-#include "SourceBufferList.h"
 #include "URLRegistry.h"
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
 
 namespace WebCore {
 
-class GenericEventQueue;
+class ContentType;
+class HTMLMediaElement;
+class SourceBuffer;
+class SourceBufferList;
+class SourceBufferPrivate;
+class TimeRanges;
 
-class MediaSource : public MediaSourcePrivateClient, public ActiveDOMObject, public EventTargetWithInlineData, public URLRegistrable {
+class MediaSource final : public MediaSourcePrivateClient, public ActiveDOMObject, public EventTargetWithInlineData, public URLRegistrable {
 public:
     static void setRegistry(URLRegistry*);
-    static MediaSource* lookup(const String& url) { return s_registry ? static_cast<MediaSource*>(s_registry->lookup(url)) : 0; }
+    static MediaSource* lookup(const String& url) { return s_registry ? static_cast<MediaSource*>(s_registry->lookup(url)) : nullptr; }
 
-    static const AtomicString& openKeyword();
-    static const AtomicString& closedKeyword();
-    static const AtomicString& endedKeyword();
-
     static Ref<MediaSource> create(ScriptExecutionContext&);
     virtual ~MediaSource();
 
@@ -71,69 +67,66 @@
     enum class EndOfStreamError { Network, Decode };
     void streamEndedWithError(Optional<EndOfStreamError>);
 
-    // MediaSourcePrivateClient
-    void setPrivateAndOpen(Ref<MediaSourcePrivate>&&) override;
-    MediaTime duration() const override;
-    std::unique_ptr<PlatformTimeRanges> buffered() const override;
-    void seekToTime(const MediaTime&) override;
+    MediaTime duration() const final;
+    std::unique_ptr<PlatformTimeRanges> buffered() const final;
 
     bool attachToElement(HTMLMediaElement&);
     void detachFromElement(HTMLMediaElement&);
     void monitorSourceBuffers();
     bool isSeeking() const { return m_pendingSeekTime.isValid(); }
-    void completeSeek();
     Ref<TimeRanges> seekable();
-    void setLiveSeekableRange(double start, double end, ExceptionCode&);
-    void clearLiveSeekableRange(ExceptionCode&);
+    ExceptionOr<void> setLiveSeekableRange(double start, double end);
+    ExceptionOr<void> clearLiveSeekableRange();
 
-
-    void setDuration(double, ExceptionCode&);
-    Optional<ExceptionCode> setDurationInternal(const MediaTime&);
+    ExceptionOr<void> setDuration(double);
+    ExceptionOr<void> setDurationInternal(const MediaTime&);
     MediaTime currentTime() const;
     const AtomicString& readyState() const { return m_readyState; }
-    void setReadyState(const AtomicString&);
-    void endOfStream(Optional<EndOfStreamError>, ExceptionCode&);
+    ExceptionOr<void> endOfStream(Optional<EndOfStreamError>);
 
     HTMLMediaElement* mediaElement() const { return m_mediaElement; }
 
-    // MediaSource.idl methods
     SourceBufferList* sourceBuffers() { return m_sourceBuffers.get(); }
     SourceBufferList* activeSourceBuffers() { return m_activeSourceBuffers.get(); }
-    SourceBuffer* addSourceBuffer(const String& type, ExceptionCode&);
-    void removeSourceBuffer(SourceBuffer&, ExceptionCode&);
+    ExceptionOr<SourceBuffer*> addSourceBuffer(const String& type);
+    ExceptionOr<void> removeSourceBuffer(SourceBuffer&);
     static bool isTypeSupported(const String& type);
 
-    // EventTarget interface
     ScriptExecutionContext* scriptExecutionContext() const final;
-    void refEventTarget() final { ref(); }
-    void derefEventTarget() final { deref(); }
-    EventTargetInterface eventTargetInterface() const override;
 
-    // URLRegistrable interface
-    URLRegistry& registry() const override;
+    using RefCounted::ref;
+    using RefCounted::deref;
 
-    using RefCounted<MediaSourcePrivateClient>::ref;
-    using RefCounted<MediaSourcePrivateClient>::deref;
+    bool hasPendingActivity() const final;
 
-    // ActiveDOMObject API.
-    bool hasPendingActivity() const override;
-
     static const MediaTime& currentTimeFudgeFactor();
 
-protected:
+private:
     explicit MediaSource(ScriptExecutionContext&);
 
-    // ActiveDOMObject API.
-    void stop() override;
-    bool canSuspendForDocumentSuspension() const override;
-    const char* activeDOMObjectName() const override;
+    void stop() final;
+    bool canSuspendForDocumentSuspension() const final;
+    const char* activeDOMObjectName() const final;
 
+    void setPrivateAndOpen(Ref<MediaSourcePrivate>&&) final;
+    void seekToTime(const MediaTime&) final;
+
+    void refEventTarget() final { ref(); }
+    void derefEventTarget() final { deref(); }
+    EventTargetInterface eventTargetInterface() const final;
+
+    URLRegistry& registry() const final;
+
+    static const AtomicString& openKeyword();
+    static const AtomicString& closedKeyword();
+    static const AtomicString& endedKeyword();
+    void setReadyState(const AtomicString&);
     void onReadyStateChange(const AtomicString& oldState, const AtomicString& newState);
+
     Vector<PlatformTimeRanges> activeRanges() const;
 
-    RefPtr<SourceBufferPrivate> createSourceBufferPrivate(const ContentType&, ExceptionCode&);
+    ExceptionOr<Ref<SourceBufferPrivate>> createSourceBufferPrivate(const ContentType&);
     void scheduleEvent(const AtomicString& eventName);
-    GenericEventQueue& asyncEventQueue() { return m_asyncEventQueue; }
 
     bool hasBufferedTime(const MediaTime&);
     bool hasCurrentTime();
@@ -141,6 +134,8 @@
 
     void regenerateActiveSourceBuffers();
 
+    void completeSeek();
+
     static URLRegistry* s_registry;
 
     RefPtr<MediaSourcePrivate> m_private;
@@ -148,7 +143,7 @@
     RefPtr<SourceBufferList> m_activeSourceBuffers;
     mutable std::unique_ptr<PlatformTimeRanges> m_buffered;
     std::unique_ptr<PlatformTimeRanges> m_liveSeekable;
-    HTMLMediaElement* m_mediaElement;
+    HTMLMediaElement* m_mediaElement { nullptr };
     MediaTime m_duration;
     MediaTime m_pendingSeekTime;
     AtomicString m_readyState;

Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.idl (207006 => 207007)


--- trunk/Source/WebCore/Modules/mediasource/MediaSource.idl	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.idl	2016-10-10 17:25:48 UTC (rev 207007)
@@ -46,19 +46,19 @@
     // Subset of sourceBuffers that provide data for the selected/enabled tracks.
     readonly attribute SourceBufferList activeSourceBuffers;
 
-    [SetterMayThrowLegacyException] attribute unrestricted double duration;
+    [SetterMayThrowException] attribute unrestricted double duration;
 
-    [MayThrowLegacyException] SourceBuffer addSourceBuffer(DOMString type);
-    [MayThrowLegacyException] void removeSourceBuffer(SourceBuffer buffer);
+    [MayThrowException] SourceBuffer addSourceBuffer(DOMString type);
+    [MayThrowException] void removeSourceBuffer(SourceBuffer buffer);
 
     readonly attribute DOMString readyState;
     
-    [MayThrowLegacyException] void endOfStream(optional EndOfStreamError error);
+    [MayThrowException] void endOfStream(optional EndOfStreamError error);
 
     static boolean isTypeSupported (DOMString type);
 
-    [MayThrowLegacyException] void setLiveSeekableRange(double start, double end);
-    [MayThrowLegacyException] void clearLiveSeekableRange();
+    [MayThrowException] void setLiveSeekableRange(double start, double end);
+    [MayThrowException] void clearLiveSeekableRange();
 
     attribute EventHandler onsourceopen;
     attribute EventHandler onsourceended;

Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (207006 => 207007)


--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2016-10-10 17:25:48 UTC (rev 207007)
@@ -46,6 +46,7 @@
 #include "MediaSample.h"
 #include "MediaSource.h"
 #include "SampleMap.h"
+#include "SourceBufferList.h"
 #include "SourceBufferPrivate.h"
 #include "TextTrackList.h"
 #include "TimeRanges.h"
@@ -125,32 +126,25 @@
     m_private->setClient(nullptr);
 }
 
-RefPtr<TimeRanges> SourceBuffer::buffered(ExceptionCode& ec) const
+ExceptionOr<Ref<TimeRanges>> SourceBuffer::buffered() const
 {
     // Section 3.1 buffered attribute steps.
     // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#attributes-1
     // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw an
     //    INVALID_STATE_ERR exception and abort these steps.
-    if (isRemoved()) {
-        ec = INVALID_STATE_ERR;
-        return nullptr;
-    }
+    if (isRemoved())
+        return Exception { INVALID_STATE_ERR };
 
     // 2. Return a new static normalized TimeRanges object for the media segments buffered.
     return m_buffered->copy();
 }
 
-const RefPtr<TimeRanges>& SourceBuffer::buffered() const
-{
-    return m_buffered;
-}
-
 double SourceBuffer::timestampOffset() const
 {
     return m_timestampOffset.toDouble();
 }
 
-void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::setTimestampOffset(double offset)
 {
     // Section 3.1 timestampOffset attribute setter steps.
     // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#attributes-1
@@ -158,10 +152,8 @@
     // 2. If this object has been removed from the sourceBuffers attribute of the parent media source, then throw an
     //    INVALID_STATE_ERR exception and abort these steps.
     // 3. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
-    if (isRemoved() || m_updating) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (isRemoved() || m_updating)
+        return Exception { INVALID_STATE_ERR };
 
     // 4. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
     // 4.1 Set the readyState attribute of the parent media source to "open"
@@ -169,10 +161,8 @@
     m_source->openIfInEndedState();
 
     // 5. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALID_STATE_ERR and abort these steps.
-    if (m_appendState == ParsingMediaSegment) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (m_appendState == ParsingMediaSegment)
+        return Exception { INVALID_STATE_ERR };
 
     MediaTime newTimestampOffset = MediaTime::createWithDouble(offset);
 
@@ -182,14 +172,16 @@
 
     // 7. Update the attribute to the new value.
     m_timestampOffset = newTimestampOffset;
+
+    return { };
 }
 
 double SourceBuffer::appendWindowStart() const
 {
     return m_appendWindowStart.toDouble();
-};
+}
 
-void SourceBuffer::setAppendWindowStart(double newValue, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::setAppendWindowStart(double newValue)
 {
     // Section 3.1 appendWindowStart attribute setter steps.
     // W3C Editor's Draft 16 September 2016
@@ -197,28 +189,26 @@
     // 1. If this object has been removed from the sourceBuffers attribute of the parent media source,
     //    then throw an InvalidStateError  exception and abort these steps.
     // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
-    if (isRemoved() || m_updating) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (isRemoved() || m_updating)
+        return Exception { INVALID_STATE_ERR };
 
     // 3. If the new value is less than 0 or greater than or equal to appendWindowEnd then
     //    throw an TypeError exception and abort these steps.
-    if (newValue < 0 || newValue >= m_appendWindowEnd.toDouble()) {
-        ec = TypeError;
-        return;
-    }
+    if (newValue < 0 || newValue >= m_appendWindowEnd.toDouble())
+        return Exception { TypeError };
 
     // 4. Update the attribute to the new value.
     m_appendWindowStart = MediaTime::createWithDouble(newValue);
+
+    return { };
 }
 
 double SourceBuffer::appendWindowEnd() const
 {
     return m_appendWindowEnd.toDouble();
-};
+}
 
-void SourceBuffer::setAppendWindowEnd(double newValue, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::setAppendWindowEnd(double newValue)
 {
     // Section 3.1 appendWindowEnd attribute setter steps.
     // W3C Editor's Draft 16 September 2016
@@ -226,32 +216,30 @@
     // 1. If this object has been removed from the sourceBuffers attribute of the parent media source,
     //    then throw an InvalidStateError exception and abort these steps.
     // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
-    if (isRemoved() || m_updating) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (isRemoved() || m_updating)
+        return Exception { INVALID_STATE_ERR };
 
     // 3. If the new value equals NaN, then throw an TypeError and abort these steps.
     // 4. If the new value is less than or equal to appendWindowStart then throw an TypeError exception
     //    and abort these steps.
-    if (std::isnan(newValue) || newValue <= m_appendWindowStart.toDouble()) {
-        ec = TypeError;
-        return;
-    }
+    if (std::isnan(newValue) || newValue <= m_appendWindowStart.toDouble())
+        return Exception { TypeError };
 
     // 5.. Update the attribute to the new value.
     m_appendWindowEnd = MediaTime::createWithDouble(newValue);
+
+    return { };
 }
 
 
-void SourceBuffer::appendBuffer(ArrayBuffer& data, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::appendBuffer(ArrayBuffer& data)
 {
-    appendBufferInternal(static_cast<unsigned char*>(data.data()), data.byteLength(), ec);
+    return appendBufferInternal(static_cast<unsigned char*>(data.data()), data.byteLength());
 }
 
-void SourceBuffer::appendBuffer(ArrayBufferView& data, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::appendBuffer(ArrayBufferView& data)
 {
-    appendBufferInternal(static_cast<unsigned char*>(data.baseAddress()), data.byteLength(), ec);
+    return appendBufferInternal(static_cast<unsigned char*>(data.baseAddress()), data.byteLength());
 }
 
 void SourceBuffer::resetParserState()
@@ -281,7 +269,7 @@
     m_private->resetParserState();
 }
 
-void SourceBuffer::abort(ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::abort()
 {
     // Section 3.2 abort() method steps.
     // https://rawgit.com/w3c/media-source/45627646344eea0170dd1cbc5a3d508ca751abb8/media-source-respec.html#dom-sourcebuffer-abort
@@ -289,16 +277,12 @@
     //    then throw an INVALID_STATE_ERR exception and abort these steps.
     // 2. If the readyState attribute of the parent media source is not in the "open" state
     //    then throw an INVALID_STATE_ERR exception and abort these steps.
-    if (isRemoved() || !m_source->isOpen()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (isRemoved() || !m_source->isOpen())
+        return Exception { INVALID_STATE_ERR };
 
     // 3. If the range removal algorithm is running, then throw an InvalidStateError exception and abort these steps.
-    if (m_removeTimer.isActive()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (m_removeTimer.isActive())
+        return Exception { INVALID_STATE_ERR };
 
     // 4. If the sourceBuffer.updating attribute equals true, then run the following steps: ...
     abortIfUpdating();
@@ -311,14 +295,16 @@
 
     // 7. Set appendWindowEnd to positive Infinity.
     m_appendWindowEnd = MediaTime::positiveInfiniteTime();
+
+    return { };
 }
 
-void SourceBuffer::remove(double start, double end, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::remove(double start, double end)
 {
-    remove(MediaTime::createWithDouble(start), MediaTime::createWithDouble(end), ec);
+    return remove(MediaTime::createWithDouble(start), MediaTime::createWithDouble(end));
 }
 
-void SourceBuffer::remove(const MediaTime& start, const MediaTime& end, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::remove(const MediaTime& start, const MediaTime& end)
 {
     LOG(MediaSource, "SourceBuffer::remove(%p) - start(%lf), end(%lf)", this, start.toDouble(), end.toDouble());
 
@@ -327,10 +313,8 @@
     // 1. If this object has been removed from the sourceBuffers attribute of the parent media source then throw
     //    an InvalidStateError exception and abort these steps.
     // 2. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps.
-    if (isRemoved() || m_updating) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (isRemoved() || m_updating)
+        return Exception { INVALID_STATE_ERR };
 
     // 3. If duration equals NaN, then throw a TypeError exception and abort these steps.
     // 4. If start is negative or greater than duration, then throw a TypeError exception and abort these steps.
@@ -341,8 +325,7 @@
         || start < MediaTime::zeroTime()
         || start > m_source->duration()
         || end <= start) {
-        ec = TypeError;
-        return;
+        return Exception { TypeError };
     }
 
     // 6. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
@@ -352,6 +335,8 @@
 
     // 7. Run the range removal algorithm with start and end as the start and end of the removal range.
     rangeRemoval(start, end);
+
+    return { };
 }
 
 void SourceBuffer::rangeRemoval(const MediaTime& start, const MediaTime& end)
@@ -511,7 +496,7 @@
     m_asyncEventQueue.enqueueEvent(WTFMove(event));
 }
 
-void SourceBuffer::appendBufferInternal(unsigned char* data, unsigned size, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::appendBufferInternal(unsigned char* data, unsigned size)
 {
     // Section 3.2 appendBuffer()
     // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
@@ -523,10 +508,8 @@
     // 1. If the SourceBuffer has been removed from the sourceBuffers attribute of the parent media source
     // then throw an INVALID_STATE_ERR exception and abort these steps.
     // 2. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
-    if (isRemoved() || m_updating) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (isRemoved() || m_updating)
+        return Exception { INVALID_STATE_ERR };
 
     // 3. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
     // 3.1. Set the readyState attribute of the parent media source to "open"
@@ -541,8 +524,7 @@
     // 5. If the buffer full flag equals true, then throw a QUOTA_EXCEEDED_ERR exception and abort these step.
     if (m_bufferFull) {
         LOG(MediaSource, "SourceBuffer::appendBufferInternal(%p) -  buffer full, failing with QUOTA_EXCEEDED_ERR error", this);
-        ec = QUOTA_EXCEEDED_ERR;
-        return;
+        return Exception { QUOTA_EXCEEDED_ERR };
     }
 #endif
 
@@ -560,6 +542,8 @@
     m_appendBufferTimer.startOneShot(0);
 
     reportExtraMemoryAllocated();
+
+    return { };
 }
 
 void SourceBuffer::appendBufferTimerFired()
@@ -2044,7 +2028,7 @@
     return downcast<Document>(*scriptExecutionContext());
 }
 
-void SourceBuffer::setMode(AppendMode newMode, ExceptionCode& ec)
+ExceptionOr<void> SourceBuffer::setMode(AppendMode newMode)
 {
     // 3.1 Attributes - mode
     // http://www.w3.org/TR/media-source/#widl-SourceBuffer-mode
@@ -2053,20 +2037,16 @@
 
     // 1. Let new mode equal the new value being assigned to this attribute.
     // 2. If generate timestamps flag equals true and new mode equals "segments", then throw an INVALID_ACCESS_ERR exception and abort these steps.
-    if (m_shouldGenerateTimestamps && newMode == AppendMode::Segments) {
-        ec = INVALID_ACCESS_ERR;
-        return;
-    }
+    if (m_shouldGenerateTimestamps && newMode == AppendMode::Segments)
+        return Exception { INVALID_ACCESS_ERR };
 
     // 3. If this object has been removed from the sourceBuffers attribute of the parent media source, then throw an INVALID_STATE_ERR exception and abort these steps.
     // 4. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps.
-    if (isRemoved() || m_updating) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (isRemoved() || m_updating)
+        return Exception { INVALID_STATE_ERR };
 
     // 5. If the readyState attribute of the parent media source is in the "ended" state then run the following steps:
-    if (m_source->readyState() == MediaSource::endedKeyword()) {
+    if (m_source->isEnded()) {
         // 5.1. Set the readyState attribute of the parent media source to "open"
         // 5.2. Queue a task to fire a simple event named sourceopen at the parent media source.
         m_source->openIfInEndedState();
@@ -2073,10 +2053,8 @@
     }
 
     // 6. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALID_STATE_ERR and abort these steps.
-    if (m_appendState == ParsingMediaSegment) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (m_appendState == ParsingMediaSegment)
+        return Exception { INVALID_STATE_ERR };
 
     // 7. If the new mode equals "sequence", then set the group start timestamp to the group end timestamp.
     if (newMode == AppendMode::Sequence)
@@ -2084,6 +2062,8 @@
 
     // 8. Update the attribute to new mode.
     m_mode = newMode;
+
+    return { };
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (207006 => 207007)


--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h	2016-10-10 17:25:48 UTC (rev 207007)
@@ -36,16 +36,13 @@
 #include "ActiveDOMObject.h"
 #include "AudioTrack.h"
 #include "EventTarget.h"
-#include "ExceptionCode.h"
+#include "ExceptionOr.h"
 #include "GenericEventQueue.h"
-#include "ScriptWrappable.h"
 #include "SourceBufferPrivateClient.h"
 #include "TextTrack.h"
 #include "Timer.h"
 #include "VideoTrack.h"
 #include <runtime/ArrayBufferView.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -52,23 +49,19 @@
 class AudioTrackList;
 class MediaSource;
 class PlatformTimeRanges;
-class SourceBufferPrivate;
 class TextTrackList;
 class TimeRanges;
 class VideoTrackList;
 
-class SourceBuffer final : public RefCounted<SourceBuffer>, public ActiveDOMObject, public EventTargetWithInlineData, public SourceBufferPrivateClient, public AudioTrackClient, public VideoTrackClient, public TextTrackClient {
+class SourceBuffer final : public RefCounted<SourceBuffer>, public ActiveDOMObject, public EventTargetWithInlineData, private SourceBufferPrivateClient, private AudioTrackClient, private VideoTrackClient, private TextTrackClient {
 public:
     static Ref<SourceBuffer> create(Ref<SourceBufferPrivate>&&, MediaSource*);
-
     virtual ~SourceBuffer();
 
-    // SourceBuffer.idl methods
     bool updating() const { return m_updating; }
-    RefPtr<TimeRanges> buffered(ExceptionCode&) const;
-    const RefPtr<TimeRanges>& buffered() const;
+    ExceptionOr<Ref<TimeRanges>> buffered() const;
     double timestampOffset() const;
-    void setTimestampOffset(double, ExceptionCode&);
+    ExceptionOr<void> setTimestampOffset(double);
 
 #if ENABLE(VIDEO_TRACK)
     VideoTrackList* videoTracks();
@@ -77,17 +70,18 @@
 #endif
 
     double appendWindowStart() const;
-    void setAppendWindowStart(double, ExceptionCode&);
+    ExceptionOr<void> setAppendWindowStart(double);
     double appendWindowEnd() const;
-    void setAppendWindowEnd(double, ExceptionCode&);
+    ExceptionOr<void> setAppendWindowEnd(double);
 
-    void appendBuffer(ArrayBuffer&, ExceptionCode&);
-    void appendBuffer(ArrayBufferView&, ExceptionCode&);
-    void abort(ExceptionCode&);
-    void remove(double start, double end, ExceptionCode&);
-    void remove(const MediaTime&, const MediaTime&, ExceptionCode&);
+    ExceptionOr<void> appendBuffer(ArrayBuffer&);
+    ExceptionOr<void> appendBuffer(ArrayBufferView&);
+    ExceptionOr<void> abort();
+    ExceptionOr<void> remove(double start, double end);
+    ExceptionOr<void> remove(const MediaTime&, const MediaTime&);
 
-    void appendError(bool);
+    const TimeRanges& bufferedInternal() const { ASSERT(m_buffered); return *m_buffered; }
+
     void abortIfUpdating();
     void removedFromMediaSource();
     void seekToTime(const MediaTime&);
@@ -95,16 +89,13 @@
     bool canPlayThroughRange(PlatformTimeRanges&);
 
     bool hasVideo() const;
-    bool hasAudio() const;
 
     bool active() const { return m_active; }
 
-    // EventTarget interface
-    ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
-    EventTargetInterface eventTargetInterface() const override { return SourceBufferEventTargetInterfaceType; }
+    ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
 
-    using RefCounted<SourceBuffer>::ref;
-    using RefCounted<SourceBuffer>::deref;
+    using RefCounted::ref;
+    using RefCounted::deref;
 
     struct TrackBuffer;
 
@@ -112,13 +103,10 @@
 
     enum class AppendMode { Segments, Sequence };
     AppendMode mode() const { return m_mode; }
-    void setMode(AppendMode, ExceptionCode&);
+    ExceptionOr<void> setMode(AppendMode);
 
-    bool shouldGenerateTimestamps() const { return m_shouldGenerateTimestamps; }
     void setShouldGenerateTimestamps(bool flag) { m_shouldGenerateTimestamps = flag; }
 
-    void rangeRemoval(const MediaTime&, const MediaTime&);
-
     bool isBufferedDirty() const { return m_bufferedDirty; }
     void setBufferedDirty(bool flag) { m_bufferedDirty = flag; }
 
@@ -125,50 +113,44 @@
     MediaTime highestPresentationTimestamp() const;
     void readyStateChanged();
 
-    // ActiveDOMObject API.
-    bool hasPendingActivity() const override;
+    bool hasPendingActivity() const final;
 
-protected:
-    // EventTarget interface
-    void refEventTarget() override { ref(); }
-    void derefEventTarget() override { deref(); }
-
 private:
     SourceBuffer(Ref<SourceBufferPrivate>&&, MediaSource*);
 
-    // ActiveDOMObject API.
-    void stop() override;
-    const char* activeDOMObjectName() const override;
-    bool canSuspendForDocumentSuspension() const override;
+    void refEventTarget() final { ref(); }
+    void derefEventTarget() final { deref(); }
 
-    // SourceBufferPrivateClient
-    void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivate*, const InitializationSegment&) override;
-    void sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, MediaSample&) override;
-    bool sourceBufferPrivateHasAudio(const SourceBufferPrivate*) const override;
-    bool sourceBufferPrivateHasVideo(const SourceBufferPrivate*) const override;
-    void sourceBufferPrivateDidBecomeReadyForMoreSamples(SourceBufferPrivate*, AtomicString trackID) override;
-    MediaTime sourceBufferPrivateFastSeekTimeForMediaTime(SourceBufferPrivate*, const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) override;
-    void sourceBufferPrivateAppendComplete(SourceBufferPrivate*, AppendResult) override;
-    void sourceBufferPrivateDidReceiveRenderingError(SourceBufferPrivate*, int errorCode) override;
+    void stop() final;
+    const char* activeDOMObjectName() const final;
+    bool canSuspendForDocumentSuspension() const final;
 
-    // AudioTrackClient
-    void audioTrackEnabledChanged(AudioTrack*) override;
+    void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivate*, const InitializationSegment&) final;
+    void sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, MediaSample&) final;
+    bool sourceBufferPrivateHasAudio(const SourceBufferPrivate*) const final;
+    bool sourceBufferPrivateHasVideo(const SourceBufferPrivate*) const final;
+    void sourceBufferPrivateDidBecomeReadyForMoreSamples(SourceBufferPrivate*, AtomicString trackID) final;
+    MediaTime sourceBufferPrivateFastSeekTimeForMediaTime(SourceBufferPrivate*, const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) final;
+    void sourceBufferPrivateAppendComplete(SourceBufferPrivate*, AppendResult) final;
+    void sourceBufferPrivateDidReceiveRenderingError(SourceBufferPrivate*, int errorCode) final;
 
-    // VideoTrackClient
-    void videoTrackSelectedChanged(VideoTrack*) override;
+    void audioTrackEnabledChanged(AudioTrack*) final;
 
-    // TextTrackClient
-    void textTrackKindChanged(TextTrack*) override;
-    void textTrackModeChanged(TextTrack*) override;
-    void textTrackAddCues(TextTrack*, const TextTrackCueList*) override;
-    void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) override;
-    void textTrackAddCue(TextTrack*, TextTrackCue&) override;
-    void textTrackRemoveCue(TextTrack*, TextTrackCue&) override;
+    void videoTrackSelectedChanged(VideoTrack*) final;
 
+    void textTrackKindChanged(TextTrack*) final;
+    void textTrackModeChanged(TextTrack*) final;
+    void textTrackAddCues(TextTrack*, const TextTrackCueList*) final;
+    void textTrackRemoveCues(TextTrack*, const TextTrackCueList*) final;
+    void textTrackAddCue(TextTrack*, TextTrackCue&) final;
+    void textTrackRemoveCue(TextTrack*, TextTrackCue&) final;
+
+    EventTargetInterface eventTargetInterface() const final { return SourceBufferEventTargetInterfaceType; }
+
     bool isRemoved() const;
     void scheduleEvent(const AtomicString& eventName);
 
-    void appendBufferInternal(unsigned char*, unsigned, ExceptionCode&);
+    ExceptionOr<void> appendBufferInternal(unsigned char*, unsigned);
     void appendBufferTimerFired();
     void resetParserState();
 
@@ -192,7 +174,12 @@
 
     void updateBufferedFromTrackBuffers();
 
-    // Internals
+    void appendError(bool);
+
+    bool hasAudio() const;
+
+    void rangeRemoval(const MediaTime&, const MediaTime&);
+
     friend class Internals;
     WEBCORE_EXPORT Vector<String> bufferedSamplesForTrackID(const AtomicString&);
     WEBCORE_EXPORT Vector<String> enqueuedSamplesForTrackID(const AtomicString&);

Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.idl (207006 => 207007)


--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.idl	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.idl	2016-10-10 17:25:48 UTC (rev 207007)
@@ -38,16 +38,15 @@
     Conditional=MEDIA_SOURCE,
     ExportMacro=WEBCORE_EXPORT,
 ] interface SourceBuffer : EventTarget {
+    [SetterMayThrowException] attribute AppendMode mode;
 
-    [SetterMayThrowLegacyException] attribute AppendMode mode;
-
     readonly attribute boolean updating;
   
     // Returns the time ranges buffered.
-    [GetterMayThrowLegacyException] readonly attribute TimeRanges buffered;
+    [GetterMayThrowException] readonly attribute TimeRanges buffered;
 
     // Applies an offset to media segment timestamps.
-    [SetterMayThrowLegacyException] attribute double timestampOffset;
+    [SetterMayThrowException] attribute double timestampOffset;
 
     // Track support
     [Conditional=VIDEO_TRACK] readonly attribute AudioTrackList audioTracks;
@@ -54,16 +53,16 @@
     [Conditional=VIDEO_TRACK] readonly attribute VideoTrackList videoTracks;
     [Conditional=VIDEO_TRACK] readonly attribute TextTrackList textTracks;
 
-    [SetterMayThrowLegacyException] attribute double appendWindowStart;
-    [SetterMayThrowLegacyException] attribute unrestricted double appendWindowEnd;
+    [SetterMayThrowException] attribute double appendWindowStart;
+    [SetterMayThrowException] attribute unrestricted double appendWindowEnd;
 
     // Append segment data.
-    [MayThrowLegacyException] void appendBuffer(ArrayBuffer data);
-    [MayThrowLegacyException] void appendBuffer(ArrayBufferView data);
+    [MayThrowException] void appendBuffer(ArrayBuffer data);
+    [MayThrowException] void appendBuffer(ArrayBufferView data);
 
     // Abort the current segment append sequence.
-    [MayThrowLegacyException] void abort();
-    [MayThrowLegacyException] void remove(unrestricted double start, unrestricted double end);
+    [MayThrowException] void abort();
+    [MayThrowException] void remove(unrestricted double start, unrestricted double end);
 
     attribute EventHandler onupdatestart;
     attribute EventHandler onupdate;
@@ -71,4 +70,3 @@
     attribute EventHandler onerror;
     attribute EventHandler onabort;
 };
-

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitMediaSourceGStreamer.h (207006 => 207007)


--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitMediaSourceGStreamer.h	2016-10-10 17:23:07 UTC (rev 207006)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitMediaSourceGStreamer.h	2016-10-10 17:25:48 UTC (rev 207007)
@@ -19,13 +19,14 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef WebKitMediaSourceGStreamer_h
-#define WebKitMediaSourceGStreamer_h
+#pragma once
+
 #if ENABLE(VIDEO) && ENABLE(MEDIA_SOURCE) && USE(GSTREAMER)
 
 #include "GRefPtrGStreamer.h"
 #include "MediaPlayer.h"
 #include "MediaSource.h"
+#include "MediaSourcePrivate.h"
 #include "SourceBufferPrivate.h"
 #include "SourceBufferPrivateClient.h"
 
@@ -88,4 +89,3 @@
 };
 
 #endif // USE(GSTREAMER)
-#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to