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

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 = adoptPtrWillBeNoop(new WebSocketHandshake(url, protocol, m_doc ument)); 104 m_handshake = adoptPtrWillBeNoop(new WebSocketHandshake(url, protocol, m_doc ument));
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 RefPtrWillBeRawPtr<MainThreadWebSocketChannel> protect(this); // The client can close the channel, potentially removing the last reference. 199 RefPtrWillBeRawPtr<MainThreadWebSocketChannel> protect(this); // The client can close the channel, potentially removing the last reference.
199 m_shouldDiscardReceivedData = true; 200 m_shouldDiscardReceivedData = true;
200 if (!m_buffer.isEmpty()) 201 if (!m_buffer.isEmpty())
201 skipBuffer(m_buffer.size()); // Save memory. 202 skipBuffer(m_buffer.size()); // Save memory.
202 m_deflateFramer.didFail(); 203 m_deflateFramer.didFail();
203 m_perMessageDeflate.didFail(); 204 m_perMessageDeflate.didFail();
204 m_hasContinuousFrame = false; 205 m_hasContinuousFrame = false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack" ), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 264 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack" ), "CallStack", "stack", InspectorCallStackEvent::currentCallStack());
264 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 265 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
265 InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier); 266 InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier);
266 } 267 }
267 ASSERT_UNUSED(handle, handle == m_handle || !m_handle); 268 ASSERT_UNUSED(handle, handle == m_handle || !m_handle);
268 269
269 // Show error message on JS console if this is unexpected connection close 270 // Show error message on JS console if this is unexpected connection close
270 // during opening handshake. 271 // during opening handshake.
271 if (!m_hasCalledDisconnectOnHandle && m_handshake->mode() == WebSocketHandsh ake::Incomplete && m_document) { 272 if (!m_hasCalledDisconnectOnHandle && m_handshake->mode() == WebSocketHandsh ake::Incomplete && m_document) {
272 const String message = "WebSocket connection to '" + m_handshake->url(). elidedString() + "' failed: Connection closed before receiving a handshake respo nse"; 273 const String message = "WebSocket connection to '" + m_handshake->url(). elidedString() + "' failed: Connection closed before receiving a handshake respo nse";
273 m_document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, messag e, m_sourceURLAtConstruction, m_lineNumberAtConstruction); 274 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Er rorMessageLevel, message, m_sourceURLAtConstruction, m_lineNumberAtConstruction) );
274 } 275 }
275 276
276 m_state = ChannelClosed; 277 m_state = ChannelClosed;
277 if (m_closingTimer.isActive()) 278 if (m_closingTimer.isActive())
278 m_closingTimer.stop(); 279 m_closingTimer.stop();
279 if (m_outgoingFrameQueueStatus != OutgoingFrameQueueClosed) 280 if (m_outgoingFrameQueueStatus != OutgoingFrameQueueClosed)
280 abortOutgoingFrameQueue(); 281 abortOutgoingFrameQueue();
281 if (m_handle) { 282 if (m_handle) {
282 WebSocketChannelClient* client = m_client; 283 WebSocketChannelClient* client = m_client;
283 m_client = nullptr; 284 m_client = nullptr;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 return false; 458 return false;
458 if (m_handshake->mode() == WebSocketHandshake::Connected) { 459 if (m_handshake->mode() == WebSocketHandshake::Connected) {
459 if (m_identifier) { 460 if (m_identifier) {
460 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timelin e"), "WebSocketReceiveHandshakeResponse", "data", InspectorWebSocketEvent::data( m_document, m_identifier)); 461 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timelin e"), "WebSocketReceiveHandshakeResponse", "data", InspectorWebSocketEvent::data( m_document, m_identifier));
461 // FIXME(361045): remove InspectorInstrumentation calls once Dev Tools Timeline migrates to tracing. 462 // FIXME(361045): remove InspectorInstrumentation calls once Dev Tools Timeline migrates to tracing.
462 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(m _document, m_identifier, 0, &m_handshake->serverHandshakeResponse()); 463 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(m _document, m_identifier, 0, &m_handshake->serverHandshakeResponse());
463 } 464 }
464 465
465 if (m_deflateFramer.enabled() && m_document) { 466 if (m_deflateFramer.enabled() && m_document) {
466 const String message = "WebSocket extension \"x-webkit-deflate-f rame\" is deprecated"; 467 const String message = "WebSocket extension \"x-webkit-deflate-f rame\" is deprecated";
467 m_document->addConsoleMessage(JSMessageSource, WarningMessageLev el, message, m_sourceURLAtConstruction, m_lineNumberAtConstruction); 468 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSo urce, WarningMessageLevel, message, m_sourceURLAtConstruction, m_lineNumberAtCon struction));
468 } 469 }
469 470
470 WTF_LOG(Network, "MainThreadWebSocketChannel %p Connected", this); 471 WTF_LOG(Network, "MainThreadWebSocketChannel %p Connected", this);
471 skipBuffer(headerLength); 472 skipBuffer(headerLength);
472 String subprotocol = m_handshake->serverWebSocketProtocol(); 473 String subprotocol = m_handshake->serverWebSocketProtocol();
473 String extensions = m_handshake->acceptedExtensions(); 474 String extensions = m_handshake->acceptedExtensions();
474 m_client->didConnect(subprotocol.isNull() ? "" : subprotocol, extens ions.isNull() ? "" : extensions); 475 m_client->didConnect(subprotocol.isNull() ? "" : subprotocol, extens ions.isNull() ? "" : extensions);
475 WTF_LOG(Network, "MainThreadWebSocketChannel %p %lu bytes remaining in m_buffer", this, static_cast<unsigned long>(m_buffer.size())); 476 WTF_LOG(Network, "MainThreadWebSocketChannel %p %lu bytes remaining in m_buffer", this, static_cast<unsigned long>(m_buffer.size()));
476 return !m_buffer.isEmpty(); 477 return !m_buffer.isEmpty();
477 } 478 }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 { 863 {
863 visitor->trace(m_document); 864 visitor->trace(m_document);
864 visitor->trace(m_client); 865 visitor->trace(m_client);
865 visitor->trace(m_handshake); 866 visitor->trace(m_handshake);
866 visitor->trace(m_handle); 867 visitor->trace(m_handle);
867 WebSocketChannel::trace(visitor); 868 WebSocketChannel::trace(visitor);
868 SocketStreamHandleClient::trace(visitor); 869 SocketStreamHandleClient::trace(visitor);
869 } 870 }
870 871
871 } // namespace blink 872 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698