Changeset 249710 in webkit
- Timestamp:
- Sep 10, 2019 5:04:45 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r249686 r249710 1 2019-09-10 Youenn Fablet <youenn@apple.com> 2 3 Add support to RTCDataChannel.send(Blob) 4 https://bugs.webkit.org/show_bug.cgi?id=201377 5 6 Reviewed by Chris Dumez. 7 8 * web-platform-tests/webrtc/RTCDataChannel-send-blob-order-expected.txt: Added. 9 * web-platform-tests/webrtc/RTCDataChannel-send-blob-order.html: Added. 10 * web-platform-tests/webrtc/RTCDataChannel-send-expected.txt: 11 1 12 2019-09-09 Joonghun Park <jh718.park@samsung.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-expected.txt
r244196 r249710 6 6 PASS Data channel should be able to send Uint8Array message and receive as ArrayBuffer 7 7 PASS Data channel should be able to send ArrayBuffer message and receive as ArrayBuffer 8 FAIL Data channel should be able to send Blob message and receive as ArrayBuffer promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported." 8 PASS Data channel should be able to send Blob message and receive as ArrayBuffer 9 9 PASS Data channel should be able to send ArrayBuffer message and receive as Blob 10 10 FAIL Data channel binaryType should receive message as Blob by default assert_equals: Expect initial binaryType value to be blob expected "blob" but got "arraybuffer" 11 FAIL Sending multiple messages with different types should succeed and be received assert_unreached: Unexpected promise rejection: NotSupportedError: The operation is not supported. Reached unreachable code 11 PASS Sending multiple messages with different types should succeed and be received 12 12 -
trunk/Source/WebCore/ChangeLog
r249709 r249710 1 2019-09-10 Youenn Fablet <youenn@apple.com> 2 3 Add support to RTCDataChannel.send(Blob) 4 https://bugs.webkit.org/show_bug.cgi?id=201377 5 6 Reviewed by Chris Dumez. 7 8 Make use of NetworkSendQueue to enqueue and send properly messages. 9 Test: imported/w3c/web-platform-tests/webrtc/RTCDataChannel-send-blob-order.html 10 11 * Modules/mediastream/RTCDataChannel.cpp: 12 (WebCore::RTCDataChannel::createMessageQueue): 13 (WebCore::RTCDataChannel::RTCDataChannel): 14 (WebCore::RTCDataChannel::send): 15 (WebCore::RTCDataChannel::close): 16 * Modules/mediastream/RTCDataChannel.h: 17 1 18 2019-09-10 Ryosuke Niwa <rniwa@webkit.org> 2 19 -
trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp
r248503 r249710 30 30 31 31 #include "Blob.h" 32 #include "Event.h"33 32 #include "EventNames.h" 34 33 #include "MessageEvent.h" 35 #include "RTCDataChannelHandler.h"36 34 #include "ScriptExecutionContext.h" 37 35 #include "SharedBuffer.h" 38 #include <JavaScriptCore/ArrayBuffer.h>39 36 #include <JavaScriptCore/ArrayBufferView.h> 40 37 #include <wtf/IsoMallocInlines.h> … … 67 64 } 68 65 66 NetworkSendQueue RTCDataChannel::createMessageQueue(Document& document, RTCDataChannel& channel) 67 { 68 return { document, [&channel](const String& data) { 69 if (!channel.m_handler->sendStringData(data)) 70 channel.scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "Error sending string through RTCDataChannel."_s); 71 }, [&channel](auto* data, size_t length) { 72 if (!channel.m_handler->sendRawData(data, length)) 73 channel.scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, "Error sending binary data through RTCDataChannel."_s); 74 }, [&channel](int errorCode) { 75 if (auto* context = channel.scriptExecutionContext()) 76 context->addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Error ", errorCode, " in retrieving a blob data to be sent through RTCDataChannel.")); 77 return NetworkSendQueue::Continue::Yes; 78 } }; 79 } 80 69 81 RTCDataChannel::RTCDataChannel(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options) 70 82 : ActiveDOMObject(&context) … … 73 85 , m_label(WTFMove(label)) 74 86 , m_options(WTFMove(options)) 87 , m_messageQueue(createMessageQueue(downcast<Document>(context), *this)) 75 88 { 76 89 } … … 115 128 return Exception { InvalidStateError }; 116 129 117 if (!m_handler->sendStringData(data)) { 118 // FIXME: Decide what the right exception here is. 119 return Exception { SyntaxError }; 120 } 121 122 return { }; 123 } 124 125 ExceptionOr<void> RTCDataChannel::sendRawData(const char* data, size_t length) 126 { 127 if (m_readyState != RTCDataChannelState::Open) 128 return Exception { InvalidStateError }; 129 130 if (!length) 131 return { }; 132 133 if (!m_handler->sendRawData(data, length)) { 134 // FIXME: Decide what the right exception here is. 135 return Exception { SyntaxError }; 136 } 137 138 return { }; 139 } 140 130 m_messageQueue.enqueue(data); 131 return { }; 132 } 141 133 142 134 ExceptionOr<void> RTCDataChannel::send(ArrayBuffer& data) 143 135 { 144 return sendRawData(static_cast<const char*>(data.data()), data.byteLength()); 136 if (m_readyState != RTCDataChannelState::Open) 137 return Exception { InvalidStateError }; 138 139 m_messageQueue.enqueue(data, 0, data.byteLength()); 140 return { }; 145 141 } 146 142 147 143 ExceptionOr<void> RTCDataChannel::send(ArrayBufferView& data) 148 144 { 149 return sendRawData(static_cast<const char*>(data.baseAddress()), data.byteLength()); 150 } 151 152 ExceptionOr<void> RTCDataChannel::send(Blob&) 153 { 154 // FIXME: Implement. 155 return Exception { NotSupportedError }; 145 if (m_readyState != RTCDataChannelState::Open) 146 return Exception { InvalidStateError }; 147 148 m_messageQueue.enqueue(*data.unsharedBuffer(), data.byteOffset(), data.byteLength()); 149 return { }; 150 } 151 152 ExceptionOr<void> RTCDataChannel::send(Blob& blob) 153 { 154 if (m_readyState != RTCDataChannelState::Open) 155 return Exception { InvalidStateError }; 156 157 m_messageQueue.enqueue(blob); 158 return { }; 156 159 } 157 160 … … 163 166 m_stopped = true; 164 167 m_readyState = RTCDataChannelState::Closed; 168 169 m_messageQueue.clear(); 165 170 166 171 m_handler->close(); -
trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h
r246490 r249710 32 32 #include "EventTarget.h" 33 33 #include "ExceptionOr.h" 34 #include "NetworkSendQueue.h" 34 35 #include "RTCDataChannelHandler.h" 35 36 #include "RTCDataChannelHandlerClient.h" … … 81 82 RTCDataChannel(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&); 82 83 84 static NetworkSendQueue createMessageQueue(Document&, RTCDataChannel&); 85 83 86 void scheduleDispatchEvent(Ref<Event>&&); 84 87 void scheduledEventTimerFired(); … … 89 92 void refEventTarget() final { ref(); } 90 93 void derefEventTarget() final { deref(); } 91 92 ExceptionOr<void> sendRawData(const char* data, size_t length);93 94 94 95 // ActiveDOMObject API … … 119 120 RTCDataChannelInit m_options; 120 121 size_t m_bufferedAmountLowThreshold { 0 }; 122 123 NetworkSendQueue m_messageQueue; 121 124 }; 122 125
Note: See TracChangeset
for help on using the changeset viewer.