| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 void WebSocket::closeInternal(int code, const String& reason, ExceptionState& ex
ceptionState) | 457 void WebSocket::closeInternal(int code, const String& reason, ExceptionState& ex
ceptionState) |
| 458 { | 458 { |
| 459 if (code == WebSocketChannel::CloseEventCodeNotSpecified) { | 459 if (code == WebSocketChannel::CloseEventCodeNotSpecified) { |
| 460 WTF_LOG(Network, "WebSocket %p close() without code and reason", this); | 460 WTF_LOG(Network, "WebSocket %p close() without code and reason", this); |
| 461 } else { | 461 } else { |
| 462 WTF_LOG(Network, "WebSocket %p close() code=%d reason='%s'", this, code,
reason.utf8().data()); | 462 WTF_LOG(Network, "WebSocket %p close() code=%d reason='%s'", this, code,
reason.utf8().data()); |
| 463 if (!(code == WebSocketChannel::CloseEventCodeNormalClosure || (WebSocke
tChannel::CloseEventCodeMinimumUserDefined <= code && code <= WebSocketChannel::
CloseEventCodeMaximumUserDefined))) { | 463 if (!(code == WebSocketChannel::CloseEventCodeNormalClosure || (WebSocke
tChannel::CloseEventCodeMinimumUserDefined <= code && code <= WebSocketChannel::
CloseEventCodeMaximumUserDefined))) { |
| 464 exceptionState.throwDOMException(InvalidAccessError, "The code must
be either 1000, or between 3000 and 4999. " + String::number(code) + " is neithe
r."); | 464 exceptionState.throwDOMException(InvalidAccessError, "The code must
be either 1000, or between 3000 and 4999. " + String::number(code) + " is neithe
r."); |
| 465 return; | 465 return; |
| 466 } | 466 } |
| 467 CString utf8 = reason.utf8(String::StrictConversionReplacingUnpairedSurr
ogatesWithFFFD); | 467 CString utf8 = reason.utf8(StrictUTF8ConversionReplacingUnpairedSurrogat
esWithFFFD); |
| 468 if (utf8.length() > maxReasonSizeInBytes) { | 468 if (utf8.length() > maxReasonSizeInBytes) { |
| 469 exceptionState.throwDOMException(SyntaxError, "The message must not
be greater than " + String::number(maxReasonSizeInBytes) + " bytes."); | 469 exceptionState.throwDOMException(SyntaxError, "The message must not
be greater than " + String::number(maxReasonSizeInBytes) + " bytes."); |
| 470 return; | 470 return; |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 if (m_state == CLOSING || m_state == CLOSED) | 474 if (m_state == CLOSING || m_state == CLOSED) |
| 475 return; | 475 return; |
| 476 if (m_state == CONNECTING) { | 476 if (m_state == CONNECTING) { |
| 477 m_state = CLOSING; | 477 m_state = CLOSING; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; | 683 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; |
| 684 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; | 684 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; |
| 685 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) | 685 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) |
| 686 overhead += 8; | 686 overhead += 8; |
| 687 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) | 687 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) |
| 688 overhead += 2; | 688 overhead += 2; |
| 689 return overhead; | 689 return overhead; |
| 690 } | 690 } |
| 691 | 691 |
| 692 } // namespace WebCore | 692 } // namespace WebCore |
| OLD | NEW |