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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 PassRefPtr<WebSocket> WebSocket::create(ExecutionContext* context, const String&
url, ExceptionState& exceptionState) | 244 PassRefPtr<WebSocket> WebSocket::create(ExecutionContext* context, const String&
url, ExceptionState& exceptionState) |
245 { | 245 { |
246 Vector<String> protocols; | 246 Vector<String> protocols; |
247 return create(context, url, protocols, exceptionState); | 247 return create(context, url, protocols, exceptionState); |
248 } | 248 } |
249 | 249 |
250 PassRefPtr<WebSocket> WebSocket::create(ExecutionContext* context, const String&
url, const Vector<String>& protocols, ExceptionState& exceptionState) | 250 PassRefPtr<WebSocket> WebSocket::create(ExecutionContext* context, const String&
url, const Vector<String>& protocols, ExceptionState& exceptionState) |
251 { | 251 { |
252 if (url.isNull()) { | 252 if (url.isNull()) { |
253 exceptionState.throwDOMException(SyntaxError, "Failed to create a WebSoc
ket: the provided URL is invalid."); | 253 exceptionState.throwDOMException(SyntaxError, "Failed to create a WebSoc
ket: the provided URL is invalid."); |
254 return 0; | 254 return nullptr; |
255 } | 255 } |
256 | 256 |
257 RefPtr<WebSocket> webSocket(adoptRef(new WebSocket(context))); | 257 RefPtr<WebSocket> webSocket(adoptRef(new WebSocket(context))); |
258 webSocket->suspendIfNeeded(); | 258 webSocket->suspendIfNeeded(); |
259 | 259 |
260 webSocket->connect(context->completeURL(url), protocols, exceptionState); | 260 webSocket->connect(context->completeURL(url), protocols, exceptionState); |
261 if (exceptionState.hadException()) | 261 if (exceptionState.hadException()) |
262 return 0; | 262 return nullptr; |
263 | 263 |
264 return webSocket.release(); | 264 return webSocket.release(); |
265 } | 265 } |
266 | 266 |
267 PassRefPtr<WebSocket> WebSocket::create(ExecutionContext* context, const String&
url, const String& protocol, ExceptionState& exceptionState) | 267 PassRefPtr<WebSocket> WebSocket::create(ExecutionContext* context, const String&
url, const String& protocol, ExceptionState& exceptionState) |
268 { | 268 { |
269 Vector<String> protocols; | 269 Vector<String> protocols; |
270 protocols.append(protocol); | 270 protocols.append(protocol); |
271 return create(context, url, protocols, exceptionState); | 271 return create(context, url, protocols, exceptionState); |
272 } | 272 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payload
Size); | 382 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payload
Size); |
383 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFram
ingOverhead(payloadSize)); | 383 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFram
ingOverhead(payloadSize)); |
384 | 384 |
385 logError("WebSocket is already in CLOSING or CLOSED state."); | 385 logError("WebSocket is already in CLOSING or CLOSED state."); |
386 } | 386 } |
387 | 387 |
388 void WebSocket::releaseChannel() | 388 void WebSocket::releaseChannel() |
389 { | 389 { |
390 ASSERT(m_channel); | 390 ASSERT(m_channel); |
391 m_channel->disconnect(); | 391 m_channel->disconnect(); |
392 m_channel = 0; | 392 m_channel = nullptr; |
393 } | 393 } |
394 | 394 |
395 void WebSocket::send(const String& message, ExceptionState& exceptionState) | 395 void WebSocket::send(const String& message, ExceptionState& exceptionState) |
396 { | 396 { |
397 WTF_LOG(Network, "WebSocket %p send() Sending String '%s'", this, message.ut
f8().data()); | 397 WTF_LOG(Network, "WebSocket %p send() Sending String '%s'", this, message.ut
f8().data()); |
398 if (m_state == CONNECTING) { | 398 if (m_state == CONNECTING) { |
399 setInvalidStateErrorForSendMethod(exceptionState); | 399 setInvalidStateErrorForSendMethod(exceptionState); |
400 return; | 400 return; |
401 } | 401 } |
402 // No exception is raised if the connection was once established but has sub
sequently been closed. | 402 // No exception is raised if the connection was once established but has sub
sequently been closed. |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; | 680 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; |
681 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; | 681 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; |
682 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) | 682 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) |
683 overhead += 8; | 683 overhead += 8; |
684 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) | 684 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) |
685 overhead += 2; | 685 overhead += 2; |
686 return overhead; | 686 return overhead; |
687 } | 687 } |
688 | 688 |
689 } // namespace WebCore | 689 } // namespace WebCore |
OLD | NEW |