Title: [211371] trunk/Source/WebCore
Revision
211371
Author
commit-qu...@webkit.org
Date
2017-01-30 09:36:43 -0800 (Mon, 30 Jan 2017)

Log Message

[WebRTC] Add support for libwebrtc data channel
https://bugs.webkit.org/show_bug.cgi?id=167489

Patch by Youenn Fablet <youe...@gmail.com> on 2017-01-30
Reviewed by Alex Christensen.

Partially covered by webrtc/datachannel/basic.html but not yet enabled on bots.

Introducing LibWebRTCDataChannelHandler as the integration layer between WebCore (RTCDataChannel)
and libwebrtc (DataChannelObserver).

* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::RTCDataChannel::create):
(WebCore::RTCDataChannel::RTCDataChannel):
(WebCore::RTCDataChannel::bufferedAmount):
(WebCore::RTCDataChannel::bufferedAmountIsDecreasing):
* Modules/mediastream/RTCDataChannel.h:
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp: Added.
(WebCore::LibWebRTCDataChannelHandler::~LibWebRTCDataChannelHandler):
(WebCore::LibWebRTCDataChannelHandler::setClient):
(WebCore::LibWebRTCDataChannelHandler::sendStringData):
(WebCore::LibWebRTCDataChannelHandler::sendRawData):
(WebCore::LibWebRTCDataChannelHandler::close):
(WebCore::LibWebRTCDataChannelHandler::OnStateChange):
(WebCore::LibWebRTCDataChannelHandler::OnMessage):
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::OnRemoveStream):
(WebCore::LibWebRTCMediaEndpoint::addDataChannel):
(): Deleted.
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::createDataChannelHandler):
* dom/EventNames.h:
* platform/mediastream/RTCDataChannelHandler.h:
* platform/mediastream/RTCDataChannelHandlerClient.h:
* platform/mock/RTCDataChannelHandlerMock.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211370 => 211371)


--- trunk/Source/WebCore/ChangeLog	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/ChangeLog	2017-01-30 17:36:43 UTC (rev 211371)
@@ -1,3 +1,41 @@
+2017-01-30  Youenn Fablet  <youe...@gmail.com>
+
+        [WebRTC] Add support for libwebrtc data channel
+        https://bugs.webkit.org/show_bug.cgi?id=167489
+
+        Reviewed by Alex Christensen.
+
+        Partially covered by webrtc/datachannel/basic.html but not yet enabled on bots.
+
+        Introducing LibWebRTCDataChannelHandler as the integration layer between WebCore (RTCDataChannel)
+        and libwebrtc (DataChannelObserver).
+
+        * Modules/mediastream/RTCDataChannel.cpp:
+        (WebCore::RTCDataChannel::create):
+        (WebCore::RTCDataChannel::RTCDataChannel):
+        (WebCore::RTCDataChannel::bufferedAmount):
+        (WebCore::RTCDataChannel::bufferedAmountIsDecreasing):
+        * Modules/mediastream/RTCDataChannel.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp: Added.
+        (WebCore::LibWebRTCDataChannelHandler::~LibWebRTCDataChannelHandler):
+        (WebCore::LibWebRTCDataChannelHandler::setClient):
+        (WebCore::LibWebRTCDataChannelHandler::sendStringData):
+        (WebCore::LibWebRTCDataChannelHandler::sendRawData):
+        (WebCore::LibWebRTCDataChannelHandler::close):
+        (WebCore::LibWebRTCDataChannelHandler::OnStateChange):
+        (WebCore::LibWebRTCDataChannelHandler::OnMessage):
+        * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::OnRemoveStream):
+        (WebCore::LibWebRTCMediaEndpoint::addDataChannel):
+        (): Deleted.
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::createDataChannelHandler):
+        * dom/EventNames.h:
+        * platform/mediastream/RTCDataChannelHandler.h:
+        * platform/mediastream/RTCDataChannelHandlerClient.h:
+        * platform/mock/RTCDataChannelHandlerMock.h:
+
 2017-01-30  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Several web timing tests crash in GTK+ and AppleWin bots

Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (211370 => 211371)


--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp	2017-01-30 17:36:43 UTC (rev 211371)
@@ -55,7 +55,9 @@
 Ref<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
 {
     ASSERT(handler);
-    return adoptRef(*new RTCDataChannel(context, WTFMove(handler), WTFMove(label), WTFMove(options)));
+    auto channel = adoptRef(*new RTCDataChannel(context, WTFMove(handler), WTFMove(label), WTFMove(options)));
+    channel->m_handler->setClient(&channel.get());
+    return channel;
 }
 
 RTCDataChannel::RTCDataChannel(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
@@ -65,7 +67,6 @@
     , m_label(WTFMove(label))
     , m_options(WTFMove(options))
 {
-    m_handler->setClient(this);
 }
 
 const AtomicString& RTCDataChannel::readyState() const
@@ -90,9 +91,9 @@
     return emptyAtom;
 }
 
-unsigned RTCDataChannel::bufferedAmount() const
+size_t RTCDataChannel::bufferedAmount() const
 {
-    return 0;
+    return m_handler->bufferedAmount();
 }
 
 const AtomicString& RTCDataChannel::binaryType() const
@@ -222,6 +223,15 @@
     scheduleDispatchEvent(Event::create(eventNames().errorEvent, false, false));
 }
 
+void RTCDataChannel::bufferedAmountIsDecreasing()
+{
+    if (m_stopped)
+        return;
+
+    if (bufferedAmount() <= m_bufferedAmountLowThreshold)
+        scheduleDispatchEvent(Event::create(eventNames().bufferedAmountLowThresholdEvent, false, false));
+}
+
 void RTCDataChannel::stop()
 {
     m_stopped = true;

Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h (211370 => 211371)


--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h	2017-01-30 17:36:43 UTC (rev 211371)
@@ -44,7 +44,7 @@
 class Blob;
 class RTCPeerConnectionHandler;
 
-class RTCDataChannel final : public RefCounted<RTCDataChannel>, public EventTargetWithInlineData, public RTCDataChannelHandlerClient {
+class RTCDataChannel final : public RTCDataChannelHandlerClient, public EventTargetWithInlineData {
 public:
     static Ref<RTCDataChannel> create(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
 
@@ -57,7 +57,9 @@
 
     String label() const { return m_label; }
     const AtomicString& readyState() const;
-    unsigned bufferedAmount() const;
+    size_t bufferedAmount() const;
+    size_t bufferedAmountLowThreshold() const { return m_bufferedAmountLowThreshold; }
+    void setBufferedAmountLowThreshold(size_t value) { m_bufferedAmountLowThreshold = value; }
 
     const AtomicString& binaryType() const;
     ExceptionOr<void> setBinaryType(const AtomicString&);
@@ -71,8 +73,8 @@
 
     void stop();
 
-    using RefCounted::ref;
-    using RefCounted::deref;
+    using RTCDataChannelHandlerClient::ref;
+    using RTCDataChannelHandlerClient::deref;
 
 private:
     RTCDataChannel(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
@@ -88,12 +90,12 @@
 
     ScriptExecutionContext* m_scriptExecutionContext;
 
+    // RTCDataChannelHandlerClient API
     void didChangeReadyState(ReadyState) final;
     void didReceiveStringData(const String&) final;
     void didReceiveRawData(const char*, size_t) final;
     void didDetectError() final;
-    void protect() final { ref(); }
-    void unprotect() final { deref(); }
+    void bufferedAmountIsDecreasing() final;
 
     std::unique_ptr<RTCDataChannelHandler> m_handler;
 
@@ -109,6 +111,7 @@
 
     String m_label;
     RTCDataChannelInit m_options;
+    size_t m_bufferedAmountLowThreshold { 0 };
 };
 
 } // namespace WebCore

Added: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp (0 => 211371)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp	2017-01-30 17:36:43 UTC (rev 211371)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2017 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LibWebRTCDataChannelHandler.h"
+
+#if USE(LIBWEBRTC)
+
+#include "RTCDataChannel.h"
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+
+LibWebRTCDataChannelHandler::~LibWebRTCDataChannelHandler()
+{
+    if (m_client)
+        m_channel->UnregisterObserver();
+}
+
+void LibWebRTCDataChannelHandler::setClient(RTCDataChannelHandlerClient* client)
+{
+    m_client = client;
+    if (m_client)
+        m_channel->RegisterObserver(this);
+    else
+        m_channel->UnregisterObserver();
+}
+
+bool LibWebRTCDataChannelHandler::sendStringData(const String& text)
+{
+    return m_channel->Send({rtc::CopyOnWriteBuffer(text.utf8().data(), text.length()), false});
+}
+
+bool LibWebRTCDataChannelHandler::sendRawData(const char* data, size_t length)
+{
+    return m_channel->Send({rtc::CopyOnWriteBuffer(data, length), true});
+}
+
+void LibWebRTCDataChannelHandler::close()
+{
+    m_channel->Close();
+}
+
+void LibWebRTCDataChannelHandler::OnStateChange()
+{
+    RTCDataChannel::ReadyState state;
+    switch (m_channel->state()) {
+    case webrtc::DataChannelInterface::kConnecting:
+        state = RTCDataChannel::ReadyStateConnecting;
+        break;
+    case webrtc::DataChannelInterface::kOpen:
+        state = RTCDataChannel::ReadyStateOpen;
+        break;
+    case webrtc::DataChannelInterface::kClosing:
+        state = RTCDataChannel::ReadyStateClosing;
+        break;
+    case webrtc::DataChannelInterface::kClosed:
+        state = RTCDataChannel::ReadyStateClosed;
+        break;
+    }
+    ASSERT(m_client);
+    callOnMainThread([protectedClient = makeRef(*m_client), state] {
+        protectedClient->didChangeReadyState(state);
+    });
+}
+
+void LibWebRTCDataChannelHandler::OnMessage(const webrtc::DataBuffer& buffer)
+{
+    ASSERT(m_client);
+    std::unique_ptr<webrtc::DataBuffer> protectedBuffer(new webrtc::DataBuffer(buffer));
+    callOnMainThread([protectedClient = makeRef(*m_client), buffer = WTFMove(protectedBuffer)] {
+        // FIXME: Ensure this is correct by adding some tests with non-ASCII characters.
+        const char* data = "" char*>(buffer->data.data());
+        if (buffer->binary)
+            protectedClient->didReceiveRawData(data, buffer->size());
+        else
+            protectedClient->didReceiveStringData(String(data, buffer->size()));
+    });
+}
+
+void LibWebRTCDataChannelHandler::OnBufferedAmountChange(uint64_t previousAmount)
+{
+    if (previousAmount <= m_channel->buffered_amount())
+        return;
+    ASSERT(m_client);
+    callOnMainThread([protectedClient = makeRef(*m_client)] {
+        protectedClient->bufferedAmountIsDecreasing();
+    });
+}
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)

Copied: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h (from rev 211370, trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h) (0 => 211371)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h	2017-01-30 17:36:43 UTC (rev 211371)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2017 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(LIBWEBRTC)
+
+#include "LibWebRTCMacros.h"
+#include "RTCDataChannelHandler.h"
+#include <webrtc/api/datachannelinterface.h>
+
+namespace WebCore {
+
+class RTCDataChannelHandlerClient;
+
+class LibWebRTCDataChannelHandler final : public RTCDataChannelHandler, private webrtc::DataChannelObserver {
+public:
+    explicit LibWebRTCDataChannelHandler(rtc::scoped_refptr<webrtc::DataChannelInterface>&& channel) : m_channel(WTFMove(channel)) { ASSERT(m_channel); }
+    ~LibWebRTCDataChannelHandler();
+
+private:
+    // RTCDataChannelHandler API
+    void setClient(RTCDataChannelHandlerClient*) final;
+    bool sendStringData(const String&) final;
+    bool sendRawData(const char*, size_t) final;
+    void close() final;
+    size_t bufferedAmount() const final { return m_channel->buffered_amount(); }
+
+    // webrtc::DataChannelObserver API
+    void OnStateChange();
+    void OnMessage(const webrtc::DataBuffer&);
+    void OnBufferedAmountChange(uint64_t);
+
+    rtc::scoped_refptr<webrtc::DataChannelInterface> m_channel;
+    RTCDataChannelHandlerClient* m_client { nullptr };
+};
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (211370 => 211371)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-01-30 17:36:43 UTC (rev 211371)
@@ -28,6 +28,7 @@
 #if USE(LIBWEBRTC)
 
 #include "EventNames.h"
+#include "LibWebRTCDataChannelHandler.h"
 #include "LibWebRTCPeerConnectionBackend.h"
 #include "LibWebRTCProvider.h"
 #include "LibWebRTCUtils.h"
@@ -285,9 +286,52 @@
 
 void LibWebRTCMediaEndpoint::OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface>)
 {
-    ASSERT_NOT_REACHED();
+    notImplemented();
 }
 
+std::unique_ptr<RTCDataChannelHandler> LibWebRTCMediaEndpoint::createDataChannel(const String& label, const RTCDataChannelInit& options)
+{
+    webrtc::DataChannelInit init;
+    init.ordered = options.ordered;
+    init.maxRetransmitTime = options.maxRetransmitTime;
+    init.maxRetransmits = options.maxRetransmits;
+    init.protocol = options.protocol.utf8().data();
+    init.negotiated = options.negotiated;
+    init.id = options.id;
+
+    return std::make_unique<LibWebRTCDataChannelHandler>(m_backend->CreateDataChannel(label.utf8().data(), &init));
+}
+
+void LibWebRTCMediaEndpoint::addDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel)
+{
+    auto protocol = dataChannel->protocol();
+    auto label = dataChannel->label();
+
+    RTCDataChannelInit init;
+    init.ordered = dataChannel->ordered();
+    init.maxRetransmitTime = dataChannel->maxRetransmitTime();
+    init.maxRetransmits = dataChannel->maxRetransmits();
+    init.protocol = String(protocol.data(), protocol.size());
+    init.negotiated = dataChannel->negotiated();
+    init.id = dataChannel->id();
+
+    bool isOpened = dataChannel->state() == webrtc::DataChannelInterface::kOpen;
+
+    auto handler =  std::make_unique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel));
+    ASSERT(m_peerConnectionBackend.connection().scriptExecutionContext());
+    auto channel = RTCDataChannel::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), WTFMove(handler), String(label.data(), label.size()), WTFMove(init));
+
+    if (isOpened) {
+        callOnMainThread([channel = channel.copyRef()] {
+            // FIXME: We should be able to write channel->didChangeReadyState(...)
+            RTCDataChannelHandlerClient& client = channel.get();
+            client.didChangeReadyState(RTCDataChannel::ReadyStateOpen);
+        });
+    }
+
+    m_peerConnectionBackend.connection().fireEvent(RTCDataChannelEvent::create(eventNames().datachannelEvent, false, false, WTFMove(channel)));
+}
+
 void LibWebRTCMediaEndpoint::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel)
 {
     callOnMainThread([protectedThis = makeRef(*this), dataChannel = WTFMove(dataChannel)] {

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (211370 => 211371)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2017-01-30 17:36:43 UTC (rev 211371)
@@ -66,6 +66,7 @@
     void doCreateOffer();
     void doCreateAnswer();
     void getStats(MediaStreamTrack*, PeerConnection::StatsPromise&&);
+    std::unique_ptr<RTCDataChannelHandler> createDataChannel(const String&, const RTCDataChannelInit&);
 
     void storeIceCandidate(std::unique_ptr<webrtc::IceCandidateInterface>&& candidate) { m_pendingCandidates.append(WTFMove(candidate)); }
     void addPendingIceCandidates();

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (211370 => 211371)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-01-30 17:36:43 UTC (rev 211371)
@@ -29,6 +29,7 @@
 
 #include "Document.h"
 #include "IceCandidate.h"
+#include "LibWebRTCDataChannelHandler.h"
 #include "LibWebRTCMediaEndpoint.h"
 #include "MediaEndpointConfiguration.h"
 #include "Page.h"
@@ -179,10 +180,7 @@
 
 std::unique_ptr<RTCDataChannelHandler> LibWebRTCPeerConnectionBackend::createDataChannelHandler(const String& label, const RTCDataChannelInit& options)
 {
-    UNUSED_PARAM(label);
-    UNUSED_PARAM(options);
-    ASSERT_NOT_REACHED();
-    return nullptr;
+    return m_endpoint->createDataChannel(label, options);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/EventNames.h (211370 => 211371)


--- trunk/Source/WebCore/dom/EventNames.h	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/dom/EventNames.h	2017-01-30 17:36:43 UTC (rev 211371)
@@ -67,6 +67,7 @@
     macro(blocked) \
     macro(blur) \
     macro(boundary) \
+    macro(bufferedAmountLowThreshold) \
     macro(cached) \
     macro(cancel) \
     macro(canplay) \

Modified: trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h (211370 => 211371)


--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h	2017-01-30 17:36:43 UTC (rev 211371)
@@ -50,6 +50,8 @@
     virtual bool sendStringData(const String&) = 0;
     virtual bool sendRawData(const char*, size_t) = 0;
     virtual void close() = 0;
+
+    virtual size_t bufferedAmount() const = 0;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h (211370 => 211371)


--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h	2017-01-30 17:36:43 UTC (rev 211371)
@@ -22,16 +22,16 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef RTCDataChannelHandlerClient_h
-#define RTCDataChannelHandlerClient_h
+#pragma once
 
 #if ENABLE(WEB_RTC)
 
+#include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class RTCDataChannelHandlerClient {
+class RTCDataChannelHandlerClient : public ThreadSafeRefCounted<RTCDataChannelHandlerClient> {
 public:
     enum ReadyState {
         ReadyStateConnecting = 0,
@@ -46,13 +46,9 @@
     virtual void didReceiveStringData(const String&) = 0;
     virtual void didReceiveRawData(const char*, size_t) = 0;
     virtual void didDetectError() = 0;
-
-    virtual void protect() = 0;
-    virtual void unprotect() = 0;
+    virtual void bufferedAmountIsDecreasing() = 0;
 };
 
 } // namespace WebCore
 
 #endif // ENABLE(WEB_RTC)
-
-#endif // RTCDataChannelHandlerClient_h

Modified: trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.h (211370 => 211371)


--- trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.h	2017-01-30 17:31:47 UTC (rev 211370)
+++ trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.h	2017-01-30 17:36:43 UTC (rev 211371)
@@ -42,6 +42,7 @@
     bool sendStringData(const String&) final;
     bool sendRawData(const char*, size_t) final;
     void close() final;
+    size_t bufferedAmount() const final { return 0; }
 
     RTCDataChannelHandlerClient* m_client;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to