Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: Source/modules/websockets/WebSocket.cpp

Issue 124003003: Add ascii() / latin1() / utf8() methods to AtomicString to avoid having to call string() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/modules/websockets/NewWebSocketChannelImpl.cpp ('k') | Source/platform/fonts/skia/FontCacheSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698