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

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

Issue 419203004: DevTools: wrapping arguments addConsoleMessage in ConsoleMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@wrap-not-all-console-args
Patch Set: Created 6 years, 4 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, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/websockets/MainThreadWebSocketChannel.h" 32 #include "modules/websockets/MainThreadWebSocketChannel.h"
33 33
34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/ExecutionContext.h" 36 #include "core/dom/ExecutionContext.h"
37 #include "core/fileapi/Blob.h" 37 #include "core/fileapi/Blob.h"
38 #include "core/fileapi/FileReaderLoader.h" 38 #include "core/fileapi/FileReaderLoader.h"
39 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
40 #include "core/inspector/ConsoleMessage.h"
40 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
41 #include "core/inspector/InspectorTraceEvents.h" 42 #include "core/inspector/InspectorTraceEvents.h"
42 #include "core/loader/FrameLoader.h" 43 #include "core/loader/FrameLoader.h"
43 #include "core/loader/FrameLoaderClient.h" 44 #include "core/loader/FrameLoaderClient.h"
44 #include "core/loader/MixedContentChecker.h" 45 #include "core/loader/MixedContentChecker.h"
45 #include "core/loader/UniqueIdentifier.h" 46 #include "core/loader/UniqueIdentifier.h"
46 #include "core/page/Page.h" 47 #include "core/page/Page.h"
47 #include "modules/websockets/WebSocketChannelClient.h" 48 #include "modules/websockets/WebSocketChannelClient.h"
48 #include "platform/Logging.h" 49 #include "platform/Logging.h"
49 #include "platform/network/SocketStreamError.h" 50 #include "platform/network/SocketStreamError.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 bool MainThreadWebSocketChannel::connect(const KURL& url, const String& protocol ) 91 bool MainThreadWebSocketChannel::connect(const KURL& url, const String& protocol )
91 { 92 {
92 WTF_LOG(Network, "MainThreadWebSocketChannel %p connect()", this); 93 WTF_LOG(Network, "MainThreadWebSocketChannel %p connect()", this);
93 ASSERT(!m_handle); 94 ASSERT(!m_handle);
94 ASSERT(!m_suspended); 95 ASSERT(!m_suspended);
95 96
96 if (m_document->frame() && !m_document->frame()->loader().mixedContentChecke r()->canConnectInsecureWebSocket(m_document->securityOrigin(), url)) 97 if (m_document->frame() && !m_document->frame()->loader().mixedContentChecke r()->canConnectInsecureWebSocket(m_document->securityOrigin(), url))
97 return false; 98 return false;
98 if (MixedContentChecker::isMixedContent(m_document->securityOrigin(), url)) { 99 if (MixedContentChecker::isMixedContent(m_document->securityOrigin(), url)) {
99 String message = "Connecting to a non-secure WebSocket server from a sec ure origin is deprecated."; 100 String message = "Connecting to a non-secure WebSocket server from a sec ure origin is deprecated.";
100 m_document->addConsoleMessage(JSMessageSource, WarningMessageLevel, mess age); 101 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Wa rningMessageLevel, message));
101 } 102 }
102 103
103 m_handshake = new WebSocketHandshake(url, protocol, m_document); 104 m_handshake = new WebSocketHandshake(url, protocol, m_document);
104 m_handshake->reset(); 105 m_handshake->reset();
105 m_handshake->addExtensionProcessor(m_perMessageDeflate.createExtensionProces sor()); 106 m_handshake->addExtensionProcessor(m_perMessageDeflate.createExtensionProces sor());
106 m_handshake->addExtensionProcessor(m_deflateFramer.createExtensionProcessor( )); 107 m_handshake->addExtensionProcessor(m_deflateFramer.createExtensionProcessor( ));
107 if (m_identifier) { 108 if (m_identifier) {
108 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "We bSocketCreate", "data", InspectorWebSocketCreateEvent::data(m_document, m_identi fier, url, protocol)); 109 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "We bSocketCreate", "data", InspectorWebSocketCreateEvent::data(m_document, m_identi fier, url, protocol));
109 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack" ), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 110 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack" ), "CallStack", "stack", InspectorCallStackEvent::currentCallStack());
110 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 111 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 m_didFailOfClientAlreadyRun = true; 185 m_didFailOfClientAlreadyRun = true;
185 m_client->didReceiveMessageError(); 186 m_client->didReceiveMessageError();
186 } 187 }
187 188
188 void MainThreadWebSocketChannel::fail(const String& reason, MessageLevel level, const String& sourceURL, unsigned lineNumber) 189 void MainThreadWebSocketChannel::fail(const String& reason, MessageLevel level, const String& sourceURL, unsigned lineNumber)
189 { 190 {
190 WTF_LOG(Network, "MainThreadWebSocketChannel %p fail() reason='%s'", this, r eason.utf8().data()); 191 WTF_LOG(Network, "MainThreadWebSocketChannel %p fail() reason='%s'", this, r eason.utf8().data());
191 if (m_document) { 192 if (m_document) {
192 InspectorInstrumentation::didReceiveWebSocketFrameError(m_document, m_id entifier, reason); 193 InspectorInstrumentation::didReceiveWebSocketFrameError(m_document, m_id entifier, reason);
193 const String message = "WebSocket connection to '" + m_handshake->url(). elidedString() + "' failed: " + reason; 194 const String message = "WebSocket connection to '" + m_handshake->url(). elidedString() + "' failed: " + reason;
194 m_document->addConsoleMessage(JSMessageSource, level, message, sourceURL , lineNumber); 195 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, le vel, message, sourceURL, lineNumber));
195 } 196 }
196 // Hybi-10 specification explicitly states we must not continue to handle in coming data 197 // Hybi-10 specification explicitly states we must not continue to handle in coming data
197 // once the WebSocket connection is failed (section 7.1.7). 198 // once the WebSocket connection is failed (section 7.1.7).
198 m_shouldDiscardReceivedData = true; 199 m_shouldDiscardReceivedData = true;
199 if (!m_buffer.isEmpty()) 200 if (!m_buffer.isEmpty())
200 skipBuffer(m_buffer.size()); // Save memory. 201 skipBuffer(m_buffer.size()); // Save memory.
201 m_deflateFramer.didFail(); 202 m_deflateFramer.didFail();
202 m_perMessageDeflate.didFail(); 203 m_perMessageDeflate.didFail();
203 m_hasContinuousFrame = false; 204 m_hasContinuousFrame = false;
204 m_continuousFrameData.clear(); 205 m_continuousFrameData.clear();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack" ), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 263 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack" ), "CallStack", "stack", InspectorCallStackEvent::currentCallStack());
263 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 264 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
264 InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier); 265 InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier);
265 } 266 }
266 ASSERT_UNUSED(handle, handle == m_handle || !m_handle); 267 ASSERT_UNUSED(handle, handle == m_handle || !m_handle);
267 268
268 // Show error message on JS console if this is unexpected connection close 269 // Show error message on JS console if this is unexpected connection close
269 // during opening handshake. 270 // during opening handshake.
270 if (!m_hasCalledDisconnectOnHandle && m_handshake->mode() == WebSocketHandsh ake::Incomplete && m_document) { 271 if (!m_hasCalledDisconnectOnHandle && m_handshake->mode() == WebSocketHandsh ake::Incomplete && m_document) {
271 const String message = "WebSocket connection to '" + m_handshake->url(). elidedString() + "' failed: Connection closed before receiving a handshake respo nse"; 272 const String message = "WebSocket connection to '" + m_handshake->url(). elidedString() + "' failed: Connection closed before receiving a handshake respo nse";
272 m_document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, messag e, m_sourceURLAtConstruction, m_lineNumberAtConstruction); 273 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Er rorMessageLevel, message, m_sourceURLAtConstruction, m_lineNumberAtConstruction) );
273 } 274 }
274 275
275 m_state = ChannelClosed; 276 m_state = ChannelClosed;
276 if (m_closingTimer.isActive()) 277 if (m_closingTimer.isActive())
277 m_closingTimer.stop(); 278 m_closingTimer.stop();
278 if (m_outgoingFrameQueueStatus != OutgoingFrameQueueClosed) 279 if (m_outgoingFrameQueueStatus != OutgoingFrameQueueClosed)
279 abortOutgoingFrameQueue(); 280 abortOutgoingFrameQueue();
280 if (m_handle) { 281 if (m_handle) {
281 WebSocketChannelClient* client = m_client; 282 WebSocketChannelClient* client = m_client;
282 m_client = nullptr; 283 m_client = nullptr;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return false; 452 return false;
452 if (m_handshake->mode() == WebSocketHandshake::Connected) { 453 if (m_handshake->mode() == WebSocketHandshake::Connected) {
453 if (m_identifier) { 454 if (m_identifier) {
454 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timelin e"), "WebSocketReceiveHandshakeResponse", "data", InspectorWebSocketEvent::data( m_document, m_identifier)); 455 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timelin e"), "WebSocketReceiveHandshakeResponse", "data", InspectorWebSocketEvent::data( m_document, m_identifier));
455 // FIXME(361045): remove InspectorInstrumentation calls once Dev Tools Timeline migrates to tracing. 456 // FIXME(361045): remove InspectorInstrumentation calls once Dev Tools Timeline migrates to tracing.
456 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(m _document, m_identifier, 0, &m_handshake->serverHandshakeResponse()); 457 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(m _document, m_identifier, 0, &m_handshake->serverHandshakeResponse());
457 } 458 }
458 459
459 if (m_deflateFramer.enabled() && m_document) { 460 if (m_deflateFramer.enabled() && m_document) {
460 const String message = "WebSocket extension \"x-webkit-deflate-f rame\" is deprecated"; 461 const String message = "WebSocket extension \"x-webkit-deflate-f rame\" is deprecated";
461 m_document->addConsoleMessage(JSMessageSource, WarningMessageLev el, message, m_sourceURLAtConstruction, m_lineNumberAtConstruction); 462 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSo urce, WarningMessageLevel, message, m_sourceURLAtConstruction, m_lineNumberAtCon struction));
462 } 463 }
463 464
464 WTF_LOG(Network, "MainThreadWebSocketChannel %p Connected", this); 465 WTF_LOG(Network, "MainThreadWebSocketChannel %p Connected", this);
465 skipBuffer(headerLength); 466 skipBuffer(headerLength);
466 String subprotocol = m_handshake->serverWebSocketProtocol(); 467 String subprotocol = m_handshake->serverWebSocketProtocol();
467 String extensions = m_handshake->acceptedExtensions(); 468 String extensions = m_handshake->acceptedExtensions();
468 m_client->didConnect(subprotocol.isNull() ? "" : subprotocol, extens ions.isNull() ? "" : extensions); 469 m_client->didConnect(subprotocol.isNull() ? "" : subprotocol, extens ions.isNull() ? "" : extensions);
469 WTF_LOG(Network, "MainThreadWebSocketChannel %p %lu bytes remaining in m_buffer", this, static_cast<unsigned long>(m_buffer.size())); 470 WTF_LOG(Network, "MainThreadWebSocketChannel %p %lu bytes remaining in m_buffer", this, static_cast<unsigned long>(m_buffer.size()));
470 return !m_buffer.isEmpty(); 471 return !m_buffer.isEmpty();
471 } 472 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 { 856 {
856 visitor->trace(m_document); 857 visitor->trace(m_document);
857 visitor->trace(m_client); 858 visitor->trace(m_client);
858 visitor->trace(m_handshake); 859 visitor->trace(m_handshake);
859 visitor->trace(m_handle); 860 visitor->trace(m_handle);
860 WebSocketChannel::trace(visitor); 861 WebSocketChannel::trace(visitor);
861 SocketStreamHandleClient::trace(visitor); 862 SocketStreamHandleClient::trace(visitor);
862 } 863 }
863 864
864 } // namespace blink 865 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/websockets/DOMWebSocket.cpp ('k') | Source/modules/websockets/NewWebSocketChannelImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698