| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR |
| 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "modules/peerconnection/RTCDataChannel.h" | 25 #include "modules/peerconnection/RTCDataChannel.h" |
| 26 | 26 |
| 27 #include "bindings/core/v8/ExceptionState.h" | 27 #include "bindings/core/v8/ExceptionState.h" |
| 28 #include "core/dom/DOMArrayBuffer.h" | 28 #include "core/dom/DOMArrayBuffer.h" |
| 29 #include "core/dom/DOMArrayBufferView.h" | 29 #include "core/dom/DOMArrayBufferView.h" |
| 30 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/events/MessageEvent.h" | 32 #include "core/events/MessageEvent.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 exceptionState.throwDOMException(TypeMismatchError, | 193 exceptionState.throwDOMException(TypeMismatchError, |
| 194 "Unknown binary type : " + binaryType); | 194 "Unknown binary type : " + binaryType); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void RTCDataChannel::send(const String& data, ExceptionState& exceptionState) { | 197 void RTCDataChannel::send(const String& data, ExceptionState& exceptionState) { |
| 198 if (m_readyState != ReadyStateOpen) { | 198 if (m_readyState != ReadyStateOpen) { |
| 199 throwNotOpenException(exceptionState); | 199 throwNotOpenException(exceptionState); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 if (!m_handler->sendStringData(data)) { | 202 if (!m_handler->sendStringData(data)) { |
| 203 // FIXME: This should not throw an exception but instead forcefully close th
e data channel. | 203 // FIXME: This should not throw an exception but instead forcefully close |
| 204 // the data channel. |
| 204 throwCouldNotSendDataException(exceptionState); | 205 throwCouldNotSendDataException(exceptionState); |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 | 208 |
| 208 void RTCDataChannel::send(DOMArrayBuffer* data, | 209 void RTCDataChannel::send(DOMArrayBuffer* data, |
| 209 ExceptionState& exceptionState) { | 210 ExceptionState& exceptionState) { |
| 210 if (m_readyState != ReadyStateOpen) { | 211 if (m_readyState != ReadyStateOpen) { |
| 211 throwNotOpenException(exceptionState); | 212 throwNotOpenException(exceptionState); |
| 212 return; | 213 return; |
| 213 } | 214 } |
| 214 | 215 |
| 215 size_t dataLength = data->byteLength(); | 216 size_t dataLength = data->byteLength(); |
| 216 if (!dataLength) | 217 if (!dataLength) |
| 217 return; | 218 return; |
| 218 | 219 |
| 219 if (!m_handler->sendRawData(static_cast<const char*>((data->data())), | 220 if (!m_handler->sendRawData(static_cast<const char*>((data->data())), |
| 220 dataLength)) { | 221 dataLength)) { |
| 221 // FIXME: This should not throw an exception but instead forcefully close th
e data channel. | 222 // FIXME: This should not throw an exception but instead forcefully close |
| 223 // the data channel. |
| 222 throwCouldNotSendDataException(exceptionState); | 224 throwCouldNotSendDataException(exceptionState); |
| 223 } | 225 } |
| 224 } | 226 } |
| 225 | 227 |
| 226 void RTCDataChannel::send(DOMArrayBufferView* data, | 228 void RTCDataChannel::send(DOMArrayBufferView* data, |
| 227 ExceptionState& exceptionState) { | 229 ExceptionState& exceptionState) { |
| 228 if (!m_handler->sendRawData(static_cast<const char*>(data->baseAddress()), | 230 if (!m_handler->sendRawData(static_cast<const char*>(data->baseAddress()), |
| 229 data->byteLength())) { | 231 data->byteLength())) { |
| 230 // FIXME: This should not throw an exception but instead forcefully close th
e data channel. | 232 // FIXME: This should not throw an exception but instead forcefully close |
| 233 // the data channel. |
| 231 throwCouldNotSendDataException(exceptionState); | 234 throwCouldNotSendDataException(exceptionState); |
| 232 } | 235 } |
| 233 } | 236 } |
| 234 | 237 |
| 235 void RTCDataChannel::send(Blob* data, ExceptionState& exceptionState) { | 238 void RTCDataChannel::send(Blob* data, ExceptionState& exceptionState) { |
| 236 // FIXME: implement | 239 // FIXME: implement |
| 237 throwNoBlobSupportException(exceptionState); | 240 throwNoBlobSupportException(exceptionState); |
| 238 } | 241 } |
| 239 | 242 |
| 240 void RTCDataChannel::close() { | 243 void RTCDataChannel::close() { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 events.clear(); | 372 events.clear(); |
| 370 } | 373 } |
| 371 | 374 |
| 372 DEFINE_TRACE(RTCDataChannel) { | 375 DEFINE_TRACE(RTCDataChannel) { |
| 373 visitor->trace(m_scheduledEvents); | 376 visitor->trace(m_scheduledEvents); |
| 374 EventTargetWithInlineData::trace(visitor); | 377 EventTargetWithInlineData::trace(visitor); |
| 375 ActiveDOMObject::trace(visitor); | 378 ActiveDOMObject::trace(visitor); |
| 376 } | 379 } |
| 377 | 380 |
| 378 } // namespace blink | 381 } // namespace blink |
| OLD | NEW |