| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 exceptionState.throwDOMException(NetworkError, "Could not send data"); | 46 exceptionState.throwDOMException(NetworkError, "Could not send data"); |
| 47 } | 47 } |
| 48 | 48 |
| 49 static void throwNoBlobSupportException(ExceptionState& exceptionState) | 49 static void throwNoBlobSupportException(ExceptionState& exceptionState) |
| 50 { | 50 { |
| 51 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem
ented yet"); | 51 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem
ented yet"); |
| 52 } | 52 } |
| 53 | 53 |
| 54 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, PassOwnPtr<Web
RTCDataChannelHandler> handler) | 54 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, PassOwnPtr<Web
RTCDataChannelHandler> handler) |
| 55 { | 55 { |
| 56 ASSERT(handler); | 56 DCHECK(handler); |
| 57 return new RTCDataChannel(context, handler); | 57 return new RTCDataChannel(context, handler); |
| 58 } | 58 } |
| 59 | 59 |
| 60 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, WebRTCPeerConn
ectionHandler* peerConnectionHandler, const String& label, const WebRTCDataChann
elInit& init, ExceptionState& exceptionState) | 60 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, WebRTCPeerConn
ectionHandler* peerConnectionHandler, const String& label, const WebRTCDataChann
elInit& init, ExceptionState& exceptionState) |
| 61 { | 61 { |
| 62 OwnPtr<WebRTCDataChannelHandler> handler = adoptPtr(peerConnectionHandler->c
reateDataChannel(label, init)); | 62 OwnPtr<WebRTCDataChannelHandler> handler = adoptPtr(peerConnectionHandler->c
reateDataChannel(label, init)); |
| 63 if (!handler) { | 63 if (!handler) { |
| 64 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n
ot supported"); | 64 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n
ot supported"); |
| 65 return nullptr; | 65 return nullptr; |
| 66 } | 66 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 case ReadyStateConnecting: | 135 case ReadyStateConnecting: |
| 136 return "connecting"; | 136 return "connecting"; |
| 137 case ReadyStateOpen: | 137 case ReadyStateOpen: |
| 138 return "open"; | 138 return "open"; |
| 139 case ReadyStateClosing: | 139 case ReadyStateClosing: |
| 140 return "closing"; | 140 return "closing"; |
| 141 case ReadyStateClosed: | 141 case ReadyStateClosed: |
| 142 return "closed"; | 142 return "closed"; |
| 143 } | 143 } |
| 144 | 144 |
| 145 ASSERT_NOT_REACHED(); | 145 NOTREACHED(); |
| 146 return String(); | 146 return String(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 unsigned RTCDataChannel::bufferedAmount() const | 149 unsigned RTCDataChannel::bufferedAmount() const |
| 150 { | 150 { |
| 151 return m_handler->bufferedAmount(); | 151 return m_handler->bufferedAmount(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 unsigned RTCDataChannel::bufferedAmountLowThreshold() const | 154 unsigned RTCDataChannel::bufferedAmountLowThreshold() const |
| 155 { | 155 { |
| 156 return m_bufferedAmountLowThreshold; | 156 return m_bufferedAmountLowThreshold; |
| 157 } | 157 } |
| 158 | 158 |
| 159 void RTCDataChannel::setBufferedAmountLowThreshold(unsigned threshold) | 159 void RTCDataChannel::setBufferedAmountLowThreshold(unsigned threshold) |
| 160 { | 160 { |
| 161 m_bufferedAmountLowThreshold = threshold; | 161 m_bufferedAmountLowThreshold = threshold; |
| 162 } | 162 } |
| 163 | 163 |
| 164 String RTCDataChannel::binaryType() const | 164 String RTCDataChannel::binaryType() const |
| 165 { | 165 { |
| 166 switch (m_binaryType) { | 166 switch (m_binaryType) { |
| 167 case BinaryTypeBlob: | 167 case BinaryTypeBlob: |
| 168 return "blob"; | 168 return "blob"; |
| 169 case BinaryTypeArrayBuffer: | 169 case BinaryTypeArrayBuffer: |
| 170 return "arraybuffer"; | 170 return "arraybuffer"; |
| 171 } | 171 } |
| 172 ASSERT_NOT_REACHED(); | 172 NOTREACHED(); |
| 173 return String(); | 173 return String(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void RTCDataChannel::setBinaryType(const String& binaryType, ExceptionState& exc
eptionState) | 176 void RTCDataChannel::setBinaryType(const String& binaryType, ExceptionState& exc
eptionState) |
| 177 { | 177 { |
| 178 if (binaryType == "blob") | 178 if (binaryType == "blob") |
| 179 throwNoBlobSupportException(exceptionState); | 179 throwNoBlobSupportException(exceptionState); |
| 180 else if (binaryType == "arraybuffer") | 180 else if (binaryType == "arraybuffer") |
| 181 m_binaryType = BinaryTypeArrayBuffer; | 181 m_binaryType = BinaryTypeArrayBuffer; |
| 182 else | 182 else |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 { | 269 { |
| 270 if (m_binaryType == BinaryTypeBlob) { | 270 if (m_binaryType == BinaryTypeBlob) { |
| 271 // FIXME: Implement. | 271 // FIXME: Implement. |
| 272 return; | 272 return; |
| 273 } | 273 } |
| 274 if (m_binaryType == BinaryTypeArrayBuffer) { | 274 if (m_binaryType == BinaryTypeArrayBuffer) { |
| 275 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, dataLength)
; | 275 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(data, dataLength)
; |
| 276 scheduleDispatchEvent(MessageEvent::create(buffer.release())); | 276 scheduleDispatchEvent(MessageEvent::create(buffer.release())); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 ASSERT_NOT_REACHED(); | 279 NOTREACHED(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void RTCDataChannel::didDetectError() | 282 void RTCDataChannel::didDetectError() |
| 283 { | 283 { |
| 284 scheduleDispatchEvent(Event::create(EventTypeNames::error)); | 284 scheduleDispatchEvent(Event::create(EventTypeNames::error)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 const AtomicString& RTCDataChannel::interfaceName() const | 287 const AtomicString& RTCDataChannel::interfaceName() const |
| 288 { | 288 { |
| 289 return EventTargetNames::RTCDataChannel; | 289 return EventTargetNames::RTCDataChannel; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 315 } | 315 } |
| 316 | 316 |
| 317 DEFINE_TRACE(RTCDataChannel) | 317 DEFINE_TRACE(RTCDataChannel) |
| 318 { | 318 { |
| 319 visitor->trace(m_executionContext); | 319 visitor->trace(m_executionContext); |
| 320 visitor->trace(m_scheduledEvents); | 320 visitor->trace(m_scheduledEvents); |
| 321 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v
isitor); | 321 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v
isitor); |
| 322 } | 322 } |
| 323 | 323 |
| 324 } // namespace blink | 324 } // namespace blink |
| OLD | NEW |