Changeset 201880 in webkit
- Timestamp:
- Jun 9, 2016, 1:10:30 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 29 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/websockets/ThreadableWebSocketChannel.h (modified) (1 diff)
-
WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp (modified) (3 diffs)
-
WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h (modified) (3 diffs)
-
WebCore/Modules/websockets/WebSocket.cpp (modified) (6 diffs)
-
WebCore/Modules/websockets/WebSocket.h (modified) (3 diffs)
-
WebCore/Modules/websockets/WebSocketChannel.cpp (modified) (12 diffs)
-
WebCore/Modules/websockets/WebSocketChannel.h (modified) (7 diffs)
-
WebCore/Modules/websockets/WebSocketChannelClient.h (modified) (2 diffs)
-
WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp (modified) (5 diffs)
-
WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h (modified) (3 diffs)
-
WebCore/platform/network/BlobData.cpp (modified) (1 diff)
-
WebCore/platform/network/BlobData.h (modified) (2 diffs)
-
WebCore/platform/network/BlobRegistry.h (modified) (3 diffs)
-
WebCore/platform/network/BlobRegistryImpl.cpp (modified) (2 diffs)
-
WebCore/platform/network/BlobRegistryImpl.h (modified) (1 diff)
-
WebCore/platform/network/SocketStreamHandleBase.cpp (modified) (4 diffs)
-
WebCore/platform/network/SocketStreamHandleBase.h (modified) (2 diffs)
-
WebCore/platform/network/SocketStreamHandleClient.h (modified) (1 diff)
-
WebCore/platform/network/cf/SocketStreamHandle.h (modified) (4 diffs)
-
WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp (modified) (12 diffs)
-
WebCore/platform/network/curl/ResourceHandleCurl.cpp (modified) (1 diff)
-
WebCore/platform/network/curl/SocketStreamHandle.h (modified) (4 diffs)
-
WebCore/platform/network/curl/SocketStreamHandleCurl.cpp (modified) (5 diffs)
-
WebCore/platform/network/soup/SocketStreamHandle.h (modified) (3 diffs)
-
WebCore/platform/network/soup/SocketStreamHandleSoup.cpp (modified) (13 diffs)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp (modified) (1 diff)
-
WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r201877 r201880 1 2016-06-09 Alex Christensen <achristensen@webkit.org> 2 3 Clean up WebSocket code 4 https://bugs.webkit.org/show_bug.cgi?id=158551 5 6 Reviewed by Darin Adler. 7 8 No new tests. There is no change in behavior. 9 There seems to be no reason why SocketStreamHandle should be an AuthenticationClient. 10 11 * Modules/websockets/ThreadableWebSocketChannel.h: 12 * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp: 13 (WebCore::ThreadableWebSocketChannelClientWrapper::setSendRequestResult): 14 (WebCore::ThreadableWebSocketChannelClientWrapper::bufferedAmount): 15 (WebCore::ThreadableWebSocketChannelClientWrapper::setBufferedAmount): 16 (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData): 17 (WebCore::ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount): 18 (WebCore::ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake): 19 (WebCore::ThreadableWebSocketChannelClientWrapper::didClose): 20 * Modules/websockets/ThreadableWebSocketChannelClientWrapper.h: 21 * Modules/websockets/WebSocket.cpp: 22 (WebCore::joinStrings): 23 (WebCore::saturateAdd): 24 (WebCore::WebSocket::send): 25 (WebCore::WebSocket::readyState): 26 (WebCore::WebSocket::bufferedAmount): 27 (WebCore::WebSocket::didReceiveBinaryData): 28 (WebCore::WebSocket::didReceiveMessageError): 29 (WebCore::WebSocket::didUpdateBufferedAmount): 30 (WebCore::WebSocket::didStartClosingHandshake): 31 (WebCore::WebSocket::didClose): 32 * Modules/websockets/WebSocket.h: 33 * Modules/websockets/WebSocketChannel.cpp: 34 (WebCore::WebSocketChannel::WebSocketChannel): 35 (WebCore::WebSocketChannel::~WebSocketChannel): 36 (WebCore::WebSocketChannel::send): 37 (WebCore::WebSocketChannel::bufferedAmount): 38 (WebCore::WebSocketChannel::resume): 39 (WebCore::WebSocketChannel::willOpenSocketStream): 40 (WebCore::WebSocketChannel::didOpenSocketStream): 41 (WebCore::WebSocketChannel::didCloseSocketStream): 42 (WebCore::WebSocketChannel::didReceiveSocketStreamData): 43 (WebCore::WebSocketChannel::didUpdateBufferedAmount): 44 (WebCore::WebSocketChannel::didFailSocketStream): 45 (WebCore::WebSocketChannel::didStartLoading): 46 (WebCore::WebSocketChannel::appendToBuffer): 47 (WebCore::WebSocketChannel::processBuffer): 48 (WebCore::WebSocketChannel::resumeTimerFired): 49 (WebCore::WebSocketChannel::startClosingHandshake): 50 (WebCore::WebSocketChannel::didReceiveAuthenticationChallenge): Deleted. 51 (WebCore::WebSocketChannel::didCancelAuthenticationChallenge): Deleted. 52 * Modules/websockets/WebSocketChannel.h: 53 * Modules/websockets/WebSocketChannelClient.h: 54 (WebCore::WebSocketChannelClient::~WebSocketChannelClient): 55 (WebCore::WebSocketChannelClient::didConnect): 56 (WebCore::WebSocketChannelClient::didReceiveMessage): 57 (WebCore::WebSocketChannelClient::didReceiveBinaryData): 58 (WebCore::WebSocketChannelClient::didReceiveMessageError): 59 (WebCore::WebSocketChannelClient::didUpdateBufferedAmount): 60 (WebCore::WebSocketChannelClient::didStartClosingHandshake): 61 (WebCore::WebSocketChannelClient::didClose): 62 (WebCore::WebSocketChannelClient::WebSocketChannelClient): 63 * Modules/websockets/WorkerThreadableWebSocketChannel.cpp: 64 (WebCore::WorkerThreadableWebSocketChannel::send): 65 (WebCore::WorkerThreadableWebSocketChannel::bufferedAmount): 66 (WebCore::WorkerThreadableWebSocketChannel::Peer::bufferedAmount): 67 (WebCore::WorkerThreadableWebSocketChannel::Peer::didReceiveBinaryData): 68 (WebCore::WorkerThreadableWebSocketChannel::Peer::didUpdateBufferedAmount): 69 (WebCore::WorkerThreadableWebSocketChannel::Peer::didStartClosingHandshake): 70 (WebCore::WorkerThreadableWebSocketChannel::Peer::didClose): 71 (WebCore::WorkerThreadableWebSocketChannel::Bridge::send): 72 (WebCore::WorkerThreadableWebSocketChannel::Bridge::bufferedAmount): 73 * Modules/websockets/WorkerThreadableWebSocketChannel.h: 74 * platform/network/BlobData.cpp: 75 (WebCore::BlobData::appendData): 76 (WebCore::BlobData::appendFile): 77 * platform/network/BlobData.h: 78 (WebCore::BlobDataItem::BlobDataItem): 79 * platform/network/BlobRegistry.h: 80 * platform/network/BlobRegistryImpl.cpp: 81 (WebCore::BlobRegistryImpl::appendStorageItems): 82 (WebCore::BlobRegistryImpl::registerFileBlobURL): 83 (WebCore::BlobRegistryImpl::registerBlobURL): 84 (WebCore::BlobRegistryImpl::registerBlobURLOptionallyFileBacked): 85 (WebCore::BlobRegistryImpl::registerBlobURLForSlice): 86 * platform/network/BlobRegistryImpl.h: 87 * platform/network/SocketStreamHandleBase.cpp: 88 (WebCore::SocketStreamHandleBase::send): 89 (WebCore::SocketStreamHandleBase::disconnect): 90 (WebCore::SocketStreamHandleBase::sendPendingData): 91 * platform/network/SocketStreamHandleBase.h: 92 * platform/network/SocketStreamHandleClient.h: 93 (WebCore::SocketStreamHandleClient::~SocketStreamHandleClient): 94 (WebCore::SocketStreamHandleClient::willOpenSocketStream): 95 (WebCore::SocketStreamHandleClient::didOpenSocketStream): 96 (WebCore::SocketStreamHandleClient::didCloseSocketStream): 97 (WebCore::SocketStreamHandleClient::didReceiveSocketStreamData): 98 (WebCore::SocketStreamHandleClient::didUpdateBufferedAmount): 99 (WebCore::SocketStreamHandleClient::didFailSocketStream): 100 (WebCore::SocketStreamHandleClient::didReceiveAuthenticationChallenge): Deleted. 101 (WebCore::SocketStreamHandleClient::didCancelAuthenticationChallenge): Deleted. 102 * platform/network/cf/SocketStreamHandle.h: 103 (WebCore::SocketStreamHandle::create): 104 (WebCore::SocketStreamHandle::refAuthenticationClient): Deleted. 105 (WebCore::SocketStreamHandle::derefAuthenticationClient): Deleted. 106 * platform/network/cf/SocketStreamHandleCFNet.cpp: 107 (WebCore::SocketStreamHandle::SocketStreamHandle): 108 (WebCore::SocketStreamHandle::addCONNECTCredentials): 109 (WebCore::SocketStreamHandle::copyCFStreamDescription): 110 (WebCore::SocketStreamHandle::readStreamCallback): 111 (WebCore::SocketStreamHandle::writeStreamCallback): 112 (WebCore::SocketStreamHandle::reportErrorToClient): 113 (WebCore::SocketStreamHandle::~SocketStreamHandle): 114 (WebCore::SocketStreamHandle::platformClose): 115 (WebCore::SocketStreamHandle::port): 116 (WebCore::SocketStreamHandle::receivedCredential): Deleted. 117 (WebCore::SocketStreamHandle::receivedRequestToContinueWithoutCredential): Deleted. 118 (WebCore::SocketStreamHandle::receivedCancellation): Deleted. 119 (WebCore::SocketStreamHandle::receivedRequestToPerformDefaultHandling): Deleted. 120 (WebCore::SocketStreamHandle::receivedChallengeRejection): Deleted. 121 * platform/network/curl/ResourceHandleCurl.cpp: 122 * platform/network/curl/SocketStreamHandle.h: 123 (WebCore::SocketStreamHandle::SocketData::SocketData): 124 * platform/network/curl/SocketStreamHandleCurl.cpp: 125 (WebCore::SocketStreamHandle::platformClose): 126 (WebCore::SocketStreamHandle::readData): 127 (WebCore::SocketStreamHandle::didReceiveData): 128 (WebCore::SocketStreamHandle::didOpenSocket): 129 (WebCore::SocketStreamHandle::createCopy): 130 (WebCore::SocketStreamHandle::didReceiveAuthenticationChallenge): Deleted. 131 (WebCore::SocketStreamHandle::receivedCredential): Deleted. 132 (WebCore::SocketStreamHandle::receivedRequestToContinueWithoutCredential): Deleted. 133 (WebCore::SocketStreamHandle::receivedCancellation): Deleted. 134 (WebCore::SocketStreamHandle::receivedRequestToPerformDefaultHandling): Deleted. 135 (WebCore::SocketStreamHandle::receivedChallengeRejection): Deleted. 136 * platform/network/soup/SocketStreamHandle.h: 137 (WebCore::SocketStreamHandle::create): 138 * platform/network/soup/SocketStreamHandleSoup.cpp: 139 (WebCore::getHandleFromId): 140 (WebCore::deactivateHandle): 141 (WebCore::activateHandle): 142 (WebCore::SocketStreamHandle::SocketStreamHandle): 143 (WebCore::SocketStreamHandle::~SocketStreamHandle): 144 (WebCore::SocketStreamHandle::connected): 145 (WebCore::SocketStreamHandle::readBytes): 146 (WebCore::SocketStreamHandle::platformSend): 147 (WebCore::SocketStreamHandle::platformClose): 148 (WebCore::SocketStreamHandle::beginWaitingForSocketWritability): 149 (WebCore::SocketStreamHandle::didReceiveAuthenticationChallenge): Deleted. 150 (WebCore::SocketStreamHandle::receivedCredential): Deleted. 151 (WebCore::SocketStreamHandle::receivedRequestToContinueWithoutCredential): Deleted. 152 (WebCore::SocketStreamHandle::receivedCancellation): Deleted. 153 (WebCore::SocketStreamHandle::receivedRequestToPerformDefaultHandling): Deleted. 154 (WebCore::SocketStreamHandle::receivedChallengeRejection): Deleted. 155 1 156 2016-06-09 Commit Queue <commit-queue@webkit.org> 2 157 -
trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.h
r201837 r201880 66 66 virtual SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) = 0; 67 67 virtual SendResult send(Blob&) = 0; 68 virtual unsigned longbufferedAmount() const = 0;68 virtual unsigned bufferedAmount() const = 0; 69 69 virtual void close(int code, const String& reason) = 0; 70 70 // Log the reason text and close the connection. Will call didClose(). -
trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp
r201837 r201880 137 137 } 138 138 139 unsigned longThreadableWebSocketChannelClientWrapper::bufferedAmount() const139 unsigned ThreadableWebSocketChannelClientWrapper::bufferedAmount() const 140 140 { 141 141 return m_bufferedAmount; 142 142 } 143 143 144 void ThreadableWebSocketChannelClientWrapper::setBufferedAmount(unsigned longbufferedAmount)144 void ThreadableWebSocketChannelClientWrapper::setBufferedAmount(unsigned bufferedAmount) 145 145 { 146 146 m_bufferedAmount = bufferedAmount; … … 186 186 } 187 187 188 void ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount(unsigned longbufferedAmount)188 void ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount(unsigned bufferedAmount) 189 189 { 190 190 m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this), bufferedAmount] (ScriptExecutionContext&) { … … 208 208 } 209 209 210 void ThreadableWebSocketChannelClientWrapper::didClose(unsigned longunhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason)210 void ThreadableWebSocketChannelClientWrapper::didClose(unsigned unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason) 211 211 { 212 212 m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this), unhandledBufferedAmount, closingHandshakeCompletion, code, reason = reason.isolatedCopy()] (ScriptExecutionContext&) { -
trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.h
r201837 r201880 72 72 void setSendRequestResult(ThreadableWebSocketChannel::SendResult); 73 73 74 unsigned longbufferedAmount() const;75 void setBufferedAmount(unsigned long);74 unsigned bufferedAmount() const; 75 void setBufferedAmount(unsigned); 76 76 77 77 void clearClient(); … … 80 80 void didReceiveMessage(const String& message); 81 81 void didReceiveBinaryData(Vector<uint8_t>&&); 82 void didUpdateBufferedAmount(unsigned longbufferedAmount);82 void didUpdateBufferedAmount(unsigned bufferedAmount); 83 83 void didStartClosingHandshake(); 84 void didClose(unsigned longunhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);84 void didClose(unsigned unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason); 85 85 void didReceiveMessageError(); 86 86 … … 102 102 Vector<UChar> m_extensions; 103 103 ThreadableWebSocketChannel::SendResult m_sendRequestResult; 104 unsigned longm_bufferedAmount;104 unsigned m_bufferedAmount; 105 105 bool m_suspended; 106 106 Vector<std::unique_ptr<ScriptExecutionContext::Task>> m_pendingTasks; -
trunk/Source/WebCore/Modules/websockets/WebSocket.cpp
r201837 r201880 116 116 } 117 117 118 static unsigned long saturateAdd(unsigned long a, unsigned longb)119 { 120 if (std::numeric_limits<unsigned long>::max() - a < b)121 return std::numeric_limits<unsigned long>::max();118 static unsigned saturateAdd(unsigned a, unsigned b) 119 { 120 if (std::numeric_limits<unsigned>::max() - a < b) 121 return std::numeric_limits<unsigned>::max(); 122 122 return a + b; 123 123 } … … 370 370 } 371 371 if (m_state == CLOSING || m_state == CLOSED) { 372 unsigned long payloadSize = static_cast<unsigned long>(binaryData.size());372 unsigned payloadSize = static_cast<unsigned>(binaryData.size()); 373 373 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, payloadSize); 374 374 m_bufferedAmountAfterClose = saturateAdd(m_bufferedAmountAfterClose, getFramingOverhead(payloadSize)); … … 420 420 } 421 421 422 unsigned longWebSocket::bufferedAmount() const422 unsigned WebSocket::bufferedAmount() const 423 423 { 424 424 return saturateAdd(m_bufferedAmount, m_bufferedAmountAfterClose); … … 567 567 void WebSocket::didReceiveBinaryData(Vector<uint8_t>&& binaryData) 568 568 { 569 LOG(Network, "WebSocket %p didReceiveBinaryData() % lu byte binary message", this, static_cast<unsigned long>(binaryData.size()));569 LOG(Network, "WebSocket %p didReceiveBinaryData() %u byte binary message", this, static_cast<unsigned>(binaryData.size())); 570 570 switch (m_binaryType) { 571 571 case BinaryTypeBlob: … … 587 587 } 588 588 589 void WebSocket::didUpdateBufferedAmount(unsigned longbufferedAmount)590 { 591 LOG(Network, "WebSocket %p didUpdateBufferedAmount() New bufferedAmount is % lu", this, bufferedAmount);589 void WebSocket::didUpdateBufferedAmount(unsigned bufferedAmount) 590 { 591 LOG(Network, "WebSocket %p didUpdateBufferedAmount() New bufferedAmount is %u", this, bufferedAmount); 592 592 if (m_state == CLOSED) 593 593 return; … … 601 601 } 602 602 603 void WebSocket::didClose(unsigned longunhandledBufferedAmount, ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason)603 void WebSocket::didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason) 604 604 { 605 605 LOG(Network, "WebSocket %p didClose()", this); -
trunk/Source/WebCore/Modules/websockets/WebSocket.h
r200298 r201880 81 81 const URL& url() const; 82 82 State readyState() const; 83 unsigned longbufferedAmount() const;83 unsigned bufferedAmount() const; 84 84 85 85 String protocol() const; … … 101 101 void didReceiveBinaryData(Vector<uint8_t>&&) override; 102 102 void didReceiveMessageError() override; 103 void didUpdateBufferedAmount(unsigned longbufferedAmount) override;103 void didUpdateBufferedAmount(unsigned bufferedAmount) override; 104 104 void didStartClosingHandshake() override; 105 void didClose(unsigned longunhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override;105 void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override; 106 106 107 107 private: … … 134 134 State m_state; 135 135 URL m_url; 136 unsigned longm_bufferedAmount;137 unsigned longm_bufferedAmountAfterClose;136 unsigned m_bufferedAmount; 137 unsigned m_bufferedAmountAfterClose; 138 138 BinaryType m_binaryType; 139 139 String m_subprotocol; -
trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp
r201837 r201880 69 69 , m_client(&client) 70 70 , m_resumeTimer(*this, &WebSocketChannel::resumeTimerFired) 71 , m_suspended(false)72 , m_closing(false)73 , m_receivedClosingHandshake(false)74 71 , m_closingTimer(*this, &WebSocketChannel::closingTimerFired) 75 , m_closed(false)76 , m_shouldDiscardReceivedData(false)77 , m_unhandledBufferedAmount(0)78 , m_identifier(0)79 , m_hasContinuousFrame(false)80 , m_closeEventCode(CloseEventCodeAbnormalClosure)81 , m_outgoingFrameQueueStatus(OutgoingFrameQueueOpen)82 , m_blobLoaderStatus(BlobLoaderNotStarted)83 72 { 84 73 if (Page* page = document.page()) 85 74 m_identifier = page->progress().createUniqueIdentifier(); 86 75 87 LOG(Network, "WebSocketChannel %p ctor, identifier % lu", this, m_identifier);76 LOG(Network, "WebSocketChannel %p ctor, identifier %u", this, m_identifier); 88 77 } 89 78 … … 175 164 } 176 165 177 unsigned longWebSocketChannel::bufferedAmount() const166 unsigned WebSocketChannel::bufferedAmount() const 178 167 { 179 168 LOG(Network, "WebSocketChannel %p bufferedAmount()", this); … … 254 243 } 255 244 256 void WebSocketChannel::willOpenSocketStream(SocketStreamHandle *)245 void WebSocketChannel::willOpenSocketStream(SocketStreamHandle&) 257 246 { 258 247 LOG(Network, "WebSocketChannel %p willOpenSocketStream()", this); 259 248 } 260 249 261 void WebSocketChannel::didOpenSocketStream(SocketStreamHandle *handle)250 void WebSocketChannel::didOpenSocketStream(SocketStreamHandle& handle) 262 251 { 263 252 LOG(Network, "WebSocketChannel %p didOpenSocketStream()", this); 264 ASSERT( handle == m_handle);253 ASSERT(&handle == m_handle); 265 254 if (!m_document) 266 255 return; … … 268 257 InspectorInstrumentation::willSendWebSocketHandshakeRequest(m_document, m_identifier, m_handshake->clientHandshakeRequest()); 269 258 CString handshakeMessage = m_handshake->clientHandshakeMessage(); 270 if (!handle ->send(handshakeMessage.data(), handshakeMessage.length()))259 if (!handle.send(handshakeMessage.data(), handshakeMessage.length())) 271 260 fail("Failed to send WebSocket handshake."); 272 261 } 273 262 274 void WebSocketChannel::didCloseSocketStream(SocketStreamHandle *handle)263 void WebSocketChannel::didCloseSocketStream(SocketStreamHandle& handle) 275 264 { 276 265 LOG(Network, "WebSocketChannel %p didCloseSocketStream()", this); 277 266 if (m_identifier && m_document) 278 267 InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier); 279 ASSERT_UNUSED(handle, handle == m_handle || !m_handle);268 ASSERT_UNUSED(handle, &handle == m_handle || !m_handle); 280 269 m_closed = true; 281 270 if (m_closingTimer.isActive()) … … 297 286 } 298 287 299 void WebSocketChannel::didReceiveSocketStreamData(SocketStreamHandle *handle, const char* data, int len)288 void WebSocketChannel::didReceiveSocketStreamData(SocketStreamHandle& handle, const char* data, int len) 300 289 { 301 290 LOG(Network, "WebSocketChannel %p didReceiveSocketStreamData() Received %d bytes", this, len); 302 291 Ref<WebSocketChannel> protectedThis(*this); // The client can close the channel, potentially removing the last reference. 303 ASSERT( handle == m_handle);292 ASSERT(&handle == m_handle); 304 293 if (!m_document) { 305 294 return; 306 295 } 307 296 if (len <= 0) { 308 handle ->disconnect();297 handle.disconnect(); 309 298 return; 310 299 } 311 300 if (!m_client) { 312 301 m_shouldDiscardReceivedData = true; 313 handle ->disconnect();302 handle.disconnect(); 314 303 return; 315 304 } … … 326 315 } 327 316 328 void WebSocketChannel::didUpdateBufferedAmount(SocketStreamHandle *, size_t bufferedAmount)317 void WebSocketChannel::didUpdateBufferedAmount(SocketStreamHandle&, size_t bufferedAmount) 329 318 { 330 319 if (m_client) … … 332 321 } 333 322 334 void WebSocketChannel::didFailSocketStream(SocketStreamHandle *handle, const SocketStreamError& error)323 void WebSocketChannel::didFailSocketStream(SocketStreamHandle& handle, const SocketStreamError& error) 335 324 { 336 325 LOG(Network, "WebSocketChannel %p didFailSocketStream()", this); 337 ASSERT( handle == m_handle || !m_handle);326 ASSERT(&handle == m_handle || !m_handle); 338 327 if (m_document) { 339 328 String message; … … 348 337 } 349 338 m_shouldDiscardReceivedData = true; 350 handle->disconnect(); 351 } 352 353 void WebSocketChannel::didReceiveAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) 354 { 355 } 356 357 void WebSocketChannel::didCancelAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) 358 { 339 handle.disconnect(); 359 340 } 360 341 … … 398 379 size_t newBufferSize = m_buffer.size() + len; 399 380 if (newBufferSize < m_buffer.size()) { 400 LOG(Network, "WebSocketChannel %p appendToBuffer() Buffer overflow (% lu bytes already in receive buffer and appending %lu bytes)", this, static_cast<unsigned long>(m_buffer.size()), static_cast<unsigned long>(len));381 LOG(Network, "WebSocketChannel %p appendToBuffer() Buffer overflow (%u bytes already in receive buffer and appending %u bytes)", this, static_cast<unsigned>(m_buffer.size()), static_cast<unsigned>(len)); 401 382 return false; 402 383 } … … 417 398 ASSERT(m_client); 418 399 ASSERT(!m_buffer.isEmpty()); 419 LOG(Network, "WebSocketChannel %p processBuffer() Receive buffer has % lu bytes", this, static_cast<unsigned long>(m_buffer.size()));400 LOG(Network, "WebSocketChannel %p processBuffer() Receive buffer has %u bytes", this, static_cast<unsigned>(m_buffer.size())); 420 401 421 402 if (m_shouldDiscardReceivedData) … … 446 427 skipBuffer(headerLength); 447 428 m_client->didConnect(); 448 LOG(Network, "WebSocketChannel %p % lu bytes remaining in m_buffer", this, static_cast<unsigned long>(m_buffer.size()));429 LOG(Network, "WebSocketChannel %p %u bytes remaining in m_buffer", this, static_cast<unsigned>(m_buffer.size())); 449 430 return !m_buffer.isEmpty(); 450 431 } … … 469 450 break; 470 451 if (!m_suspended && m_client && m_closed && m_handle) 471 didCloseSocketStream( m_handle.get());452 didCloseSocketStream(*m_handle); 472 453 } 473 454 -
trunk/Source/WebCore/Modules/websockets/WebSocketChannel.h
r201837 r201880 29 29 */ 30 30 31 #ifndef WebSocketChannel_h 32 #define WebSocketChannel_h 31 #pragma once 33 32 34 33 #if ENABLE(WEB_SOCKETS) … … 40 39 #include "WebSocketDeflateFramer.h" 41 40 #include "WebSocketFrame.h" 42 #include "WebSocketHandshake.h"43 41 #include <wtf/Deque.h> 44 42 #include <wtf/Forward.h> … … 55 53 class SocketStreamError; 56 54 class WebSocketChannelClient; 55 class WebSocketHandshake; 57 56 58 57 class WebSocketChannel : public RefCounted<WebSocketChannel>, public SocketStreamHandleClient, public ThreadableWebSocketChannel, public FileReaderLoaderClient … … 72 71 ThreadableWebSocketChannel::SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) override; 73 72 ThreadableWebSocketChannel::SendResult send(Blob&) override; 74 unsigned longbufferedAmount() const override;73 unsigned bufferedAmount() const override; 75 74 void close(int code, const String& reason) override; // Start closing handshake. 76 75 void fail(const String& reason) override; … … 81 80 82 81 // SocketStreamHandleClient functions. 83 void willOpenSocketStream(SocketStreamHandle*) override; 84 void didOpenSocketStream(SocketStreamHandle*) override; 85 void didCloseSocketStream(SocketStreamHandle*) override; 86 void didReceiveSocketStreamData(SocketStreamHandle*, const char*, int) override; 87 void didUpdateBufferedAmount(SocketStreamHandle*, size_t bufferedAmount) override; 88 void didFailSocketStream(SocketStreamHandle*, const SocketStreamError&) override; 89 void didReceiveAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) override; 90 void didCancelAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) override; 82 void willOpenSocketStream(SocketStreamHandle&) override; 83 void didOpenSocketStream(SocketStreamHandle&) override; 84 void didCloseSocketStream(SocketStreamHandle&) override; 85 void didReceiveSocketStreamData(SocketStreamHandle&, const char*, int) override; 86 void didUpdateBufferedAmount(SocketStreamHandle&, size_t bufferedAmount) override; 87 void didFailSocketStream(SocketStreamHandle&, const SocketStreamError&) override; 91 88 92 89 enum CloseEventCode { … … 192 189 193 190 Timer m_resumeTimer; 194 bool m_suspended ;195 bool m_closing ;196 bool m_receivedClosingHandshake ;191 bool m_suspended { false }; 192 bool m_closing { false }; 193 bool m_receivedClosingHandshake { false }; 197 194 Timer m_closingTimer; 198 bool m_closed ;199 bool m_shouldDiscardReceivedData ;200 unsigned long m_unhandledBufferedAmount;201 202 unsigned long m_identifier; // m_identifier == 0 means that we could not obtain a valid identifier.195 bool m_closed { false }; 196 bool m_shouldDiscardReceivedData { false }; 197 unsigned m_unhandledBufferedAmount { 0 }; 198 199 unsigned m_identifier { 0 }; // m_identifier == 0 means that we could not obtain a valid identifier. 203 200 204 201 // Private members only for hybi-10 protocol. 205 bool m_hasContinuousFrame ;202 bool m_hasContinuousFrame { false }; 206 203 WebSocketFrame::OpCode m_continuousFrameOpCode; 207 204 Vector<uint8_t> m_continuousFrameData; 208 unsigned short m_closeEventCode ;205 unsigned short m_closeEventCode { CloseEventCodeAbnormalClosure }; 209 206 String m_closeEventReason; 210 207 211 208 Deque<std::unique_ptr<QueuedFrame>> m_outgoingFrameQueue; 212 OutgoingFrameQueueStatus m_outgoingFrameQueueStatus ;209 OutgoingFrameQueueStatus m_outgoingFrameQueueStatus { OutgoingFrameQueueOpen }; 213 210 214 211 // FIXME: Load two or more Blobs simultaneously for better performance. 215 212 std::unique_ptr<FileReaderLoader> m_blobLoader; 216 BlobLoaderStatus m_blobLoaderStatus ;213 BlobLoaderStatus m_blobLoaderStatus { BlobLoaderNotStarted }; 217 214 218 215 WebSocketDeflateFramer m_deflateFramer; … … 222 219 223 220 #endif // ENABLE(WEB_SOCKETS) 224 225 #endif // WebSocketChannel_h -
trunk/Source/WebCore/Modules/websockets/WebSocketChannelClient.h
r198869 r201880 29 29 */ 30 30 31 #ifndef WebSocketChannelClient_h 32 #define WebSocketChannelClient_h 31 #pragma once 33 32 34 33 #if ENABLE(WEB_SOCKETS) … … 39 38 namespace WebCore { 40 39 41 class WebSocketChannelClient {42 public:43 virtual ~WebSocketChannelClient() { }44 virtual void didConnect() { }45 virtual void didReceiveMessage(const String&) { }46 virtual void didReceiveBinaryData(Vector<uint8_t>&&) { }47 virtual void didReceiveMessageError() { }48 virtual void didUpdateBufferedAmount(unsigned long/* bufferedAmount */) { }49 virtual void didStartClosingHandshake() { }50 enum ClosingHandshakeCompletionStatus {51 ClosingHandshakeIncomplete,52 ClosingHandshakeComplete53 };54 virtual void didClose(unsigned long/* unhandledBufferedAmount */, ClosingHandshakeCompletionStatus, unsigned short /* code */, const String& /* reason */) { }40 class WebSocketChannelClient { 41 public: 42 virtual ~WebSocketChannelClient() { } 43 virtual void didConnect() { } 44 virtual void didReceiveMessage(const String&) { } 45 virtual void didReceiveBinaryData(Vector<uint8_t>&&) { } 46 virtual void didReceiveMessageError() { } 47 virtual void didUpdateBufferedAmount(unsigned /* bufferedAmount */) { } 48 virtual void didStartClosingHandshake() { } 49 enum ClosingHandshakeCompletionStatus { 50 ClosingHandshakeIncomplete, 51 ClosingHandshakeComplete 52 }; 53 virtual void didClose(unsigned /* unhandledBufferedAmount */, ClosingHandshakeCompletionStatus, unsigned short /* code */, const String& /* reason */) { } 55 54 56 protected:57 WebSocketChannelClient() { }58 };55 protected: 56 WebSocketChannelClient() { } 57 }; 59 58 60 59 } // namespace WebCore 61 60 62 61 #endif // ENABLE(WEB_SOCKETS) 63 64 #endif // WebSocketChannelClient_h -
trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp
r201837 r201880 102 102 } 103 103 104 unsigned longWorkerThreadableWebSocketChannel::bufferedAmount() const104 unsigned WorkerThreadableWebSocketChannel::bufferedAmount() const 105 105 { 106 106 if (!m_bridge) … … 207 207 return; 208 208 209 unsigned longbufferedAmount = m_mainWebSocketChannel->bufferedAmount();209 unsigned bufferedAmount = m_mainWebSocketChannel->bufferedAmount(); 210 210 m_loaderProxy.postTaskForModeToWorkerGlobalScope([workerClientWrapper = m_workerClientWrapper.copyRef(), bufferedAmount](ScriptExecutionContext& context) mutable { 211 211 ASSERT_UNUSED(context, context.isWorkerGlobalScope()); … … 289 289 } 290 290 291 void WorkerThreadableWebSocketChannel::Peer::didUpdateBufferedAmount(unsigned longbufferedAmount)291 void WorkerThreadableWebSocketChannel::Peer::didUpdateBufferedAmount(unsigned bufferedAmount) 292 292 { 293 293 ASSERT(isMainThread()); … … 309 309 } 310 310 311 void WorkerThreadableWebSocketChannel::Peer::didClose(unsigned longunhandledBufferedAmount, ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason)311 void WorkerThreadableWebSocketChannel::Peer::didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason) 312 312 { 313 313 ASSERT(isMainThread()); … … 462 462 } 463 463 464 unsigned longWorkerThreadableWebSocketChannel::Bridge::bufferedAmount()464 unsigned WorkerThreadableWebSocketChannel::Bridge::bufferedAmount() 465 465 { 466 466 if (!m_peer) -
trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.h
r201837 r201880 67 67 ThreadableWebSocketChannel::SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength) override; 68 68 ThreadableWebSocketChannel::SendResult send(Blob&) override; 69 unsigned longbufferedAmount() const override;69 unsigned bufferedAmount() const override; 70 70 void close(int code, const String& reason) override; 71 71 void fail(const String& reason) override; … … 97 97 void didReceiveMessage(const String& message) override; 98 98 void didReceiveBinaryData(Vector<uint8_t>&&) override; 99 void didUpdateBufferedAmount(unsigned longbufferedAmount) override;99 void didUpdateBufferedAmount(unsigned bufferedAmount) override; 100 100 void didStartClosingHandshake() override; 101 void didClose(unsigned longunhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override;101 void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason) override; 102 102 void didReceiveMessageError() override; 103 103 … … 130 130 ThreadableWebSocketChannel::SendResult send(const JSC::ArrayBuffer&, unsigned byteOffset, unsigned byteLength); 131 131 ThreadableWebSocketChannel::SendResult send(Blob&); 132 unsigned longbufferedAmount();132 unsigned bufferedAmount(); 133 133 void close(int code, const String& reason); 134 134 void fail(const String& reason); -
trunk/Source/WebCore/platform/network/BlobData.cpp
r198869 r201880 76 76 } 77 77 78 void BlobData::appendFile( PassRefPtr<BlobDataFileReference>file)78 void BlobData::appendFile(Ref<BlobDataFileReference>&& file) 79 79 { 80 80 file->startTrackingModifications(); 81 m_items.append(BlobDataItem( file));81 m_items.append(BlobDataItem(WTFMove(file))); 82 82 } 83 83 -
trunk/Source/WebCore/platform/network/BlobData.h
r198869 r201880 65 65 friend class BlobData; 66 66 67 explicit BlobDataItem( PassRefPtr<BlobDataFileReference>file)67 explicit BlobDataItem(Ref<BlobDataFileReference>&& file) 68 68 : m_type(Type::File) 69 , m_file( file)69 , m_file(WTFMove(file)) 70 70 , m_offset(0) 71 71 , m_length(toEndOfFile) … … 112 112 113 113 void appendData(const ThreadSafeDataBuffer&); 114 void appendFile( PassRefPtr<BlobDataFileReference>);114 void appendFile(Ref<BlobDataFileReference>&&); 115 115 116 116 private: -
trunk/Source/WebCore/platform/network/BlobRegistry.h
r201717 r201880 29 29 */ 30 30 31 #ifndef BlobRegistry_h 32 #define BlobRegistry_h 31 #pragma once 33 32 34 33 #include <functional> … … 51 50 52 51 // Registers a blob URL referring to the specified file. 53 virtual void registerFileBlobURL(const URL&, Ref Ptr<BlobDataFileReference>&&, const String& contentType) = 0;52 virtual void registerFileBlobURL(const URL&, Ref<BlobDataFileReference>&&, const String& contentType) = 0; 54 53 55 54 // Registers a blob URL referring to the specified blob data. … … 78 77 79 78 } // namespace WebCore 80 81 #endif // BlobRegistry_h -
trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp
r201761 r201880 111 111 } 112 112 113 void BlobRegistryImpl::registerFileBlobURL(const URL& url, Ref Ptr<BlobDataFileReference>&& file, const String& contentType)113 void BlobRegistryImpl::registerFileBlobURL(const URL& url, Ref<BlobDataFileReference>&& file, const String& contentType) 114 114 { 115 115 ASSERT(isMainThread()); 116 116 registerBlobResourceHandleConstructor(); 117 117 118 RefPtr<BlobData> blobData = BlobData::create(contentType); 119 120 blobData->appendFile(file); 121 m_blobs.set(url.string(), blobData.release()); 118 auto blobData = BlobData::create(contentType); 119 blobData->appendFile(WTFMove(file)); 120 m_blobs.set(url.string(), WTFMove(blobData)); 122 121 } 123 122 … … 172 171 } 173 172 174 if ( file == nullptr|| file->path().isEmpty())173 if (!file || file->path().isEmpty()) 175 174 return; 176 175 177 RefPtr<BlobData>backingFile = BlobData::create({ });178 backingFile->appendFile( WTFMove(file));179 180 m_blobs.set(url.string(), backingFile.release());176 auto backingFile = BlobData::create({ }); 177 backingFile->appendFile(file.releaseNonNull()); 178 179 m_blobs.set(url.string(), WTFMove(backingFile)); 181 180 } 182 181 -
trunk/Source/WebCore/platform/network/BlobRegistryImpl.h
r201761 r201880 58 58 void appendStorageItems(BlobData*, const BlobDataItemList&, long long offset, long long length); 59 59 60 void registerFileBlobURL(const URL&, Ref Ptr<BlobDataFileReference>&&, const String& contentType) override;60 void registerFileBlobURL(const URL&, Ref<BlobDataFileReference>&&, const String& contentType) override; 61 61 void registerBlobURL(const URL&, Vector<BlobPart>, const String& contentType) override; 62 62 void registerBlobURL(const URL&, const URL& srcURL) override; -
trunk/Source/WebCore/platform/network/SocketStreamHandleBase.cpp
r156550 r201880 62 62 m_buffer.append(data, length); 63 63 if (m_client) 64 m_client->didUpdateBufferedAmount(static_cast<SocketStreamHandle *>(this), bufferedAmount());64 m_client->didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount()); 65 65 return true; 66 66 } … … 77 77 m_buffer.append(data + bytesWritten, length - bytesWritten); 78 78 if (m_client) 79 m_client->didUpdateBufferedAmount(static_cast<SocketStreamHandle *>(this), bufferedAmount());79 m_client->didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount()); 80 80 } 81 81 return true; … … 94 94 void SocketStreamHandleBase::disconnect() 95 95 { 96 Ref<SocketStreamHandle> protect( *static_cast<SocketStreamHandle*>(this)); // platformClose calls the client, which may make the handle get deallocated immediately.96 Ref<SocketStreamHandle> protect(static_cast<SocketStreamHandle&>(*this)); // platformClose calls the client, which may make the handle get deallocated immediately. 97 97 98 98 platformClose(); … … 128 128 } while (!pending && !m_buffer.isEmpty()); 129 129 if (m_client) 130 m_client->didUpdateBufferedAmount(static_cast<SocketStreamHandle *>(this), bufferedAmount());130 m_client->didUpdateBufferedAmount(static_cast<SocketStreamHandle&>(*this), bufferedAmount()); 131 131 return true; 132 132 } -
trunk/Source/WebCore/platform/network/SocketStreamHandleBase.h
r156550 r201880 30 30 */ 31 31 32 #ifndef SocketStreamHandleBase_h 33 #define SocketStreamHandleBase_h 32 #pragma once 34 33 35 34 #include "URL.h" 36 37 35 #include <wtf/StreamBuffer.h> 38 36 … … 70 68 71 69 } // namespace WebCore 72 73 #endif // SocketStreamHandleBase_h -
trunk/Source/WebCore/platform/network/SocketStreamHandleClient.h
r156550 r201880 30 30 */ 31 31 32 #ifndef SocketStreamHandleClient_h 33 #define SocketStreamHandleClient_h 32 #pragma once 34 33 35 34 namespace WebCore { 36 35 37 class AuthenticationChallenge; 38 class URL; 39 class SocketStreamError; 40 class SocketStreamHandle; 36 class SocketStreamError; 37 class SocketStreamHandle; 41 38 42 class SocketStreamHandleClient {43 public:44 virtual ~SocketStreamHandleClient() { }39 class SocketStreamHandleClient { 40 public: 41 virtual ~SocketStreamHandleClient() { } 45 42 46 virtual void willOpenSocketStream(SocketStreamHandle*) { }47 virtual void didOpenSocketStream(SocketStreamHandle*) { }48 virtual void didCloseSocketStream(SocketStreamHandle*) { }49 virtual void didReceiveSocketStreamData(SocketStreamHandle*, const char* /*data*/, int /*length*/) { }50 virtual void didUpdateBufferedAmount(SocketStreamHandle*, size_t /*bufferedAmount*/) { }43 virtual void willOpenSocketStream(SocketStreamHandle&) { } 44 virtual void didOpenSocketStream(SocketStreamHandle&) { } 45 virtual void didCloseSocketStream(SocketStreamHandle&) { } 46 virtual void didReceiveSocketStreamData(SocketStreamHandle&, const char* /*data*/, int /*length*/) { } 47 virtual void didUpdateBufferedAmount(SocketStreamHandle&, size_t /*bufferedAmount*/) { } 51 48 52 virtual void didFailSocketStream(SocketStreamHandle*, const SocketStreamError&) { } 49 virtual void didFailSocketStream(SocketStreamHandle&, const SocketStreamError&) { } 50 }; 53 51 54 // No authentication for streams per se, but proxy may ask for credentials. 55 virtual void didReceiveAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) { } 56 virtual void didCancelAuthenticationChallenge(SocketStreamHandle*, const AuthenticationChallenge&) { } 57 }; 58 59 } // namespace WebCore 60 61 #endif // SocketStreamHandleClient_h 52 } // namespace WebCore -
trunk/Source/WebCore/platform/network/cf/SocketStreamHandle.h
r199039 r201880 30 30 */ 31 31 32 #ifndef SocketStreamHandle_h 33 #define SocketStreamHandle_h 32 #pragma once 34 33 35 #include "AuthenticationClient.h"36 34 #include "SocketStreamHandleBase.h" 37 35 #include <wtf/RetainPtr.h> … … 48 46 class SocketStreamHandleClient; 49 47 50 class SocketStreamHandle : public ThreadSafeRefCounted<SocketStreamHandle>, public SocketStreamHandleBase , public AuthenticationClient{48 class SocketStreamHandle : public ThreadSafeRefCounted<SocketStreamHandle>, public SocketStreamHandleBase { 51 49 public: 52 static PassRefPtr<SocketStreamHandle> create(const URL& url, SocketStreamHandleClient* client, NetworkingContext& networkingContext, bool usesEphemeralSession) { return adoptRef(new SocketStreamHandle(url, client, networkingContext, usesEphemeralSession)); }50 static Ref<SocketStreamHandle> create(const URL& url, SocketStreamHandleClient* client, NetworkingContext& networkingContext, bool usesEphemeralSession) { return adoptRef(*new SocketStreamHandle(url, client, networkingContext, usesEphemeralSession)); } 53 51 54 52 virtual ~SocketStreamHandle(); 55 56 using ThreadSafeRefCounted<SocketStreamHandle>::ref;57 using ThreadSafeRefCounted<SocketStreamHandle>::deref;58 53 59 54 private: … … 89 84 bool getStoredCONNECTProxyCredentials(const ProtectionSpace&, String& login, String& password); 90 85 91 // No authentication for streams per se, but proxy may ask for credentials.92 virtual void receivedCredential(const AuthenticationChallenge&, const Credential&);93 virtual void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);94 virtual void receivedCancellation(const AuthenticationChallenge&);95 virtual void receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&);96 virtual void receivedChallengeRejection(const AuthenticationChallenge&);97 98 virtual void refAuthenticationClient() { ref(); }99 virtual void derefAuthenticationClient() { deref(); }100 101 86 enum ConnectingSubstate { New, ExecutingPACFile, WaitingForCredentials, WaitingForConnect, Connected }; 102 87 ConnectingSubstate m_connectingSubstate; … … 118 103 119 104 } // namespace WebCore 120 121 #endif // SocketStreamHandle_h -
trunk/Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp
r201500 r201880 88 88 && !usesEphemeralSession 89 89 && _CFNetworkIsKnownHSTSHostWithSession(m_httpsURL.get(), nullptr)) { 90 m_client->didFailSocketStream( this, SocketStreamError(0, m_url.string(), "WebSocket connection failed because it violates HTTP Strict Transport Security."));90 m_client->didFailSocketStream(*this, SocketStreamError(0, m_url.string(), "WebSocket connection failed because it violates HTTP Strict Transport Security.")); 91 91 return; 92 92 } … … 389 389 if (!CFHTTPAuthenticationRequiresUserNameAndPassword(authentication.get())) { 390 390 // That's all we can offer... 391 m_client->didFailSocketStream( this, SocketStreamError(0, m_url.string(), "Proxy authentication scheme is not supported for WebSockets"));391 m_client->didFailSocketStream(*this, SocketStreamError(0, m_url.string(), "Proxy authentication scheme is not supported for WebSockets")); 392 392 return; 393 393 } … … 400 400 if (!methodCF || !realmCF) { 401 401 // This shouldn't happen, but on some OS versions we get incomplete authentication data, see <rdar://problem/10416316>. 402 m_client->didFailSocketStream( this, SocketStreamError(0, m_url.string(), "WebSocket proxy authentication couldn't be handled"));402 m_client->didFailSocketStream(*this, SocketStreamError(0, m_url.string(), "WebSocket proxy authentication couldn't be handled")); 403 403 return; 404 404 } … … 419 419 if (!proxyAuthorizationString) { 420 420 // Fails e.g. for NTLM auth. 421 m_client->didFailSocketStream( this, SocketStreamError(0, m_url.string(), "Proxy authentication scheme is not supported for WebSockets"));421 m_client->didFailSocketStream(*this, SocketStreamError(0, m_url.string(), "Proxy authentication scheme is not supported for WebSockets")); 422 422 return; 423 423 } … … 431 431 // FIXME: On platforms where AuthBrokerAgent is not available, ask the client if credentials could not be found. 432 432 433 m_client->didFailSocketStream( this, SocketStreamError(0, m_url.string(), "Proxy credentials are not available"));433 m_client->didFailSocketStream(*this, SocketStreamError(0, m_url.string(), "Proxy credentials are not available")); 434 434 } 435 435 … … 506 506 return; 507 507 default: 508 m_client->didFailSocketStream( this, SocketStreamError(static_cast<int>(proxyResponseCode), m_url.string(), "Proxy connection could not be established, unexpected response code"));508 m_client->didFailSocketStream(*this, SocketStreamError(static_cast<int>(proxyResponseCode), m_url.string(), "Proxy connection could not be established, unexpected response code")); 509 509 platformClose(); 510 510 return; … … 513 513 m_connectingSubstate = Connected; 514 514 m_state = Open; 515 m_client->didOpenSocketStream( this);515 m_client->didOpenSocketStream(*this); 516 516 } 517 517 … … 534 534 return; 535 535 536 m_client->didReceiveSocketStreamData( this, reinterpret_cast<const char*>(ptr), length);536 m_client->didReceiveSocketStreamData(*this, reinterpret_cast<const char*>(ptr), length); 537 537 538 538 return; … … 584 584 m_connectingSubstate = Connected; 585 585 m_state = Open; 586 m_client->didOpenSocketStream( this);586 m_client->didOpenSocketStream(*this); 587 587 } 588 588 … … 637 637 } 638 638 639 m_client->didFailSocketStream( this, SocketStreamError(static_cast<int>(errorCode), m_url.string(), description));639 m_client->didFailSocketStream(*this, SocketStreamError(static_cast<int>(errorCode), m_url.string(), description)); 640 640 } 641 641 … … 665 665 if (!m_readStream) { 666 666 if (m_connectingSubstate == New || m_connectingSubstate == ExecutingPACFile) 667 m_client->didCloseSocketStream( this);667 m_client->didCloseSocketStream(*this); 668 668 return; 669 669 } … … 683 683 m_writeStream = 0; 684 684 685 m_client->didCloseSocketStream(this); 686 } 687 688 void SocketStreamHandle::receivedCredential(const AuthenticationChallenge&, const Credential&) 689 { 690 } 691 692 void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&) 693 { 694 } 695 696 void SocketStreamHandle::receivedCancellation(const AuthenticationChallenge&) 697 { 698 } 699 700 void SocketStreamHandle::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&) 701 { 702 } 703 704 void SocketStreamHandle::receivedChallengeRejection(const AuthenticationChallenge&) 705 { 685 m_client->didCloseSocketStream(*this); 706 686 } 707 687 -
trunk/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp
r196223 r201880 41 41 #include "SSLHandle.h" 42 42 43 #if PLATFORM(WIN) && USE(CF)44 #include <wtf/PassRefPtr.h>45 #include <wtf/RetainPtr.h>46 #endif47 48 43 namespace WebCore { 49 44 -
trunk/Source/WebCore/platform/network/curl/SocketStreamHandle.h
r199053 r201880 30 30 */ 31 31 32 #ifndef SocketStreamHandle_h 33 #define SocketStreamHandle_h 32 #pragma once 34 33 35 34 #include "SocketStreamHandleBase.h" … … 48 47 namespace WebCore { 49 48 50 class AuthenticationChallenge;51 class Credential;52 49 class NetworkingContext; 53 50 class SocketStreamHandleClient; … … 76 73 77 74 static std::unique_ptr<char[]> createCopy(const char* data, int length); 78 79 // No authentication for streams per se, but proxy may ask for credentials.80 void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);81 void receivedCredential(const AuthenticationChallenge&, const Credential&);82 void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);83 void receivedCancellation(const AuthenticationChallenge&);84 void receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&);85 void receivedChallengeRejection(const AuthenticationChallenge&);86 75 87 76 struct SocketData { … … 112 101 113 102 } // namespace WebCore 114 115 #endif // SocketStreamHandle_h -
trunk/Source/WebCore/platform/network/curl/SocketStreamHandleCurl.cpp
r200687 r201880 36 36 37 37 #include "Logging.h" 38 #include "NotImplemented.h"39 38 #include "SocketStreamHandleClient.h" 40 39 #include "URL.h" … … 83 82 84 83 if (m_client) 85 m_client->didCloseSocketStream( this);84 m_client->didCloseSocketStream(*this); 86 85 } 87 86 … … 259 258 if (socketData.size > 0) { 260 259 if (m_client && state() == Open) 261 m_client->didReceiveSocketStreamData( this, socketData.data.get(), socketData.size);260 m_client->didReceiveSocketStreamData(*this, socketData.data.get(), socketData.size); 262 261 } else 263 262 platformClose(); … … 272 271 273 272 if (m_client) 274 m_client->didOpenSocketStream( this);273 m_client->didOpenSocketStream(*this); 275 274 } 276 275 … … 283 282 } 284 283 285 void SocketStreamHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge&)286 {287 notImplemented();288 }289 290 void SocketStreamHandle::receivedCredential(const AuthenticationChallenge&, const Credential&)291 {292 notImplemented();293 }294 295 void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)296 {297 notImplemented();298 }299 300 void SocketStreamHandle::receivedCancellation(const AuthenticationChallenge&)301 {302 notImplemented();303 }304 305 void SocketStreamHandle::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&)306 {307 notImplemented();308 }309 310 void SocketStreamHandle::receivedChallengeRejection(const AuthenticationChallenge&)311 {312 notImplemented();313 }314 315 284 } // namespace WebCore 316 285 -
trunk/Source/WebCore/platform/network/soup/SocketStreamHandle.h
r199053 r201880 44 44 namespace WebCore { 45 45 46 class AuthenticationChallenge;47 class Credential;48 46 class NetworkingContext; 49 47 class SocketStreamHandleClient; … … 51 49 class SocketStreamHandle : public RefCounted<SocketStreamHandle>, public SocketStreamHandleBase { 52 50 public: 53 static PassRefPtr<SocketStreamHandle> create(const URL& url, SocketStreamHandleClient* client, NetworkingContext&, bool) { return adoptRef(new SocketStreamHandle(url, client)); }54 static PassRefPtr<SocketStreamHandle> create(GSocketConnection* socketConnection, SocketStreamHandleClient* client) { return adoptRef(new SocketStreamHandle(socketConnection, client)); }51 static Ref<SocketStreamHandle> create(const URL& url, SocketStreamHandleClient* client, NetworkingContext&, bool) { return adoptRef(*new SocketStreamHandle(url, client)); } 52 static Ref<SocketStreamHandle> create(GSocketConnection* socketConnection, SocketStreamHandleClient* client) { return adoptRef(*new SocketStreamHandle(socketConnection, client)); } 55 53 56 54 virtual ~SocketStreamHandle(); … … 75 73 SocketStreamHandle(GSocketConnection*, SocketStreamHandleClient*); 76 74 77 // No authentication for streams per se, but proxy may ask for credentials.78 void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);79 void receivedCredential(const AuthenticationChallenge&, const Credential&);80 void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);81 void receivedCancellation(const AuthenticationChallenge&);82 void receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&);83 void receivedChallengeRejection(const AuthenticationChallenge&);84 85 75 void beginWaitingForSocketWritability(); 86 76 void stopWaitingForSocketWritability(); -
trunk/Source/WebCore/platform/network/soup/SocketStreamHandleSoup.cpp
r200895 r201880 37 37 #include "URL.h" 38 38 #include "Logging.h" 39 #include "NotImplemented.h"40 39 #include "SocketStreamError.h" 41 40 #include "SocketStreamHandleClient.h" … … 69 68 } 70 69 71 static void deactivateHandle(SocketStreamHandle *handle)72 { 73 gActiveHandles.remove(handle ->id());74 } 75 76 static void* activateHandle(SocketStreamHandle *handle)70 static void deactivateHandle(SocketStreamHandle& handle) 71 { 72 gActiveHandles.remove(handle.id()); 73 } 74 75 static void* activateHandle(SocketStreamHandle& handle) 77 76 { 78 77 // The first id cannot be 0, because it conflicts with the HashMap emptyValue. 79 78 static gint currentHandleId = 1; 80 79 void* id = GINT_TO_POINTER(currentHandleId++); 81 gActiveHandles.set(id, handle);80 gActiveHandles.set(id, &handle); 82 81 return id; 83 82 } … … 89 88 unsigned int port = url.hasPort() ? url.port() : (url.protocolIs("wss") ? 443 : 80); 90 89 91 m_id = activateHandle( this);90 m_id = activateHandle(*this); 92 91 GRefPtr<GSocketClient> socketClient = adoptGRef(g_socket_client_new()); 93 92 if (url.protocolIs("wss")) … … 101 100 { 102 101 LOG(Network, "SocketStreamHandle %p new client %p", this, m_client); 103 m_id = activateHandle( this);102 m_id = activateHandle(*this); 104 103 connected(socketConnection, 0); 105 104 } … … 109 108 LOG(Network, "SocketStreamHandle %p delete", this); 110 109 // If for some reason we were destroyed without closing, ensure that we are deactivated. 111 deactivateHandle( this);112 setClient( 0);110 deactivateHandle(*this); 111 setClient(nullptr); 113 112 } 114 113 … … 116 115 { 117 116 if (error) { 118 m_client->didFailSocketStream( this, SocketStreamError(error->code, error->message));117 m_client->didFailSocketStream(*this, SocketStreamError(error->code, error->message)); 119 118 return; 120 119 } … … 129 128 130 129 m_state = Open; 131 m_client->didOpenSocketStream( this);130 m_client->didOpenSocketStream(*this); 132 131 } 133 132 … … 135 134 { 136 135 if (error) { 137 m_client->didFailSocketStream( this, SocketStreamError(error->code, error->message));136 m_client->didFailSocketStream(*this, SocketStreamError(error->code, error->message)); 138 137 return; 139 138 } … … 145 144 146 145 // The client can close the handle, potentially removing the last reference. 147 Ref Ptr<SocketStreamHandle> protectedThis(this);148 m_client->didReceiveSocketStreamData( this, m_readBuffer.get(), bytesRead);146 Ref<SocketStreamHandle> protectedThis(*this); 147 m_client->didReceiveSocketStreamData(*this, m_readBuffer.get(), bytesRead); 149 148 if (m_inputStream) // The client may have closed the connection. 150 149 g_input_stream_read_async(m_inputStream.get(), m_readBuffer.get(), READ_BUFFER_SIZE, G_PRIORITY_DEFAULT, 0, … … 175 174 beginWaitingForSocketWritability(); 176 175 else 177 m_client->didFailSocketStream( this, SocketStreamError(error->code, error->message));176 m_client->didFailSocketStream(*this, SocketStreamError(error->code, error->message)); 178 177 return 0; 179 178 } … … 191 190 LOG(Network, "SocketStreamHandle %p platformClose", this); 192 191 // We remove this handle from the active handles list first, to disable all callbacks. 193 deactivateHandle( this);192 deactivateHandle(*this); 194 193 stopWaitingForSocketWritability(); 195 194 … … 198 197 g_io_stream_close(G_IO_STREAM(m_socketConnection.get()), 0, &error.outPtr()); 199 198 if (error) 200 m_client->didFailSocketStream( this, SocketStreamError(error->code, error->message));199 m_client->didFailSocketStream(*this, SocketStreamError(error->code, error->message)); 201 200 m_socketConnection = 0; 202 201 } … … 206 205 m_readBuffer = nullptr; 207 206 208 m_client->didCloseSocketStream(this); 209 } 210 211 void SocketStreamHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge&) 212 { 213 notImplemented(); 214 } 215 216 void SocketStreamHandle::receivedCredential(const AuthenticationChallenge&, const Credential&) 217 { 218 notImplemented(); 219 } 220 221 void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&) 222 { 223 notImplemented(); 224 } 225 226 void SocketStreamHandle::receivedCancellation(const AuthenticationChallenge&) 227 { 228 notImplemented(); 229 } 230 231 void SocketStreamHandle::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge&) 232 { 233 notImplemented(); 234 } 235 236 void SocketStreamHandle::receivedChallengeRejection(const AuthenticationChallenge&) 237 { 238 notImplemented(); 207 m_client->didCloseSocketStream(*this); 239 208 } 240 209 -
trunk/Source/WebKit2/ChangeLog
r201869 r201880 1 2016-06-09 Alex Christensen <achristensen@webkit.org> 2 3 Clean up WebSocket code 4 https://bugs.webkit.org/show_bug.cgi?id=158551 5 6 Reviewed by Darin Adler. 7 8 * WebProcess/FileAPI/BlobRegistryProxy.cpp: 9 (WebKit::BlobRegistryProxy::registerFileBlobURL): 10 * WebProcess/FileAPI/BlobRegistryProxy.h: 11 1 12 2016-06-09 David Kilzer <ddkilzer@apple.com> 2 13 -
trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp
r201717 r201880 37 37 namespace WebKit { 38 38 39 void BlobRegistryProxy::registerFileBlobURL(const WebCore::URL& url, Ref Ptr<BlobDataFileReference>&& file, const String& contentType)39 void BlobRegistryProxy::registerFileBlobURL(const WebCore::URL& url, Ref<BlobDataFileReference>&& file, const String& contentType) 40 40 { 41 41 SandboxExtension::Handle extensionHandle; -
trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h
r201717 r201880 33 33 class BlobRegistryProxy final : public WebCore::BlobRegistry { 34 34 public: 35 void registerFileBlobURL(const WebCore::URL&, Ref Ptr<WebCore::BlobDataFileReference>&&, const String& contentType) override;35 void registerFileBlobURL(const WebCore::URL&, Ref<WebCore::BlobDataFileReference>&&, const String& contentType) override; 36 36 void registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType) override; 37 37 void registerBlobURL(const WebCore::URL&, const WebCore::URL& srcURL) override;
Note:
See TracChangeset
for help on using the changeset viewer.