| 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* contex
t, PassOwnPtr<RTCDataChannelHandler> handler) | 41 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* contex
t, PassOwnPtr<RTCDataChannelHandler> handler) |
| 42 { | 42 { |
| 43 ASSERT(handler); | 43 ASSERT(handler); |
| 44 return adoptRef(new RTCDataChannel(context, handler)); | 44 return adoptRef(new RTCDataChannel(context, handler)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* contex
t, RTCPeerConnectionHandler* peerConnectionHandler, const String& label, const W
ebKit::WebRTCDataChannelInit& init, ExceptionState& es) | 47 PassRefPtr<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext* contex
t, RTCPeerConnectionHandler* peerConnectionHandler, const String& label, const W
ebKit::WebRTCDataChannelInit& init, ExceptionState& es) |
| 48 { | 48 { |
| 49 OwnPtr<RTCDataChannelHandler> handler = peerConnectionHandler->createDataCha
nnel(label, init); | 49 OwnPtr<RTCDataChannelHandler> handler = peerConnectionHandler->createDataCha
nnel(label, init); |
| 50 if (!handler) { | 50 if (!handler) { |
| 51 es.throwDOMException(NotSupportedError); | 51 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 52 return 0; | 52 return 0; |
| 53 } | 53 } |
| 54 return adoptRef(new RTCDataChannel(context, handler.release())); | 54 return adoptRef(new RTCDataChannel(context, handler.release())); |
| 55 } | 55 } |
| 56 | 56 |
| 57 RTCDataChannel::RTCDataChannel(ScriptExecutionContext* context, PassOwnPtr<RTCDa
taChannelHandler> handler) | 57 RTCDataChannel::RTCDataChannel(ScriptExecutionContext* context, PassOwnPtr<RTCDa
taChannelHandler> handler) |
| 58 : m_scriptExecutionContext(context) | 58 : m_scriptExecutionContext(context) |
| 59 , m_handler(handler) | 59 , m_handler(handler) |
| 60 , m_stopped(false) | 60 , m_stopped(false) |
| 61 , m_readyState(ReadyStateConnecting) | 61 , m_readyState(ReadyStateConnecting) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 case BinaryTypeArrayBuffer: | 140 case BinaryTypeArrayBuffer: |
| 141 return "arraybuffer"; | 141 return "arraybuffer"; |
| 142 } | 142 } |
| 143 ASSERT_NOT_REACHED(); | 143 ASSERT_NOT_REACHED(); |
| 144 return String(); | 144 return String(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void RTCDataChannel::setBinaryType(const String& binaryType, ExceptionState& es) | 147 void RTCDataChannel::setBinaryType(const String& binaryType, ExceptionState& es) |
| 148 { | 148 { |
| 149 if (binaryType == "blob") | 149 if (binaryType == "blob") |
| 150 es.throwDOMException(NotSupportedError); | 150 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 151 else if (binaryType == "arraybuffer") | 151 else if (binaryType == "arraybuffer") |
| 152 m_binaryType = BinaryTypeArrayBuffer; | 152 m_binaryType = BinaryTypeArrayBuffer; |
| 153 else | 153 else |
| 154 es.throwDOMException(TypeMismatchError); | 154 es.throwUninformativeAndGenericDOMException(TypeMismatchError); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void RTCDataChannel::send(const String& data, ExceptionState& es) | 157 void RTCDataChannel::send(const String& data, ExceptionState& es) |
| 158 { | 158 { |
| 159 if (m_readyState != ReadyStateOpen) { | 159 if (m_readyState != ReadyStateOpen) { |
| 160 es.throwDOMException(InvalidStateError); | 160 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 if (!m_handler->sendStringData(data)) { | 163 if (!m_handler->sendStringData(data)) { |
| 164 // FIXME: Decide what the right exception here is. | 164 // FIXME: Decide what the right exception here is. |
| 165 es.throwDOMException(SyntaxError); | 165 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 void RTCDataChannel::send(PassRefPtr<ArrayBuffer> prpData, ExceptionState& es) | 169 void RTCDataChannel::send(PassRefPtr<ArrayBuffer> prpData, ExceptionState& es) |
| 170 { | 170 { |
| 171 if (m_readyState != ReadyStateOpen) { | 171 if (m_readyState != ReadyStateOpen) { |
| 172 es.throwDOMException(InvalidStateError); | 172 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| 176 RefPtr<ArrayBuffer> data = prpData; | 176 RefPtr<ArrayBuffer> data = prpData; |
| 177 | 177 |
| 178 size_t dataLength = data->byteLength(); | 178 size_t dataLength = data->byteLength(); |
| 179 if (!dataLength) | 179 if (!dataLength) |
| 180 return; | 180 return; |
| 181 | 181 |
| 182 const char* dataPointer = static_cast<const char*>(data->data()); | 182 const char* dataPointer = static_cast<const char*>(data->data()); |
| 183 | 183 |
| 184 if (!m_handler->sendRawData(dataPointer, dataLength)) { | 184 if (!m_handler->sendRawData(dataPointer, dataLength)) { |
| 185 // FIXME: Decide what the right exception here is. | 185 // FIXME: Decide what the right exception here is. |
| 186 es.throwDOMException(SyntaxError); | 186 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 void RTCDataChannel::send(PassRefPtr<ArrayBufferView> data, ExceptionState& es) | 190 void RTCDataChannel::send(PassRefPtr<ArrayBufferView> data, ExceptionState& es) |
| 191 { | 191 { |
| 192 RefPtr<ArrayBuffer> arrayBuffer(data->buffer()); | 192 RefPtr<ArrayBuffer> arrayBuffer(data->buffer()); |
| 193 send(arrayBuffer.release(), es); | 193 send(arrayBuffer.release(), es); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void RTCDataChannel::send(PassRefPtr<Blob> data, ExceptionState& es) | 196 void RTCDataChannel::send(PassRefPtr<Blob> data, ExceptionState& es) |
| 197 { | 197 { |
| 198 // FIXME: implement | 198 // FIXME: implement |
| 199 es.throwDOMException(NotSupportedError); | 199 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void RTCDataChannel::close() | 202 void RTCDataChannel::close() |
| 203 { | 203 { |
| 204 if (m_stopped) | 204 if (m_stopped) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 m_handler->close(); | 207 m_handler->close(); |
| 208 } | 208 } |
| 209 | 209 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 events.swap(m_scheduledEvents); | 304 events.swap(m_scheduledEvents); |
| 305 | 305 |
| 306 Vector<RefPtr<Event> >::iterator it = events.begin(); | 306 Vector<RefPtr<Event> >::iterator it = events.begin(); |
| 307 for (; it != events.end(); ++it) | 307 for (; it != events.end(); ++it) |
| 308 dispatchEvent((*it).release()); | 308 dispatchEvent((*it).release()); |
| 309 | 309 |
| 310 events.clear(); | 310 events.clear(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace WebCore | 313 } // namespace WebCore |
| OLD | NEW |