Changeset 155794 in webkit
- Timestamp:
- Sep 14, 2013 7:25:14 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r155767 r155794 1 2013-09-14 Eric Carlson <eric.carlson@apple.com> 2 3 MediaStream API: Update RTCDataChannel 4 https://bugs.webkit.org/show_bug.cgi?id=121102 5 6 Reviewed by Sam Weinig. 7 8 * fast/mediastream/RTCPeerConnection-datachannel-expected.txt: 9 * fast/mediastream/RTCPeerConnection-datachannel.html: 10 1 11 2013-09-14 Zan Dobersek <zdobersek@igalia.com> 2 12 -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel-expected.txt
r140310 r155794 8 8 PASS dc = pc.createDataChannel("label2", {}); did not throw exception. 9 9 PASS dc.reliable is true 10 PASS dc = pc.createDataChannel("label3", { reliable:true}); did not throw exception.10 PASS dc = pc.createDataChannel("label3", {ordered:true}); did not throw exception. 11 11 PASS dc.reliable is true 12 PASS dc = pc.createDataChannel("label3", {reliable:false}); did not throw exception. 12 PASS dc = pc.createDataChannel("label3", {ordered:false}); did not throw exception. 13 PASS dc.reliable is false 14 PASS dc = pc.createDataChannel("label3", {maxRetransmits:0}); did not throw exception. 15 PASS dc.reliable is false 16 PASS dc = pc.createDataChannel("label3", {maxRetransmitTime:0}); did not throw exception. 13 17 PASS dc.reliable is false 14 18 PASS pc is connected -
trunk/LayoutTests/fast/mediastream/RTCPeerConnection-datachannel.html
r155270 r155794 87 87 shouldNotThrow('dc = pc.createDataChannel("label2", {});'); 88 88 shouldBe("dc.reliable", "true"); 89 shouldNotThrow('dc = pc.createDataChannel("label3", { reliable:true});');89 shouldNotThrow('dc = pc.createDataChannel("label3", {ordered:true});'); 90 90 shouldBe("dc.reliable", "true"); 91 shouldNotThrow('dc = pc.createDataChannel("label3", {reliable:false});'); 91 shouldNotThrow('dc = pc.createDataChannel("label3", {ordered:false});'); 92 shouldBe("dc.reliable", "false"); 93 shouldNotThrow('dc = pc.createDataChannel("label3", {maxRetransmits:0});'); 94 shouldBe("dc.reliable", "false"); 95 shouldNotThrow('dc = pc.createDataChannel("label3", {maxRetransmitTime:0});'); 92 96 shouldBe("dc.reliable", "false"); 93 97 -
trunk/Source/WebCore/ChangeLog
r155792 r155794 1 2013-09-14 Eric Carlson <eric.carlson@apple.com> 2 3 MediaStream API: Update RTCDataChannel 4 https://bugs.webkit.org/show_bug.cgi?id=121102 5 6 Reviewed by Sam Weinig. 7 8 Based on https://chromium.googlesource.com/chromium/blink/+/c6975c41956acded7cf0363012d7d6b69d0c6d96, 9 and https://chromium.googlesource.com/chromium/blink/+/214dab0bd6385f573c918ba5ce58a5aa206ce186. 10 11 No new tests, existing tests updated. 12 13 * Modules/mediastream/RTCDataChannel.cpp: 14 (WebCore::RTCDataChannel::create): Take an options Dictionary. 15 (WebCore::RTCDataChannel::didChangeReadyState): String -> AtomicString. Early return if the 16 state hasn't changed. 17 (WebCore::RTCDataChannel::binaryType): String -> AtomicString. 18 (WebCore::RTCDataChannel::setBinaryType): String -> AtomicString. 19 * Modules/mediastream/RTCDataChannel.h: 20 * Modules/mediastream/RTCDataChannel.idl: 21 22 * Modules/mediastream/RTCPeerConnection.cpp: 23 (WebCore::RTCPeerConnection::createDataChannel): Take an options struct. 24 * platform/mediastream/RTCDataChannelHandler.h: 25 26 * platform/mediastream/RTCPeerConnectionHandler.h: 27 (WebCore::RTCDataChannelInit::RTCDataChannelInit): Take an options struct. 28 1 29 2013-09-14 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org> 2 30 -
trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp
r155792 r155794 30 30 31 31 #include "Blob.h" 32 #include "Dictionary.h" 32 33 #include "Event.h" 33 34 #include "ExceptionCode.h" … … 38 39 #include <runtime/ArrayBuffer.h> 39 40 #include <runtime/ArrayBufferView.h> 41 #include <wtf/NeverDestroyed.h> 40 42 41 43 namespace WebCore { 42 44 43 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* peerConnectionHandler, const String& label, bool reliable, ExceptionCode& ec) 44 { 45 OwnPtr<RTCDataChannelHandler> handler = peerConnectionHandler->createDataChannel(label, reliable); 45 static const AtomicString& blobKeyword() 46 { 47 static NeverDestroyed<AtomicString> blob("blob", AtomicString::ConstructFromLiteral); 48 return blob; 49 } 50 51 static const AtomicString& arraybufferKeyword() 52 { 53 static NeverDestroyed<AtomicString> arraybuffer("arraybuffer", AtomicString::ConstructFromLiteral); 54 return arraybuffer; 55 } 56 57 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* context, RTCPeerConnectionHandler* peerConnectionHandler, const String& label, const Dictionary& options, ExceptionCode& ec) 58 { 59 RTCDataChannelInit initData; 60 options.get("ordered", initData.ordered); 61 options.get("negotiated", initData.negotiated); 62 options.get("id", initData.id); 63 options.get("maxRetransmits", initData.maxRetransmits); 64 options.get("maxRetransmitTime", initData.maxRetransmitTime); 65 options.get("protocol", initData.protocol); 66 67 OwnPtr<RTCDataChannelHandler> handler = peerConnectionHandler->createDataChannel(label, initData); 46 68 if (!handler) { 47 69 ec = NOT_SUPPORTED_ERR; … … 107 129 } 108 130 109 String RTCDataChannel::readyState() const 110 { 131 AtomicString RTCDataChannel::readyState() const 132 { 133 static NeverDestroyed<AtomicString> connectingState("connecting", AtomicString::ConstructFromLiteral); 134 static NeverDestroyed<AtomicString> openState("open", AtomicString::ConstructFromLiteral); 135 static NeverDestroyed<AtomicString> closingState("closing", AtomicString::ConstructFromLiteral); 136 static NeverDestroyed<AtomicString> closedState("closed", AtomicString::ConstructFromLiteral); 137 111 138 switch (m_readyState) { 112 139 case ReadyStateConnecting: 113 return ASCIILiteral("connecting");140 return connectingState; 114 141 case ReadyStateOpen: 115 return ASCIILiteral("open");142 return openState; 116 143 case ReadyStateClosing: 117 return ASCIILiteral("closing");144 return closingState; 118 145 case ReadyStateClosed: 119 return ASCIILiteral("closed");146 return closedState; 120 147 } 121 148 122 149 ASSERT_NOT_REACHED(); 123 return String();150 return emptyAtom; 124 151 } 125 152 … … 129 156 } 130 157 131 String RTCDataChannel::binaryType() const158 AtomicString RTCDataChannel::binaryType() const 132 159 { 133 160 switch (m_binaryType) { 134 161 case BinaryTypeBlob: 135 return ASCIILiteral("blob");162 return blobKeyword(); 136 163 case BinaryTypeArrayBuffer: 137 return ASCIILiteral("arraybuffer"); 138 } 164 return arraybufferKeyword(); 165 } 166 139 167 ASSERT_NOT_REACHED(); 140 return String();141 } 142 143 void RTCDataChannel::setBinaryType(const String& binaryType, ExceptionCode& ec)144 { 145 if (binaryType == "blob")168 return emptyAtom; 169 } 170 171 void RTCDataChannel::setBinaryType(const AtomicString& binaryType, ExceptionCode& ec) 172 { 173 if (binaryType == blobKeyword()) 146 174 ec = NOT_SUPPORTED_ERR; 147 else if (binaryType == "arraybuffer")175 else if (binaryType == arraybufferKeyword()) 148 176 m_binaryType = BinaryTypeArrayBuffer; 149 177 else … … 157 185 return; 158 186 } 187 159 188 if (!m_handler->sendStringData(data)) { 160 189 // FIXME: Decide what the right exception here is. … … 206 235 void RTCDataChannel::didChangeReadyState(ReadyState newState) 207 236 { 208 if (m_stopped || m_readyState == ReadyStateClosed )237 if (m_stopped || m_readyState == ReadyStateClosed || m_readyState == newState) 209 238 return; 210 239 … … 240 269 return; 241 270 } 271 242 272 if (m_binaryType == BinaryTypeArrayBuffer) { 243 273 RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(data, dataLength); -
trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h
r155792 r155794 35 35 36 36 namespace JSC { 37 class ArrayBuffer;38 class ArrayBufferView;37 class ArrayBuffer; 38 class ArrayBufferView; 39 39 } 40 40 … … 42 42 43 43 class Blob; 44 class Dictionary; 44 45 class RTCDataChannelHandler; 45 46 class RTCPeerConnectionHandler; … … 47 48 class RTCDataChannel : public RefCounted<RTCDataChannel>, public ScriptWrappable, public EventTarget, public RTCDataChannelHandlerClient { 48 49 public: 49 static PassRefPtr<RTCDataChannel> create(ScriptExecutionContext*, RTCPeerConnectionHandler*, const String& label, bool reliable, ExceptionCode&);50 50 static PassRefPtr<RTCDataChannel> create(ScriptExecutionContext*, PassOwnPtr<RTCDataChannelHandler>); 51 static PassRefPtr<RTCDataChannel> create(ScriptExecutionContext*, RTCPeerConnectionHandler*, const String& , const Dictionary&, ExceptionCode&); 51 52 ~RTCDataChannel(); 52 53 … … 58 59 bool negotiated() const; 59 60 unsigned short id() const; 60 String readyState() const;61 AtomicString readyState() const; 61 62 unsigned long bufferedAmount() const; 62 63 63 String binaryType() const;64 void setBinaryType(const String&, ExceptionCode&);64 AtomicString binaryType() const; 65 void setBinaryType(const AtomicString&, ExceptionCode&); 65 66 66 67 void send(const String&, ExceptionCode&); … … 96 97 virtual void refEventTarget() OVERRIDE { ref(); } 97 98 virtual void derefEventTarget() OVERRIDE { deref(); } 99 98 100 EventTargetData m_eventTargetData; 99 101 ScriptExecutionContext* m_scriptExecutionContext; -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
r155346 r155794 450 450 } 451 451 452 bool reliable = true; 453 options.get("reliable", reliable); 454 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(scriptExecutionContext(), m_peerHandler.get(), label, reliable, ec); 455 if (ec) 456 return 0; 452 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(scriptExecutionContext(), m_peerHandler.get(), label, options, ec); 453 if (ec) 454 return 0; 455 457 456 m_dataChannels.append(channel); 458 457 return channel.release(); -
trunk/Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h
r141984 r155794 52 52 class RTCVoidRequest; 53 53 54 struct RTCDataChannelInit { 55 public: 56 RTCDataChannelInit() 57 : ordered(true) 58 , maxRetransmitTime(-1) 59 , maxRetransmits(-1) 60 , negotiated(false) 61 , id(-1) { } 62 bool ordered; 63 int maxRetransmitTime; 64 int maxRetransmits; 65 String protocol; 66 bool negotiated; 67 int id; 68 }; 69 54 70 class RTCPeerConnectionHandler { 55 71 public: … … 70 86 virtual void removeStream(PassRefPtr<MediaStreamDescriptor>) = 0; 71 87 virtual void getStats(PassRefPtr<RTCStatsRequest>) = 0; 72 virtual PassOwnPtr<RTCDataChannelHandler> createDataChannel(const String& label, bool reliable) = 0;88 virtual PassOwnPtr<RTCDataChannelHandler> createDataChannel(const String& label, const RTCDataChannelInit&) = 0; 73 89 virtual PassOwnPtr<RTCDTMFSenderHandler> createDTMFSender(PassRefPtr<MediaStreamComponent>) = 0; 74 90 virtual void stop() = 0;
Note: See TracChangeset
for help on using the changeset viewer.