| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 RTCDataChannel::RTCDataChannel(ExecutionContext* context, RTCPeerConnection* con
nection, PassOwnPtr<WebRTCDataChannelHandler> handler) | 71 RTCDataChannel::RTCDataChannel(ExecutionContext* context, RTCPeerConnection* con
nection, PassOwnPtr<WebRTCDataChannelHandler> handler) |
| 72 : m_executionContext(context) | 72 : m_executionContext(context) |
| 73 , m_handler(handler) | 73 , m_handler(handler) |
| 74 , m_stopped(false) | 74 , m_stopped(false) |
| 75 , m_readyState(ReadyStateConnecting) | 75 , m_readyState(ReadyStateConnecting) |
| 76 , m_binaryType(BinaryTypeArrayBuffer) | 76 , m_binaryType(BinaryTypeArrayBuffer) |
| 77 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired) | 77 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired) |
| 78 , m_connection(connection) | 78 , m_connection(connection) |
| 79 , m_bufferedAmountLowThreshold(0U) |
| 79 { | 80 { |
| 80 m_handler->setClient(this); | 81 m_handler->setClient(this); |
| 81 } | 82 } |
| 82 | 83 |
| 83 RTCDataChannel::~RTCDataChannel() | 84 RTCDataChannel::~RTCDataChannel() |
| 84 { | 85 { |
| 85 // If the peer connection and the data channel die in the same | 86 // If the peer connection and the data channel die in the same |
| 86 // GC cycle stop has not been called and we need to notify the | 87 // GC cycle stop has not been called and we need to notify the |
| 87 // client that the channel is gone. | 88 // client that the channel is gone. |
| 88 if (!m_stopped) | 89 if (!m_stopped) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 150 |
| 150 ASSERT_NOT_REACHED(); | 151 ASSERT_NOT_REACHED(); |
| 151 return String(); | 152 return String(); |
| 152 } | 153 } |
| 153 | 154 |
| 154 unsigned RTCDataChannel::bufferedAmount() const | 155 unsigned RTCDataChannel::bufferedAmount() const |
| 155 { | 156 { |
| 156 return m_handler->bufferedAmount(); | 157 return m_handler->bufferedAmount(); |
| 157 } | 158 } |
| 158 | 159 |
| 160 unsigned RTCDataChannel::bufferedAmountLowThreshold() const |
| 161 { |
| 162 return m_bufferedAmountLowThreshold; |
| 163 } |
| 164 |
| 165 void RTCDataChannel::setBufferedAmountLowThreshold(unsigned threshold) |
| 166 { |
| 167 m_bufferedAmountLowThreshold = threshold; |
| 168 } |
| 169 |
| 159 String RTCDataChannel::binaryType() const | 170 String RTCDataChannel::binaryType() const |
| 160 { | 171 { |
| 161 switch (m_binaryType) { | 172 switch (m_binaryType) { |
| 162 case BinaryTypeBlob: | 173 case BinaryTypeBlob: |
| 163 return "blob"; | 174 return "blob"; |
| 164 case BinaryTypeArrayBuffer: | 175 case BinaryTypeArrayBuffer: |
| 165 return "arraybuffer"; | 176 return "arraybuffer"; |
| 166 } | 177 } |
| 167 ASSERT_NOT_REACHED(); | 178 ASSERT_NOT_REACHED(); |
| 168 return String(); | 179 return String(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 scheduleDispatchEvent(Event::create(EventTypeNames::open)); | 254 scheduleDispatchEvent(Event::create(EventTypeNames::open)); |
| 244 break; | 255 break; |
| 245 case ReadyStateClosed: | 256 case ReadyStateClosed: |
| 246 scheduleDispatchEvent(Event::create(EventTypeNames::close)); | 257 scheduleDispatchEvent(Event::create(EventTypeNames::close)); |
| 247 break; | 258 break; |
| 248 default: | 259 default: |
| 249 break; | 260 break; |
| 250 } | 261 } |
| 251 } | 262 } |
| 252 | 263 |
| 264 void RTCDataChannel::didDecreaseBufferedAmount(unsigned previousAmount) |
| 265 { |
| 266 if (previousAmount > m_bufferedAmountLowThreshold |
| 267 && bufferedAmount() <= m_bufferedAmountLowThreshold) { |
| 268 scheduleDispatchEvent(Event::create(EventTypeNames::bufferedamountlow)); |
| 269 } |
| 270 } |
| 271 |
| 253 void RTCDataChannel::didReceiveStringData(const WebString& text) | 272 void RTCDataChannel::didReceiveStringData(const WebString& text) |
| 254 { | 273 { |
| 255 if (m_stopped) | 274 if (m_stopped) |
| 256 return; | 275 return; |
| 257 | 276 |
| 258 scheduleDispatchEvent(MessageEvent::create(text)); | 277 scheduleDispatchEvent(MessageEvent::create(text)); |
| 259 } | 278 } |
| 260 | 279 |
| 261 void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength) | 280 void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength) |
| 262 { | 281 { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 353 |
| 335 DEFINE_TRACE(RTCDataChannel) | 354 DEFINE_TRACE(RTCDataChannel) |
| 336 { | 355 { |
| 337 visitor->trace(m_executionContext); | 356 visitor->trace(m_executionContext); |
| 338 visitor->trace(m_scheduledEvents); | 357 visitor->trace(m_scheduledEvents); |
| 339 visitor->template registerWeakMembers<RTCDataChannel, &RTCDataChannel::clear
WeakMembers>(this); | 358 visitor->template registerWeakMembers<RTCDataChannel, &RTCDataChannel::clear
WeakMembers>(this); |
| 340 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v
isitor); | 359 RefCountedGarbageCollectedEventTargetWithInlineData<RTCDataChannel>::trace(v
isitor); |
| 341 } | 360 } |
| 342 | 361 |
| 343 } // namespace blink | 362 } // namespace blink |
| OLD | NEW |