| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 m_channel->didFinishLoadingBlob(m_loader.arrayBufferResult()); | 127 m_channel->didFinishLoadingBlob(m_loader.arrayBufferResult()); |
| 128 // |this| is deleted here. | 128 // |this| is deleted here. |
| 129 } | 129 } |
| 130 | 130 |
| 131 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod
e) | 131 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod
e) |
| 132 { | 132 { |
| 133 m_channel->didFailLoadingBlob(errorCode); | 133 m_channel->didFailLoadingBlob(errorCode); |
| 134 // |this| is deleted here. | 134 // |this| is deleted here. |
| 135 } | 135 } |
| 136 | 136 |
| 137 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket
ChannelClient* client, const String& sourceURL, unsigned lineNumber, WebSocketHa
ndle *handle) | 137 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket
ChannelClient* client, PassOwnPtr<SourceLocation> location, WebSocketHandle *han
dle) |
| 138 : ContextLifecycleObserver(document) | 138 : ContextLifecycleObserver(document) |
| 139 , m_handle(adoptPtr(handle ? handle : Platform::current()->createWebSocketHa
ndle())) | 139 , m_handle(adoptPtr(handle ? handle : Platform::current()->createWebSocketHa
ndle())) |
| 140 , m_client(client) | 140 , m_client(client) |
| 141 , m_identifier(createUniqueIdentifier()) | 141 , m_identifier(createUniqueIdentifier()) |
| 142 , m_sendingQuota(0) | 142 , m_sendingQuota(0) |
| 143 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa
rk * 2) // initial quota | 143 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa
rk * 2) // initial quota |
| 144 , m_sentSizeOfTopMessage(0) | 144 , m_sentSizeOfTopMessage(0) |
| 145 , m_sourceURLAtConstruction(sourceURL) | 145 , m_locationAtConstruction(std::move(location)) |
| 146 , m_lineNumberAtConstruction(lineNumber) | |
| 147 { | 146 { |
| 148 } | 147 } |
| 149 | 148 |
| 150 DocumentWebSocketChannel::~DocumentWebSocketChannel() | 149 DocumentWebSocketChannel::~DocumentWebSocketChannel() |
| 151 { | 150 { |
| 152 ASSERT(!m_blobLoader); | 151 ASSERT(!m_blobLoader); |
| 153 } | 152 } |
| 154 | 153 |
| 155 bool DocumentWebSocketChannel::connect(const KURL& url, const String& protocol) | 154 bool DocumentWebSocketChannel::connect(const KURL& url, const String& protocol) |
| 156 { | 155 { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 248 |
| 250 void DocumentWebSocketChannel::close(int code, const String& reason) | 249 void DocumentWebSocketChannel::close(int code, const String& reason) |
| 251 { | 250 { |
| 252 WTF_LOG(Network, "DocumentWebSocketChannel %p close(%d, %s)", this, code, re
ason.utf8().data()); | 251 WTF_LOG(Network, "DocumentWebSocketChannel %p close(%d, %s)", this, code, re
ason.utf8().data()); |
| 253 ASSERT(m_handle); | 252 ASSERT(m_handle); |
| 254 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo
deNotSpecified ? CloseEventCodeNoStatusRcvd : code); | 253 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo
deNotSpecified ? CloseEventCodeNoStatusRcvd : code); |
| 255 m_messages.append(new Message(codeToSend, reason)); | 254 m_messages.append(new Message(codeToSend, reason)); |
| 256 processSendQueue(); | 255 processSendQueue(); |
| 257 } | 256 } |
| 258 | 257 |
| 259 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, co
nst String& sourceURL, unsigned lineNumber) | 258 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, Pa
ssOwnPtr<SourceLocation> location) |
| 260 { | 259 { |
| 261 WTF_LOG(Network, "DocumentWebSocketChannel %p fail(%s)", this, reason.utf8()
.data()); | 260 WTF_LOG(Network, "DocumentWebSocketChannel %p fail(%s)", this, reason.utf8()
.data()); |
| 262 // m_handle and m_client can be null here. | 261 // m_handle and m_client can be null here. |
| 263 | 262 |
| 264 InspectorInstrumentation::didReceiveWebSocketFrameError(document(), m_identi
fier, reason); | 263 InspectorInstrumentation::didReceiveWebSocketFrameError(document(), m_identi
fier, reason); |
| 265 const String message = "WebSocket connection to '" + m_url.elidedString() +
"' failed: " + reason; | 264 const String message = "WebSocket connection to '" + m_url.elidedString() +
"' failed: " + reason; |
| 266 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSou
rce, level, message, sourceURL, lineNumber, 0)); | 265 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSou
rce, level, message, std::move(location))); |
| 267 | 266 |
| 268 if (m_client) | 267 if (m_client) |
| 269 m_client->didError(); | 268 m_client->didError(); |
| 270 // |reason| is only for logging and should not be provided for scripts, | 269 // |reason| is only for logging and should not be provided for scripts, |
| 271 // hence close reason must be empty. | 270 // hence close reason must be empty. |
| 272 handleDidClose(false, CloseEventCodeAbnormalClosure, String()); | 271 handleDidClose(false, CloseEventCodeAbnormalClosure, String()); |
| 273 // handleDidClose may delete this object. | 272 // handleDidClose may delete this object. |
| 274 } | 273 } |
| 275 | 274 |
| 276 void DocumentWebSocketChannel::disconnect() | 275 void DocumentWebSocketChannel::disconnect() |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 DEFINE_TRACE(DocumentWebSocketChannel) | 579 DEFINE_TRACE(DocumentWebSocketChannel) |
| 581 { | 580 { |
| 582 visitor->trace(m_blobLoader); | 581 visitor->trace(m_blobLoader); |
| 583 visitor->trace(m_messages); | 582 visitor->trace(m_messages); |
| 584 visitor->trace(m_client); | 583 visitor->trace(m_client); |
| 585 WebSocketChannel::trace(visitor); | 584 WebSocketChannel::trace(visitor); |
| 586 ContextLifecycleObserver::trace(visitor); | 585 ContextLifecycleObserver::trace(visitor); |
| 587 } | 586 } |
| 588 | 587 |
| 589 } // namespace blink | 588 } // namespace blink |
| OLD | NEW |