OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 { | 198 { |
199 StringBuilder builder; | 199 StringBuilder builder; |
200 for (size_t i = 0; i < strings.size(); ++i) { | 200 for (size_t i = 0; i < strings.size(); ++i) { |
201 if (i) | 201 if (i) |
202 builder.append(separator); | 202 builder.append(separator); |
203 builder.append(strings[i]); | 203 builder.append(strings[i]); |
204 } | 204 } |
205 return builder.toString(); | 205 return builder.toString(); |
206 } | 206 } |
207 | 207 |
208 static unsigned long saturateAdd(unsigned long a, unsigned long b) | 208 static unsigned saturateAdd(unsigned a, unsigned long b) |
209 { | 209 { |
210 if (std::numeric_limits<unsigned long>::max() - a < b) | 210 if (std::numeric_limits<unsigned>::max() - a < b) |
211 return std::numeric_limits<unsigned long>::max(); | 211 return std::numeric_limits<unsigned>::max(); |
212 return a + b; | 212 return a + b; |
213 } | 213 } |
214 | 214 |
215 static void setInvalidStateErrorForSendMethod(ExceptionState& exceptionState) | 215 static void setInvalidStateErrorForSendMethod(ExceptionState& exceptionState) |
216 { | 216 { |
217 exceptionState.throwDOMException(InvalidStateError, "Still in CONNECTING sta
te."); | 217 exceptionState.throwDOMException(InvalidStateError, "Still in CONNECTING sta
te."); |
218 } | 218 } |
219 | 219 |
220 const char* DOMWebSocket::subprotocolSeperator() | 220 const char* DOMWebSocket::subprotocolSeperator() |
221 { | 221 { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 { | 353 { |
354 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payload
Size); | 354 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payload
Size); |
355 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFram
ingOverhead(payloadSize)); | 355 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFram
ingOverhead(payloadSize)); |
356 | 356 |
357 logError("WebSocket is already in CLOSING or CLOSED state."); | 357 logError("WebSocket is already in CLOSING or CLOSED state."); |
358 } | 358 } |
359 | 359 |
360 void DOMWebSocket::reflectBufferedAmountConsumption(Timer<DOMWebSocket>*) | 360 void DOMWebSocket::reflectBufferedAmountConsumption(Timer<DOMWebSocket>*) |
361 { | 361 { |
362 ASSERT(m_bufferedAmount >= m_consumedBufferedAmount); | 362 ASSERT(m_bufferedAmount >= m_consumedBufferedAmount); |
363 WTF_LOG(Network, "WebSocket %p reflectBufferedAmountConsumption() %lu => %lu
", this, m_bufferedAmount, m_bufferedAmount - m_consumedBufferedAmount); | 363 WTF_LOG(Network, "WebSocket %p reflectBufferedAmountConsumption() %u => %u",
this, m_bufferedAmount, m_bufferedAmount - m_consumedBufferedAmount); |
364 | 364 |
365 m_bufferedAmount -= m_consumedBufferedAmount; | 365 m_bufferedAmount -= m_consumedBufferedAmount; |
366 m_consumedBufferedAmount = 0; | 366 m_consumedBufferedAmount = 0; |
367 } | 367 } |
368 | 368 |
369 void DOMWebSocket::releaseChannel() | 369 void DOMWebSocket::releaseChannel() |
370 { | 370 { |
371 ASSERT(m_channel); | 371 ASSERT(m_channel); |
372 m_channel->disconnect(); | 372 m_channel->disconnect(); |
373 m_channel = nullptr; | 373 m_channel = nullptr; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 const KURL& DOMWebSocket::url() const | 493 const KURL& DOMWebSocket::url() const |
494 { | 494 { |
495 return m_url; | 495 return m_url; |
496 } | 496 } |
497 | 497 |
498 DOMWebSocket::State DOMWebSocket::readyState() const | 498 DOMWebSocket::State DOMWebSocket::readyState() const |
499 { | 499 { |
500 return m_state; | 500 return m_state; |
501 } | 501 } |
502 | 502 |
503 unsigned long DOMWebSocket::bufferedAmount() const | 503 unsigned DOMWebSocket::bufferedAmount() const |
504 { | 504 { |
505 return saturateAdd(m_bufferedAmount, m_bufferedAmountAfterClose); | 505 return saturateAdd(m_bufferedAmount, m_bufferedAmountAfterClose); |
506 } | 506 } |
507 | 507 |
508 String DOMWebSocket::protocol() const | 508 String DOMWebSocket::protocol() const |
509 { | 509 { |
510 return m_subprotocol; | 510 return m_subprotocol; |
511 } | 511 } |
512 | 512 |
513 String DOMWebSocket::extensions() const | 513 String DOMWebSocket::extensions() const |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 634 } |
635 } | 635 } |
636 | 636 |
637 void DOMWebSocket::didError() | 637 void DOMWebSocket::didError() |
638 { | 638 { |
639 WTF_LOG(Network, "WebSocket %p didError()", this); | 639 WTF_LOG(Network, "WebSocket %p didError()", this); |
640 m_state = CLOSED; | 640 m_state = CLOSED; |
641 m_eventQueue->dispatch(Event::create(EventTypeNames::error)); | 641 m_eventQueue->dispatch(Event::create(EventTypeNames::error)); |
642 } | 642 } |
643 | 643 |
644 void DOMWebSocket::didConsumeBufferedAmount(unsigned long consumed) | 644 void DOMWebSocket::didConsumeBufferedAmount(unsigned consumed) |
645 { | 645 { |
646 ASSERT(m_bufferedAmount >= consumed); | 646 ASSERT(m_bufferedAmount >= consumed); |
647 WTF_LOG(Network, "WebSocket %p didConsumeBufferedAmount(%lu)", this, consume
d); | 647 WTF_LOG(Network, "WebSocket %p didConsumeBufferedAmount(%u)", this, consumed
); |
648 if (m_state == CLOSED) | 648 if (m_state == CLOSED) |
649 return; | 649 return; |
650 m_consumedBufferedAmount += consumed; | 650 m_consumedBufferedAmount += consumed; |
651 if (!m_bufferedAmountConsumeTimer.isActive()) | 651 if (!m_bufferedAmountConsumeTimer.isActive()) |
652 m_bufferedAmountConsumeTimer.startOneShot(0, FROM_HERE); | 652 m_bufferedAmountConsumeTimer.startOneShot(0, FROM_HERE); |
653 } | 653 } |
654 | 654 |
655 void DOMWebSocket::didStartClosingHandshake() | 655 void DOMWebSocket::didStartClosingHandshake() |
656 { | 656 { |
657 WTF_LOG(Network, "WebSocket %p didStartClosingHandshake()", this); | 657 WTF_LOG(Network, "WebSocket %p didStartClosingHandshake()", this); |
(...skipping 29 matching lines...) Expand all Loading... |
687 | 687 |
688 void DOMWebSocket::trace(Visitor* visitor) | 688 void DOMWebSocket::trace(Visitor* visitor) |
689 { | 689 { |
690 visitor->trace(m_channel); | 690 visitor->trace(m_channel); |
691 visitor->trace(m_eventQueue); | 691 visitor->trace(m_eventQueue); |
692 WebSocketChannelClient::trace(visitor); | 692 WebSocketChannelClient::trace(visitor); |
693 EventTargetWithInlineData::trace(visitor); | 693 EventTargetWithInlineData::trace(visitor); |
694 } | 694 } |
695 | 695 |
696 } // namespace blink | 696 } // namespace blink |
OLD | NEW |