<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214627] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214627">214627</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-30 14:42:19 -0700 (Thu, 30 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Clean up RTCDataChannel
https://bugs.webkit.org/show_bug.cgi?id=169732

LayoutTests/imported/w3c:

Patch by Youenn Fablet &lt;youenn@apple.com&gt; on 2017-03-30
Reviewed by Chris Dumez.

* web-platform-tests/webrtc/RTCDataChannelEvent-constructor-expected.txt:

Source/JavaScriptCore:

Patch by Youenn Fablet &lt;youenn@apple.com&gt; on 2017-03-30
Reviewed by Chris Dumez.

* runtime/CommonIdentifiers.h: Adding RTCDataChannelEvent.

Source/WebCore:

Patch by Youenn Fablet  &lt;youenn@apple.com&gt; and Jon Lee &lt;jonlee@apple.com&gt; on 2017-03-30
Reviewed by Chris Dumez.

Test: webrtc/datachannel/datachannel-event.html
      webrtc/datachannel/bufferedAmountLowThreshold.html

Making RTCDataChannel interface closer to the spec updating implementation accordingly.
See https://w3c.github.io/webrtc-pc/#rtcdatachannel.
In particular adding RTCDataChannelEvent constructor, and missing bufferedAmount related attributes.
Doing some additional cleaning refactoring.

Making bufferedAmountIsDecreasing take a bufferedAmount argument so that we get the actual value passed by
libwebrtc without needing to get it from the libwebrtc network thread again.
In the future, we should store the bufferedAmount value in RTCDataChannel and update its value on each libwebrtc
OnBufferedAmountChange. Special treatment may be needed when the data channel is closed, in which case the bufferedAmount should just be
updated to increase in the send method.

Added some FIXMEs as RTCDataChannel is not aligned with the spec related to send and bufferedAmount.

* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::RTCDataChannel::send):
(WebCore::RTCDataChannel::close):
(WebCore::RTCDataChannel::didChangeReadyState):
(WebCore::RTCDataChannel::bufferedAmountIsDecreasing):
* Modules/mediastream/RTCDataChannel.h:
* Modules/mediastream/RTCDataChannel.idl:
* Modules/mediastream/RTCDataChannelEvent.cpp:
(WebCore::RTCDataChannelEvent::create):
(WebCore::RTCDataChannelEvent::RTCDataChannelEvent):
(WebCore::RTCDataChannelEvent::channel):
* Modules/mediastream/RTCDataChannelEvent.h:
* Modules/mediastream/RTCDataChannelEvent.idl:
* Modules/mediastream/RTCPeerConnection.idl:
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
(WebCore::LibWebRTCDataChannelHandler::OnStateChange):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::addDataChannel):
* WebCore.xcodeproj/project.pbxproj:
* dom/EventNames.h:
* platform/mediastream/RTCDataChannelHandler.h:
* platform/mediastream/RTCDataChannelHandlerClient.h:
* platform/mediastream/RTCDataChannelState.h: Added.
* platform/mediastream/RTCPeerConnectionHandlerClient.h:
* platform/mock/RTCDataChannelHandlerMock.cpp:
(WebCore::RTCDataChannelHandlerMock::setClient):
(WebCore::RTCDataChannelHandlerMock::close):
* platform/mock/RTCNotifiersMock.cpp:
(WebCore::IceConnectionNotifier::IceConnectionNotifier):
(WebCore::SignalingStateNotifier::SignalingStateNotifier):
(WebCore::DataChannelStateNotifier::DataChannelStateNotifier):
* platform/mock/RTCNotifiersMock.h:

LayoutTests:

Patch by Youenn Fablet &lt;youenn@apple.com&gt; on 2017-03-30
Reviewed by Chris Dumez.

* webrtc/datachannel/bufferedAmountLowThreshold-expected.txt: Added.
* webrtc/datachannel/bufferedAmountLowThreshold.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestswebrtcRTCDataChannelEventconstructorexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannelEvent-constructor-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelbasichtml">trunk/LayoutTests/webrtc/datachannel/basic.html</a></li>
<li><a href="#trunkLayoutTestswebrtcroutinesjs">trunk/LayoutTests/webrtc/routines.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCDataChannelcpp">trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCDataChannelh">trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCDataChannelidl">trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCDataChannelEventcpp">trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCDataChannelEventh">trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCDataChannelEventidl">trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamRTCPeerConnectionidl">trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCDataChannelHandlercpp">trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCMediaEndpointcpp">trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoredomEventNamesh">trunk/Source/WebCore/dom/EventNames.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRTCDataChannelHandlerh">trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRTCDataChannelHandlerClienth">trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRTCPeerConnectionHandlerClienth">trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockRTCDataChannelHandlerMockcpp">trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockRTCNotifiersMockcpp">trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockRTCNotifiersMockh">trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebrtcdatachannelbufferedAmountLowThresholdexpectedtxt">trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelbufferedAmountLowThresholdhtml">trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachanneldatachanneleventexpectedtxt">trunk/LayoutTests/webrtc/datachannel/datachannel-event-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachanneldatachanneleventhtml">trunk/LayoutTests/webrtc/datachannel/datachannel-event.html</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRTCDataChannelStateh">trunk/Source/WebCore/platform/mediastream/RTCDataChannelState.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/LayoutTests/ChangeLog        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2017-03-30  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        Clean up RTCDataChannel
+        https://bugs.webkit.org/show_bug.cgi?id=169732
+
+        Reviewed by Chris Dumez.
+
+        * webrtc/datachannel/bufferedAmountLowThreshold-expected.txt: Added.
+        * webrtc/datachannel/bufferedAmountLowThreshold.html: Added.
+
</ins><span class="cx"> 2017-03-30  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         svg/animations/animations-paused-in-background-page.html is flaky
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-03-30  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        Clean up RTCDataChannel
+        https://bugs.webkit.org/show_bug.cgi?id=169732
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/webrtc/RTCDataChannelEvent-constructor-expected.txt:
+
</ins><span class="cx"> 2017-03-28  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix addIceCandidate after r214441
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestswebrtcRTCDataChannelEventconstructorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannelEvent-constructor-expected.txt (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannelEvent-constructor-expected.txt        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannelEvent-constructor-expected.txt        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> 
</span><del>-FAIL RTCDataChannelEvent constructor without a required argument. Can't find variable: RTCDataChannelEvent
-FAIL RTCDataChannelEvent constructor with channel passed as null. assert_throws: function &quot;function () { new RTCDataChannelEvent('type', { channel: null }); }&quot; threw object &quot;ReferenceError: Can't find variable: RTCDataChannelEvent&quot; (&quot;ReferenceError&quot;) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL RTCDataChannelEvent constructor with a channel passed as undefined. assert_throws: function &quot;function () { new RTCDataChannelEvent('type', { channel: undefined }); }&quot; threw object &quot;ReferenceError: Can't find variable: RTCDataChannelEvent&quot; (&quot;ReferenceError&quot;) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL RTCDataChannelEvent constructor with full arguments. Can't find variable: RTCDataChannelEvent
</del><ins>+PASS RTCDataChannelEvent constructor without a required argument. 
+PASS RTCDataChannelEvent constructor with channel passed as null. 
+PASS RTCDataChannelEvent constructor with a channel passed as undefined. 
+PASS RTCDataChannelEvent constructor with full arguments. 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbasichtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/datachannel/basic.html (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/basic.html        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/LayoutTests/webrtc/datachannel/basic.html        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx">                 remoteChannel = event.channel;
</span><span class="cx">                 remoteChannel.onmessage = receiveMessages;
</span><span class="cx">             };
</span><del>-        }, (candidate) =&gt; { return candidate &amp;&amp; candidate.candidate.toLowerCase().indexOf(&quot;udp&quot;) == -1; });
</del><ins>+        }, { filterOutICECandidate: (candidate) =&gt; { return candidate &amp;&amp; candidate.candidate.toLowerCase().indexOf(&quot;udp&quot;) == -1; } });
</ins><span class="cx">     });
</span><span class="cx"> }, &quot;Basic data channel exchange from offerer to receiver using UDP only&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx">                 remoteChannel = event.channel;
</span><span class="cx">                 remoteChannel.onmessage = receiveMessages;
</span><span class="cx">             };
</span><del>-        }, (candidate) =&gt; { return candidate &amp;&amp; candidate.candidate.toLowerCase().indexOf(&quot;tcp&quot;) == -1; });
</del><ins>+        }, { filterOutICECandidate: (candidate) =&gt; { return candidate &amp;&amp; candidate.candidate.toLowerCase().indexOf(&quot;tcp&quot;) == -1; } });
</ins><span class="cx">     });
</span><span class="cx"> }, &quot;Basic data channel exchange from offerer to receiver using TCP only&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx"> 
</span><span class="cx">         finishTest = resolve;
</span><span class="cx">         createConnections((localConnection) =&gt; {
</span><del>-            var init = { ordered: true, maxPacketLifeTime: 10, maxRetransmitTime: 11, protocol: &quot;whatever&quot;, negotiated: false, id: &quot;id&quot; };
</del><ins>+            var init = { ordered: true, maxPacketLifeTime: 10, maxRetransmitTime: 11, protocol: &quot;whatever&quot;, negotiated: false, id: 1 };
</ins><span class="cx">             localChannel = localConnection.createDataChannel('sendDataChannel', init);
</span><span class="cx">             localChannel.onopen = () =&gt; { sendMessages(localChannel) };
</span><span class="cx">         }, (remoteConnection) =&gt; {
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbufferedAmountLowThresholdexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold-expected.txt (0 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold-expected.txt                                (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold-expected.txt        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+CONSOLE MESSAGE: line 76: channel send is throwing
+CONSOLE MESSAGE: line 76: channel send is throwing
+
+PASS Default buffer threshold 
+PASS Large buffer threshold reached 
+PASS Medium buffer threshold not reached 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbufferedAmountLowThresholdhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html (0 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html                                (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -0,0 +1,143 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Testing bufferedAmountLowThreashold RTCDataChannel attribute and event&lt;/title&gt;
+    &lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script src =&quot;../routines.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+var localChannel;
+var remoteChannel;
+
+function closeDataChannels() {
+    localChannel.close();
+    remoteChannel.close();
+    closeConnections();
+}
+
+var longString = &quot;abcdefgh&quot;;
+for (var cptr = 0; cptr &lt; 14; ++cptr)
+    longString += longString;
+
+function sendMessages(channel)
+{
+    channel.send(longString);
+    channel.send(longString);
+}
+
+function receiveMessages(event) {
+    if (++counter === 1)
+        return;
+    finishTest();
+}
+
+var finishTest;
+
+promise_test((test) =&gt; {
+    counter = 0;
+    var gotEvent = false;
+    return new Promise((resolve, reject) =&gt; {
+        if (window.internals)
+            internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
+
+        finishTest = resolve;
+        createConnections((localConnection) =&gt; {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onopen = () =&gt; { sendMessages(localChannel); };
+            localChannel.onbufferedamountlow = () =&gt; {
+                gotEvent = true;
+            }
+            assert_equals(localChannel.bufferedAmountLowThreshold, 0, &quot;default bufferedAmountLowThreshold value&quot;);
+        }, (remoteConnection) =&gt; {
+            remoteConnection.ondatachannel = (event) =&gt; {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = receiveMessages;
+            };
+        });
+    }).then (() =&gt; {
+         return waitFor(500);
+    }).then (() =&gt; {
+        closeDataChannels();
+        assert_true(gotEvent, &quot;got onbufferedamountlow event&quot;);
+    });
+}, &quot;Default buffer threshold&quot;);
+
+function sendContinuouslyMessages(channel)
+{
+    try {
+        while (channel.bufferedAmount &lt; 200000)
+            channel.send(longString);
+
+       setTimeout(() =&gt; sendContinuouslyMessages(channel), 1);
+    } catch(e) {
+        console.log(&quot;channel send is throwing&quot;);
+    }
+}
+
+promise_test((test) =&gt; {
+    counter = 0;
+    var gotEvent = false;
+    return new Promise((resolve, reject) =&gt; {
+        if (window.internals)
+            internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
+
+        finishTest = resolve;
+        createConnections((localConnection) =&gt; {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onopen = () =&gt; {
+                sendContinuouslyMessages(localChannel);
+                localChannel.onbufferedamountlow = () =&gt; {
+                    gotEvent = true;
+                }
+            };
+            localChannel.bufferedAmountLowThreshold = 200000;
+        }, (remoteConnection) =&gt; {
+            remoteConnection.ondatachannel = (event) =&gt; {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = receiveMessages;
+            };
+        });
+    }).then (() =&gt; {
+         return waitFor(500);
+    }).then (() =&gt; {
+        closeDataChannels();
+        assert_true(gotEvent, &quot;got onbufferedamountlow event&quot;);
+    });
+}, &quot;Large buffer threshold reached&quot;);
+
+promise_test((test) =&gt; {
+    counter = 0;
+    var gotEvent = false;
+    return new Promise((resolve, reject) =&gt; {
+        if (window.internals)
+            internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
+
+        finishTest = resolve;
+        createConnections((localConnection) =&gt; {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onopen = () =&gt; {
+                sendContinuouslyMessages(localChannel);
+                localChannel.onbufferedamountlow = () =&gt; {
+                    gotEvent = true;
+                }
+            };
+            localChannel.bufferedAmountLowThreshold = 100000;
+        }, (remoteConnection) =&gt; {
+            remoteConnection.ondatachannel = (event) =&gt; {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = receiveMessages;
+            };
+        });
+    }).then (() =&gt; {
+         return waitFor(500);
+    }).then (() =&gt; {
+        closeDataChannels();
+        assert_false(gotEvent, &quot;got onbufferedamountlow event&quot;);
+    });
+}, &quot;Medium buffer threshold not reached&quot;);
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachanneldatachanneleventexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/datachannel/datachannel-event-expected.txt (0 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/datachannel-event-expected.txt                                (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/datachannel-event-expected.txt        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Testing data channel event constructor 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachanneldatachanneleventhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/datachannel/datachannel-event.html (0 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/datachannel-event.html                                (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/datachannel-event.html        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Testing RTCDataChannelEvent&lt;/title&gt;
+    &lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+test(() =&gt; {
+    var pc = new RTCPeerConnection();
+    var channel = pc.createDataChannel(&quot;test&quot;);
+
+    assert_throws(new TypeError, () =&gt; new RTCDataChannelEvent());
+    assert_throws(new TypeError, () =&gt; new RTCDataChannelEvent(&quot;test&quot;));
+    assert_throws(new TypeError, () =&gt; new RTCDataChannelEvent(&quot;test&quot;, undefined));
+    assert_throws(new TypeError, () =&gt; new RTCDataChannelEvent(&quot;test&quot;, { channel: 1 }));
+    assert_throws(new TypeError, () =&gt; new RTCDataChannelEvent(undefined, { channel: 1 }));
+
+    var event = new RTCDataChannelEvent(&quot;test&quot;, { channel: channel });
+    assert_equals(event.channel, channel, &quot;channel passed in constructor should be used&quot;);
+    assert_equals(event.type, &quot;test&quot;);
+    assert_equals(event.isTrusted, false, &quot;trusted&quot;);
+    assert_equals(event.bubbles, false, &quot;bubble&quot;);
+    assert_equals(event.cancelable, false, &quot;cancelable&quot;);
+
+}, &quot;Testing data channel event constructor&quot;);
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcroutinesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/routines.js (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/routines.js        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/LayoutTests/webrtc/routines.js        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -2,16 +2,16 @@
</span><span class="cx"> var localConnection;
</span><span class="cx"> var remoteConnection;
</span><span class="cx"> 
</span><del>-function createConnections(setupLocalConnection, setupRemoteConnection, filterOutICECandidate) {
</del><ins>+function createConnections(setupLocalConnection, setupRemoteConnection, options = { }) {
</ins><span class="cx">     localConnection = new RTCPeerConnection();
</span><del>-    localConnection.onicecandidate = (event) =&gt; { iceCallback1(event, filterOutICECandidate) };
</del><ins>+    localConnection.onicecandidate = (event) =&gt; { iceCallback1(event, options.filterOutICECandidate) };
</ins><span class="cx">     setupLocalConnection(localConnection);
</span><span class="cx"> 
</span><span class="cx">     remoteConnection = new RTCPeerConnection();
</span><del>-    remoteConnection.onicecandidate = (event) =&gt; { iceCallback2(event, filterOutICECandidate) };
</del><ins>+    remoteConnection.onicecandidate = (event) =&gt; { iceCallback2(event, options.filterOutICECandidate) };
</ins><span class="cx">     setupRemoteConnection(remoteConnection);
</span><span class="cx"> 
</span><del>-    localConnection.createOffer().then(gotDescription1, onCreateSessionDescriptionError);
</del><ins>+    localConnection.createOffer().then((desc) =&gt; gotDescription1(desc, options), onCreateSessionDescriptionError);
</ins><span class="cx"> 
</span><span class="cx">     return [localConnection, remoteConnection]
</span><span class="cx"> }
</span><span class="lines">@@ -27,15 +27,21 @@
</span><span class="cx">     assert_unreached();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function gotDescription1(desc)
</del><ins>+function gotDescription1(desc, options)
</ins><span class="cx"> {
</span><ins>+    if (options.observeOffer)
+        options.observeOffer(desc);
+
</ins><span class="cx">     localConnection.setLocalDescription(desc);
</span><span class="cx">     remoteConnection.setRemoteDescription(desc);
</span><del>-    remoteConnection.createAnswer().then(gotDescription2, onCreateSessionDescriptionError);
</del><ins>+    remoteConnection.createAnswer().then((desc) =&gt; gotDescription2(desc, options), onCreateSessionDescriptionError);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-function gotDescription2(desc)
</del><ins>+function gotDescription2(desc, options)
</ins><span class="cx"> {
</span><ins>+    if (options.observeAnswer)
+        options.observeAnswer(desc);
+
</ins><span class="cx">     remoteConnection.setLocalDescription(desc);
</span><span class="cx">     localConnection.setRemoteDescription(desc);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-03-30  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        Clean up RTCDataChannel
+        https://bugs.webkit.org/show_bug.cgi?id=169732
+
+        Reviewed by Chris Dumez.
+
+        * runtime/CommonIdentifiers.h: Adding RTCDataChannelEvent.
+
</ins><span class="cx"> 2017-03-30  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebAssembly: pass Wasm::Context* to vmEntryToWasm when not using fast TLS
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -100,8 +100,10 @@
</span><span class="cx">     macro(ReferenceError) \
</span><span class="cx">     macro(Reflect) \
</span><span class="cx">     macro(RegExp) \
</span><ins>+    macro(Request) \
</ins><span class="cx">     macro(Response) \
</span><del>-    macro(Request) \
</del><ins>+    macro(RTCDataChannel) \
+    macro(RTCDataChannelEvent) \
</ins><span class="cx">     macro(RTCDTMFToneChangeEvent) \
</span><span class="cx">     macro(RTCIceCandidate) \
</span><span class="cx">     macro(RTCIceTransport) \
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/ChangeLog        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2017-03-30  Youenn Fablet  &lt;youenn@apple.com&gt; and Jon Lee &lt;jonlee@apple.com&gt;
+
+        Clean up RTCDataChannel
+        https://bugs.webkit.org/show_bug.cgi?id=169732
+
+        Reviewed by Chris Dumez.
+
+        Test: webrtc/datachannel/datachannel-event.html
+              webrtc/datachannel/bufferedAmountLowThreshold.html
+
+        Making RTCDataChannel interface closer to the spec updating implementation accordingly.
+        See https://w3c.github.io/webrtc-pc/#rtcdatachannel.
+        In particular adding RTCDataChannelEvent constructor, and missing bufferedAmount related attributes.
+        Doing some additional cleaning refactoring.
+
+        Making bufferedAmountIsDecreasing take a bufferedAmount argument so that we get the actual value passed by
+        libwebrtc without needing to get it from the libwebrtc network thread again.
+        In the future, we should store the bufferedAmount value in RTCDataChannel and update its value on each libwebrtc
+        OnBufferedAmountChange. Special treatment may be needed when the data channel is closed, in which case the bufferedAmount should just be
+        updated to increase in the send method.
+
+        Added some FIXMEs as RTCDataChannel is not aligned with the spec related to send and bufferedAmount.
+
+        * Modules/mediastream/RTCDataChannel.cpp:
+        (WebCore::RTCDataChannel::send):
+        (WebCore::RTCDataChannel::close):
+        (WebCore::RTCDataChannel::didChangeReadyState):
+        (WebCore::RTCDataChannel::bufferedAmountIsDecreasing):
+        * Modules/mediastream/RTCDataChannel.h:
+        * Modules/mediastream/RTCDataChannel.idl:
+        * Modules/mediastream/RTCDataChannelEvent.cpp:
+        (WebCore::RTCDataChannelEvent::create):
+        (WebCore::RTCDataChannelEvent::RTCDataChannelEvent):
+        (WebCore::RTCDataChannelEvent::channel):
+        * Modules/mediastream/RTCDataChannelEvent.h:
+        * Modules/mediastream/RTCDataChannelEvent.idl:
+        * Modules/mediastream/RTCPeerConnection.idl:
+        * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
+        (WebCore::LibWebRTCDataChannelHandler::OnStateChange):
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::addDataChannel):
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/EventNames.h:
+        * platform/mediastream/RTCDataChannelHandler.h:
+        * platform/mediastream/RTCDataChannelHandlerClient.h:
+        * platform/mediastream/RTCDataChannelState.h: Added.
+        * platform/mediastream/RTCPeerConnectionHandlerClient.h:
+        * platform/mock/RTCDataChannelHandlerMock.cpp:
+        (WebCore::RTCDataChannelHandlerMock::setClient):
+        (WebCore::RTCDataChannelHandlerMock::close):
+        * platform/mock/RTCNotifiersMock.cpp:
+        (WebCore::IceConnectionNotifier::IceConnectionNotifier):
+        (WebCore::SignalingStateNotifier::SignalingStateNotifier):
+        (WebCore::DataChannelStateNotifier::DataChannelStateNotifier):
+        * platform/mock/RTCNotifiersMock.h:
+
</ins><span class="cx"> 2017-03-30  Javier Fernandez  &lt;jfernandez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [css-align] Adapt content-alignment properties to the new baseline syntax
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCDataChannelcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -71,30 +72,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-const AtomicString&amp; RTCDataChannel::readyState() const
-{
-    static NeverDestroyed&lt;AtomicString&gt; connectingState(&quot;connecting&quot;, AtomicString::ConstructFromLiteral);
-    static NeverDestroyed&lt;AtomicString&gt; openState(&quot;open&quot;, AtomicString::ConstructFromLiteral);
-    static NeverDestroyed&lt;AtomicString&gt; closingState(&quot;closing&quot;, AtomicString::ConstructFromLiteral);
-    static NeverDestroyed&lt;AtomicString&gt; closedState(&quot;closed&quot;, AtomicString::ConstructFromLiteral);
-
-    switch (m_readyState) {
-    case ReadyStateConnecting:
-        return connectingState;
-    case ReadyStateOpen:
-        return openState;
-    case ReadyStateClosing:
-        return closingState;
-    case ReadyStateClosed:
-        return closedState;
-    }
-
-    ASSERT_NOT_REACHED();
-    return emptyAtom;
-}
-
</del><span class="cx"> size_t RTCDataChannel::bufferedAmount() const
</span><span class="cx"> {
</span><ins>+    // FIXME: We should compute our own bufferedAmount and not count on m_handler which is made null at closing time.
+    if (m_stopped)
+        return 0;
</ins><span class="cx">     return m_handler-&gt;bufferedAmount();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -124,7 +106,8 @@
</span><span class="cx"> 
</span><span class="cx"> ExceptionOr&lt;void&gt; RTCDataChannel::send(const String&amp; data)
</span><span class="cx"> {
</span><del>-    if (m_readyState != ReadyStateOpen)
</del><ins>+    // FIXME: We should only throw in Connected state.
+    if (m_readyState != RTCDataChannelState::Open)
</ins><span class="cx">         return Exception { INVALID_STATE_ERR };
</span><span class="cx"> 
</span><span class="cx">     if (!m_handler-&gt;sendStringData(data)) {
</span><span class="lines">@@ -137,7 +120,8 @@
</span><span class="cx"> 
</span><span class="cx"> ExceptionOr&lt;void&gt; RTCDataChannel::send(ArrayBuffer&amp; data)
</span><span class="cx"> {
</span><del>-    if (m_readyState != ReadyStateOpen)
</del><ins>+    // FIXME: We should only throw in Connected state.
+    if (m_readyState != RTCDataChannelState::Open)
</ins><span class="cx">         return Exception { INVALID_STATE_ERR };
</span><span class="cx"> 
</span><span class="cx">     size_t dataLength = data.byteLength();
</span><span class="lines">@@ -156,6 +140,7 @@
</span><span class="cx"> 
</span><span class="cx"> ExceptionOr&lt;void&gt; RTCDataChannel::send(ArrayBufferView&amp; data)
</span><span class="cx"> {
</span><ins>+    // FIXME: We should only throw in Connected state.
</ins><span class="cx">     return send(*data.unsharedBuffer());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -171,7 +156,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_stopped = true;
</span><del>-    m_readyState = ReadyStateClosed;
</del><ins>+    m_readyState = RTCDataChannelState::Closed;
</ins><span class="cx"> 
</span><span class="cx">     m_handler-&gt;close();
</span><span class="cx">     m_handler-&gt;setClient(nullptr);
</span><span class="lines">@@ -179,18 +164,18 @@
</span><span class="cx">     unsetPendingActivity(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RTCDataChannel::didChangeReadyState(ReadyState newState)
</del><ins>+void RTCDataChannel::didChangeReadyState(RTCDataChannelState newState)
</ins><span class="cx"> {
</span><del>-    if (m_stopped || m_readyState == ReadyStateClosed || m_readyState == newState)
</del><ins>+    if (m_stopped || m_readyState == RTCDataChannelState::Closed || m_readyState == newState)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_readyState = newState;
</span><span class="cx"> 
</span><span class="cx">     switch (m_readyState) {
</span><del>-    case ReadyStateOpen:
</del><ins>+    case RTCDataChannelState::Open:
</ins><span class="cx">         scheduleDispatchEvent(Event::create(eventNames().openEvent, false, false));
</span><span class="cx">         break;
</span><del>-    case ReadyStateClosed:
</del><ins>+    case RTCDataChannelState::Closed:
</ins><span class="cx">         scheduleDispatchEvent(Event::create(eventNames().closeEvent, false, false));
</span><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="lines">@@ -231,13 +216,13 @@
</span><span class="cx">     scheduleDispatchEvent(Event::create(eventNames().errorEvent, false, false));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RTCDataChannel::bufferedAmountIsDecreasing()
</del><ins>+void RTCDataChannel::bufferedAmountIsDecreasing(size_t amount)
</ins><span class="cx"> {
</span><span class="cx">     if (m_stopped)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (bufferedAmount() &lt;= m_bufferedAmountLowThreshold)
-        scheduleDispatchEvent(Event::create(eventNames().bufferedAmountLowThresholdEvent, false, false));
</del><ins>+    if (amount &lt;= m_bufferedAmountLowThreshold)
+        scheduleDispatchEvent(Event::create(eventNames().bufferedamountlowEvent, false, false));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RTCDataChannel::stop()
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCDataChannelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -57,7 +58,7 @@
</span><span class="cx">     std::optional&lt;unsigned short&gt; id() const { return m_options.id; };
</span><span class="cx"> 
</span><span class="cx">     String label() const { return m_label; }
</span><del>-    const AtomicString&amp; readyState() const;
</del><ins>+    RTCDataChannelState readyState() const {return m_readyState; }
</ins><span class="cx">     size_t bufferedAmount() const;
</span><span class="cx">     size_t bufferedAmountLowThreshold() const { return m_bufferedAmountLowThreshold; }
</span><span class="cx">     void setBufferedAmountLowThreshold(size_t value) { m_bufferedAmountLowThreshold = value; }
</span><span class="lines">@@ -90,21 +91,21 @@
</span><span class="cx">     // ActiveDOMObject API
</span><span class="cx">     void stop() final;
</span><span class="cx">     const char* activeDOMObjectName() const final { return &quot;RTCDataChannel&quot;; }
</span><del>-    bool canSuspendForDocumentSuspension() const final { return m_readyState == ReadyStateClosed; }
</del><ins>+    bool canSuspendForDocumentSuspension() const final { return m_readyState == RTCDataChannelState::Closed; }
</ins><span class="cx"> 
</span><span class="cx">     // RTCDataChannelHandlerClient API
</span><del>-    void didChangeReadyState(ReadyState) final;
</del><ins>+    void didChangeReadyState(RTCDataChannelState) final;
</ins><span class="cx">     void didReceiveStringData(const String&amp;) final;
</span><span class="cx">     void didReceiveRawData(const char*, size_t) final;
</span><span class="cx">     void didDetectError() final;
</span><del>-    void bufferedAmountIsDecreasing() final;
</del><ins>+    void bufferedAmountIsDecreasing(size_t) final;
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;RTCDataChannelHandler&gt; m_handler;
</span><span class="cx"> 
</span><ins>+    // FIXME: m_stopped is probably redundant with m_readyState.
</ins><span class="cx">     bool m_stopped { false };
</span><ins>+    RTCDataChannelState m_readyState { RTCDataChannelState::Connecting };
</ins><span class="cx"> 
</span><del>-    ReadyState m_readyState { ReadyStateConnecting };
-
</del><span class="cx">     enum class BinaryType { Blob, ArrayBuffer };
</span><span class="cx">     BinaryType m_binaryType { BinaryType::ArrayBuffer };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCDataChannelidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -25,17 +26,20 @@
</span><span class="cx"> [
</span><span class="cx">     ActiveDOMObject,
</span><span class="cx">     Conditional=WEB_RTC,
</span><del>-    NoInterfaceObject,
</del><ins>+    EnabledAtRuntime=PeerConnection,
</ins><span class="cx"> ] interface RTCDataChannel : EventTarget {
</span><del>-    readonly attribute DOMString label;
</del><ins>+    // FIXME: Add support for priority attribute.
+
+    readonly attribute USVString label;
</ins><span class="cx">     readonly attribute boolean ordered;
</span><span class="cx">     readonly attribute unsigned short? maxPacketLifeTime;
</span><span class="cx">     readonly attribute unsigned short? maxRetransmits;
</span><del>-    readonly attribute DOMString protocol;
</del><ins>+    readonly attribute USVString protocol;
</ins><span class="cx">     readonly attribute boolean negotiated;
</span><span class="cx">     readonly attribute unsigned short? id;
</span><del>-    readonly attribute DOMString readyState;
</del><ins>+    readonly attribute RTCDataChannelState readyState;
</ins><span class="cx">     readonly attribute unsigned long bufferedAmount;
</span><ins>+    attribute unsigned long bufferedAmountLowThreshold;
</ins><span class="cx"> 
</span><span class="cx">     [SetterMayThrowException] attribute DOMString binaryType;
</span><span class="cx"> 
</span><span class="lines">@@ -42,7 +46,7 @@
</span><span class="cx">     [MayThrowException] void send(ArrayBuffer data);
</span><span class="cx">     [MayThrowException] void send(ArrayBufferView data);
</span><span class="cx">     [MayThrowException] void send(Blob data);
</span><del>-    [MayThrowException] void send(DOMString data);
</del><ins>+    [MayThrowException] void send(USVString data);
</ins><span class="cx"> 
</span><span class="cx">     void close();
</span><span class="cx"> 
</span><span class="lines">@@ -50,4 +54,16 @@
</span><span class="cx">     attribute EventHandler onerror;
</span><span class="cx">     attribute EventHandler onclose;
</span><span class="cx">     attribute EventHandler onmessage;
</span><ins>+    attribute EventHandler onbufferedamountlow;
</ins><span class="cx"> };
</span><ins>+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+    ImplementedAs=RTCDataChannelState
+] enum RTCDataChannelState {
+    &quot;connecting&quot;,
+    &quot;open&quot;,
+    &quot;closing&quot;,
+    &quot;closed&quot;
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCDataChannelEventcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.cpp        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -36,6 +37,11 @@
</span><span class="cx">     return adoptRef(*new RTCDataChannelEvent(type, canBubble, cancelable, WTFMove(channel)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Ref&lt;RTCDataChannelEvent&gt; RTCDataChannelEvent::create(const AtomicString&amp; type, Init&amp;&amp; initializer, IsTrusted isTrusted)
+{
+    return adoptRef(*new RTCDataChannelEvent(type, WTFMove(initializer), isTrusted));
+}
+
</ins><span class="cx"> RTCDataChannelEvent::RTCDataChannelEvent(const AtomicString&amp; type, bool canBubble, bool cancelable, Ref&lt;RTCDataChannel&gt;&amp;&amp; channel)
</span><span class="cx">     : Event(type, canBubble, cancelable)
</span><span class="cx">     , m_channel(WTFMove(channel))
</span><span class="lines">@@ -42,11 +48,17 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RTCDataChannel* RTCDataChannelEvent::channel()
</del><ins>+RTCDataChannelEvent::RTCDataChannelEvent(const AtomicString&amp; type, Init&amp;&amp; initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
+    , m_channel(initializer.channel.releaseNonNull())
</ins><span class="cx"> {
</span><del>-    return m_channel.ptr();
</del><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RTCDataChannel&amp; RTCDataChannelEvent::channel()
+{
+    return m_channel.get();
+}
+
</ins><span class="cx"> EventInterface RTCDataChannelEvent::eventInterface() const
</span><span class="cx"> {
</span><span class="cx">     return RTCDataChannelEventInterfaceType;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCDataChannelEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -32,16 +33,22 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class RTCDataChannelEvent : public Event {
</del><ins>+class RTCDataChannelEvent final : public Event {
</ins><span class="cx"> public:
</span><ins>+    struct Init : EventInit {
+        RefPtr&lt;RTCDataChannel&gt; channel;
+    };
+
</ins><span class="cx">     static Ref&lt;RTCDataChannelEvent&gt; create(const AtomicString&amp; type, bool canBubble, bool cancelable, Ref&lt;RTCDataChannel&gt;&amp;&amp;);
</span><ins>+    static Ref&lt;RTCDataChannelEvent&gt; create(const AtomicString&amp; type, Init&amp;&amp;, IsTrusted = IsTrusted::No);
</ins><span class="cx"> 
</span><del>-    RTCDataChannel* channel();
</del><ins>+    RTCDataChannel&amp; channel();
</ins><span class="cx"> 
</span><span class="cx">     virtual EventInterface eventInterface() const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     RTCDataChannelEvent(const AtomicString&amp; type, bool canBubble, bool cancelable, Ref&lt;RTCDataChannel&gt;&amp;&amp;);
</span><ins>+    RTCDataChannelEvent(const AtomicString&amp; type, Init&amp;&amp;, IsTrusted);
</ins><span class="cx"> 
</span><span class="cx">     Ref&lt;RTCDataChannel&gt; m_channel;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCDataChannelEventidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.idl (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.idl        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannelEvent.idl        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -23,11 +23,14 @@
</span><span class="cx">  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-// FIXME 169662: missing Constructor(DOMString type, RTCDataChannelEventInit eventInitDict)
</del><span class="cx"> [
</span><del>-    NoInterfaceObject,
</del><span class="cx">     Conditional=WEB_RTC,
</span><del>-    EnabledAtRuntime=PeerConnection
</del><ins>+    Constructor(DOMString type, RTCDataChannelEventInit eventInitDict),
+    EnabledAtRuntime=PeerConnection,
</ins><span class="cx"> ] interface RTCDataChannelEvent : Event {
</span><span class="cx">     readonly attribute RTCDataChannel channel;
</span><span class="cx"> };
</span><ins>+
+dictionary RTCDataChannelEventInit : EventInit {
+    required RTCDataChannel channel;
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamRTCPeerConnectionidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">     unsigned short maxRetransmits;
</span><span class="cx">     USVString protocol = &quot;&quot;;
</span><span class="cx">     boolean negotiated = false;
</span><del>-    unsigned short id;
</del><ins>+    [EnforceRange] unsigned short id;
</ins><span class="cx">     // FIXME 169644: missing priority
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCDataChannelHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -64,19 +64,19 @@
</span><span class="cx"> 
</span><span class="cx"> void LibWebRTCDataChannelHandler::OnStateChange()
</span><span class="cx"> {
</span><del>-    RTCDataChannel::ReadyState state;
</del><ins>+    RTCDataChannelState state;
</ins><span class="cx">     switch (m_channel-&gt;state()) {
</span><span class="cx">     case webrtc::DataChannelInterface::kConnecting:
</span><del>-        state = RTCDataChannel::ReadyStateConnecting;
</del><ins>+        state = RTCDataChannelState::Connecting;
</ins><span class="cx">         break;
</span><span class="cx">     case webrtc::DataChannelInterface::kOpen:
</span><del>-        state = RTCDataChannel::ReadyStateOpen;
</del><ins>+        state = RTCDataChannelState::Open;
</ins><span class="cx">         break;
</span><span class="cx">     case webrtc::DataChannelInterface::kClosing:
</span><del>-        state = RTCDataChannel::ReadyStateClosing;
</del><ins>+        state = RTCDataChannelState::Closing;
</ins><span class="cx">         break;
</span><span class="cx">     case webrtc::DataChannelInterface::kClosed:
</span><del>-        state = RTCDataChannel::ReadyStateClosed;
</del><ins>+        state = RTCDataChannelState::Closed;
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     ASSERT(m_client);
</span><span class="lines">@@ -104,8 +104,8 @@
</span><span class="cx">     if (previousAmount &lt;= m_channel-&gt;buffered_amount())
</span><span class="cx">         return;
</span><span class="cx">     ASSERT(m_client);
</span><del>-    callOnMainThread([protectedClient = makeRef(*m_client)] {
-        protectedClient-&gt;bufferedAmountIsDecreasing();
</del><ins>+    callOnMainThread([protectedClient = makeRef(*m_client), amount = m_channel-&gt;buffered_amount()] {
+        protectedClient-&gt;bufferedAmountIsDecreasing(static_cast&lt;size_t&gt;(amount));
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCMediaEndpointcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -600,7 +600,7 @@
</span><span class="cx">         callOnMainThread([channel = channel.copyRef()] {
</span><span class="cx">             // FIXME: We should be able to write channel-&gt;didChangeReadyState(...)
</span><span class="cx">             RTCDataChannelHandlerClient&amp; client = channel.get();
</span><del>-            client.didChangeReadyState(RTCDataChannel::ReadyStateOpen);
</del><ins>+            client.didChangeReadyState(RTCDataChannelState::Open);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1439,6 +1439,7 @@
</span><span class="cx">                 316DCB4F1E7910A6001B5F87 /* JSRTCSignalingState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316DCB491E7910A6001B5F87 /* JSRTCSignalingState.cpp */; };
</span><span class="cx">                 316DCB501E7910A6001B5F87 /* JSRTCSignalingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 316DCB4A1E7910A6001B5F87 /* JSRTCSignalingState.h */; };
</span><span class="cx">                 316DCB8A1E7A6996001B5F87 /* RTCIceTransport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316DCB881E7A6996001B5F87 /* RTCIceTransport.cpp */; };
</span><ins>+                316DE7021E83AE1D0084C261 /* RTCDataChannelState.h in Headers */ = {isa = PBXBuildFile; fileRef = 316DE7011E83AE1D0084C261 /* RTCDataChannelState.h */; };
</ins><span class="cx">                 316FE0710E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */; };
</span><span class="cx">                 316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */; };
</span><span class="cx">                 316FE0730E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06F0E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp */; };
</span><span class="lines">@@ -8961,6 +8962,7 @@
</span><span class="cx">                 316DCB881E7A6996001B5F87 /* RTCIceTransport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCIceTransport.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 316DCB891E7A6996001B5F87 /* RTCIceTransport.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCIceTransport.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 316DCB8E1E7A6C79001B5F87 /* RTCIceTransportState.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCIceTransportState.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                316DE7011E83AE1D0084C261 /* RTCDataChannelState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCDataChannelState.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframeRule.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSKeyframeRule.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 316FE06F0E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframesRule.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16033,6 +16035,7 @@
</span><span class="cx">                                 3135910C1E7DDCB600F30630 /* RTCBundlePolicy.h */,
</span><span class="cx">                                 07221BA217CF0AD400848E51 /* RTCDataChannelHandler.h */,
</span><span class="cx">                                 07221BA317CF0AD400848E51 /* RTCDataChannelHandlerClient.h */,
</span><ins>+                                316DE7011E83AE1D0084C261 /* RTCDataChannelState.h */,
</ins><span class="cx">                                 07221BA417CF0AD400848E51 /* RTCDTMFSenderHandler.h */,
</span><span class="cx">                                 07221BA517CF0AD400848E51 /* RTCDTMFSenderHandlerClient.h */,
</span><span class="cx">                                 07221BA617CF0AD400848E51 /* RTCIceCandidateDescriptor.cpp */,
</span><span class="lines">@@ -26808,6 +26811,7 @@
</span><span class="cx">                                 FC9A0F75164094CF003D6B8D /* DOMCSSNamespace.h in Headers */,
</span><span class="cx">                                 9B3A8872145632F9003AE8F5 /* DOMDOMSettableTokenList.h in Headers */,
</span><span class="cx">                                 7AABA25A14BC613300AA9A11 /* DOMEditor.h in Headers */,
</span><ins>+                                316DE7021E83AE1D0084C261 /* RTCDataChannelState.h in Headers */,
</ins><span class="cx">                                 BC1BDF25156C18C7001C1243 /* DOMError.h in Headers */,
</span><span class="cx">                                 2ED609BD1145B07100C8684E /* DOMFormData.h in Headers */,
</span><span class="cx">                                 A8185F3B09765766005826D9 /* DOMImplementation.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/EventNames.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/EventNames.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/dom/EventNames.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">     macro(blocked) \
</span><span class="cx">     macro(blur) \
</span><span class="cx">     macro(boundary) \
</span><del>-    macro(bufferedAmountLowThreshold) \
</del><ins>+    macro(bufferedamountlow) \
</ins><span class="cx">     macro(cached) \
</span><span class="cx">     macro(cancel) \
</span><span class="cx">     macro(canplay) \
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRTCDataChannelHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRTCDataChannelHandlerClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandlerClient.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_RTC)
</span><span class="cx"> 
</span><ins>+#include &quot;RTCDataChannelState.h&quot;
</ins><span class="cx"> #include &lt;wtf/ThreadSafeRefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -33,20 +35,13 @@
</span><span class="cx"> 
</span><span class="cx"> class RTCDataChannelHandlerClient : public ThreadSafeRefCounted&lt;RTCDataChannelHandlerClient&gt; {
</span><span class="cx"> public:
</span><del>-    enum ReadyState {
-        ReadyStateConnecting = 0,
-        ReadyStateOpen = 1,
-        ReadyStateClosing = 2,
-        ReadyStateClosed = 3,
-    };
-
</del><span class="cx">     virtual ~RTCDataChannelHandlerClient() { }
</span><span class="cx"> 
</span><del>-    virtual void didChangeReadyState(ReadyState) = 0;
</del><ins>+    virtual void didChangeReadyState(RTCDataChannelState) = 0;
</ins><span class="cx">     virtual void didReceiveStringData(const String&amp;) = 0;
</span><span class="cx">     virtual void didReceiveRawData(const char*, size_t) = 0;
</span><span class="cx">     virtual void didDetectError() = 0;
</span><del>-    virtual void bufferedAmountIsDecreasing() = 0;
</del><ins>+    virtual void bufferedAmountIsDecreasing(size_t) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRTCDataChannelStateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/RTCDataChannelState.h (0 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelState.h                                (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelState.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * 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 ENABLE(WEB_RTC)
+
+namespace WebCore {
+
+enum class RTCDataChannelState {
+    Connecting,
+    Open,
+    Closing,
+    Closed
+};
+
+}; // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRTCPeerConnectionHandlerClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandlerClient.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -33,6 +33,9 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_RTC)
</span><span class="cx"> 
</span><ins>+#include &quot;RTCIceConnectionState.h&quot;
+#include &quot;RTCIceGatheringState.h&quot;
+#include &quot;RTCSignalingState.h&quot;
</ins><span class="cx"> #include &lt;wtf/PassRefPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -43,38 +46,13 @@
</span><span class="cx"> 
</span><span class="cx"> class RTCPeerConnectionHandlerClient {
</span><span class="cx"> public:
</span><del>-    enum SignalingState {
-        SignalingStateStable = 1,
-        SignalingStateHaveLocalOffer = 2,
-        SignalingStateHaveRemoteOffer = 3,
-        SignalingStateHaveLocalPrAnswer = 4,
-        SignalingStateHaveRemotePrAnswer = 5,
-        SignalingStateClosed = 6,
-    };
-
-    enum IceConnectionState {
-        IceConnectionStateNew = 1,
-        IceConnectionStateChecking = 2,
-        IceConnectionStateConnected = 3,
-        IceConnectionStateCompleted = 4,
-        IceConnectionStateFailed = 5,
-        IceConnectionStateDisconnected = 6,
-        IceConnectionStateClosed = 7
-    };
-
-    enum IceGatheringState {
-        IceGatheringStateNew = 1,
-        IceGatheringStateGathering = 2,
-        IceGatheringStateComplete = 3
-    };
-
</del><span class="cx">     virtual ~RTCPeerConnectionHandlerClient() { }
</span><span class="cx"> 
</span><span class="cx">     virtual void negotiationNeeded() = 0;
</span><span class="cx">     virtual void didGenerateIceCandidate(PassRefPtr&lt;RTCIceCandidateDescriptor&gt;) = 0;
</span><del>-    virtual void didChangeSignalingState(SignalingState) = 0;
-    virtual void didChangeIceGatheringState(IceGatheringState) = 0;
-    virtual void didChangeIceConnectionState(IceConnectionState) = 0;
</del><ins>+    virtual void didChangeSignalingState(RTCSignalingState) = 0;
+    virtual void didChangeIceGatheringState(RTCIceGatheringState) = 0;
+    virtual void didChangeIceConnectionState(RTCIceConnectionState) = 0;
</ins><span class="cx">     virtual void didAddRemoteStream(PassRefPtr&lt;MediaStreamPrivate&gt;) = 0;
</span><span class="cx">     virtual void didRemoveRemoteStream(MediaStreamPrivate*) = 0;
</span><span class="cx">     virtual void didAddRemoteDataChannel(std::unique_ptr&lt;RTCDataChannelHandler&gt;) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockRTCDataChannelHandlerMockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/platform/mock/RTCDataChannelHandlerMock.cpp        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><del>- *  Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
</del><ins>+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -24,11 +25,10 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><ins>+#include &quot;RTCDataChannelHandlerMock.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_RTC)
</span><span class="cx"> 
</span><del>-#include &quot;RTCDataChannelHandlerMock.h&quot;
-
</del><span class="cx"> #include &quot;RTCDataChannelHandlerClient.h&quot;
</span><span class="cx"> #include &quot;RTCNotifiersMock.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -46,8 +46,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_client = client;
</span><del>-    RefPtr&lt;DataChannelStateNotifier&gt; notifier = adoptRef(new DataChannelStateNotifier(m_client, RTCDataChannelHandlerClient::ReadyStateOpen));
-    m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
</del><ins>+    auto notifier = adoptRef(*new DataChannelStateNotifier(m_client, RTCDataChannelState::Open));
+    m_timerEvents.append(adoptRef(new TimerEvent(this, WTFMove(notifier))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RTCDataChannelHandlerMock::sendStringData(const String&amp; string)
</span><span class="lines">@@ -64,8 +64,8 @@
</span><span class="cx"> 
</span><span class="cx"> void RTCDataChannelHandlerMock::close()
</span><span class="cx"> {
</span><del>-    RefPtr&lt;DataChannelStateNotifier&gt; notifier = adoptRef(new DataChannelStateNotifier(m_client, RTCDataChannelHandlerClient::ReadyStateClosed));
-    m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
</del><ins>+    auto notifier = adoptRef(*new DataChannelStateNotifier(m_client, RTCDataChannelState::Closed));
+    m_timerEvents.append(adoptRef(new TimerEvent(this, WTFMove(notifier))));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockRTCNotifiersMockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/platform/mock/RTCNotifiersMock.cpp        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><del>- *  Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
</del><ins>+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -67,7 +68,7 @@
</span><span class="cx">         m_request-&gt;requestFailed(m_errorName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IceConnectionNotifier::IceConnectionNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::IceConnectionState connectionState, RTCPeerConnectionHandlerClient::IceGatheringState gatheringState)
</del><ins>+IceConnectionNotifier::IceConnectionNotifier(RTCPeerConnectionHandlerClient* client, RTCIceConnectionState connectionState, RTCIceGatheringState gatheringState)
</ins><span class="cx">     : m_client(client)
</span><span class="cx">     , m_connectionState(connectionState)
</span><span class="cx">     , m_gatheringState(gatheringState)
</span><span class="lines">@@ -80,7 +81,7 @@
</span><span class="cx">     m_client-&gt;didChangeIceConnectionState(m_connectionState);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SignalingStateNotifier::SignalingStateNotifier(RTCPeerConnectionHandlerClient* client, RTCPeerConnectionHandlerClient::SignalingState signalingState)
</del><ins>+SignalingStateNotifier::SignalingStateNotifier(RTCPeerConnectionHandlerClient* client, RTCSignalingState signalingState)
</ins><span class="cx">     : m_client(client)
</span><span class="cx">     , m_signalingState(signalingState)
</span><span class="cx"> {
</span><span class="lines">@@ -101,7 +102,7 @@
</span><span class="cx">     m_client-&gt;didAddRemoteDataChannel(std::make_unique&lt;RTCDataChannelHandlerMock&gt;(&quot;RTCDataChannelHandlerMock&quot;, RTCDataChannelInit()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DataChannelStateNotifier::DataChannelStateNotifier(RTCDataChannelHandlerClient* client, RTCDataChannelHandlerClient::ReadyState state)
</del><ins>+DataChannelStateNotifier::DataChannelStateNotifier(RTCDataChannelHandlerClient* client, RTCDataChannelState state)
</ins><span class="cx">     : m_client(client)
</span><span class="cx">     , m_state(state)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockRTCNotifiersMockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h (214626 => 214627)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h        2017-03-30 21:35:39 UTC (rev 214626)
+++ trunk/Source/WebCore/platform/mock/RTCNotifiersMock.h        2017-03-30 21:42:19 UTC (rev 214627)
</span><span class="lines">@@ -67,25 +67,25 @@
</span><span class="cx"> 
</span><span class="cx"> class IceConnectionNotifier : public MockNotifier {
</span><span class="cx"> public:
</span><del>-    IceConnectionNotifier(RTCPeerConnectionHandlerClient*, RTCPeerConnectionHandlerClient::IceConnectionState, RTCPeerConnectionHandlerClient::IceGatheringState);
</del><ins>+    IceConnectionNotifier(RTCPeerConnectionHandlerClient*, RTCIceConnectionState, RTCIceGatheringState);
</ins><span class="cx"> 
</span><span class="cx">     void fire() override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     RTCPeerConnectionHandlerClient* m_client;
</span><del>-    RTCPeerConnectionHandlerClient::IceConnectionState m_connectionState;
-    RTCPeerConnectionHandlerClient::IceGatheringState m_gatheringState;
</del><ins>+    RTCIceConnectionState m_connectionState;
+    RTCIceGatheringState m_gatheringState;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class SignalingStateNotifier : public MockNotifier {
</span><span class="cx"> public:
</span><del>-    SignalingStateNotifier(RTCPeerConnectionHandlerClient*, RTCPeerConnectionHandlerClient::SignalingState);
</del><ins>+    SignalingStateNotifier(RTCPeerConnectionHandlerClient*, RTCSignalingState);
</ins><span class="cx"> 
</span><span class="cx">     void fire() override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     RTCPeerConnectionHandlerClient* m_client;
</span><del>-    RTCPeerConnectionHandlerClient::SignalingState m_signalingState;
</del><ins>+    RTCSignalingState m_signalingState;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class RemoteDataChannelNotifier : public MockNotifier {
</span><span class="lines">@@ -100,13 +100,13 @@
</span><span class="cx"> 
</span><span class="cx"> class DataChannelStateNotifier : public MockNotifier {
</span><span class="cx"> public:
</span><del>-    DataChannelStateNotifier(RTCDataChannelHandlerClient*, RTCDataChannelHandlerClient::ReadyState);
</del><ins>+    DataChannelStateNotifier(RTCDataChannelHandlerClient*, RTCDataChannelState);
</ins><span class="cx"> 
</span><span class="cx">     void fire() override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     RTCDataChannelHandlerClient* m_client;
</span><del>-    RTCDataChannelHandlerClient::ReadyState m_state;
</del><ins>+    RTCDataChannelState m_state;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>