Changeset 70216 in webkit
- Timestamp:
- Oct 21, 2010 2:23:39 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70214 r70216 1 2010-10-21 Yuta Kitamura <yutak@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: Handle WebSocket events via InspectorInstrumentation 6 https://bugs.webkit.org/show_bug.cgi?id=47968 7 8 * inspector/InspectorInstrumentation.cpp: 9 (WebCore::InspectorInstrumentation::didCreateWebSocketImpl): 10 (WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl): 11 (WebCore::InspectorInstrumentation::didReceiveWebSocketHandshakeResponseImpl): 12 (WebCore::InspectorInstrumentation::didCloseWebSocketImpl): 13 * inspector/InspectorInstrumentation.h: 14 (WebCore::InspectorInstrumentation::didCreateWebSocket): 15 (WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequest): 16 (WebCore::InspectorInstrumentation::didReceiveWebSocketHandshakeResponse): 17 (WebCore::InspectorInstrumentation::didCloseWebSocket): 18 * websockets/WebSocketChannel.cpp: 19 (WebCore::WebSocketChannel::WebSocketChannel): 20 Now we do not depend on InspectorController to generate a resource identifier. 21 (WebCore::WebSocketChannel::disconnect): 22 Check if m_identifier is valid in case we could not obtain an identifier. 23 (WebCore::WebSocketChannel::didOpen): 24 (WebCore::WebSocketChannel::didClose): 25 (WebCore::WebSocketChannel::processBuffer): 26 * websockets/WebSocketChannel.h: 27 1 28 2010-10-20 Pavel Feldman <pfeldman@chromium.org> 2 29 -
trunk/WebCore/inspector/InspectorInstrumentation.cpp
r69960 r70216 413 413 } 414 414 415 #if ENABLE(WEB_SOCKETS) 416 void InspectorInstrumentation::didCreateWebSocketImpl(InspectorController* inspectorController, unsigned long identifier, const KURL& requestURL, const KURL& documentURL) 417 { 418 inspectorController->didCreateWebSocket(identifier, requestURL, documentURL); 419 } 420 421 void InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl(InspectorController* inspectorController, unsigned long identifier, const WebSocketHandshakeRequest& request) 422 { 423 inspectorController->willSendWebSocketHandshakeRequest(identifier, request); 424 } 425 426 void InspectorInstrumentation::didReceiveWebSocketHandshakeResponseImpl(InspectorController* inspectorController, unsigned long identifier, const WebSocketHandshakeResponse& response) 427 { 428 inspectorController->didReceiveWebSocketHandshakeResponse(identifier, response); 429 } 430 431 void InspectorInstrumentation::didCloseWebSocketImpl(InspectorController* inspectorController, unsigned long identifier) 432 { 433 inspectorController->didCloseWebSocket(identifier); 434 } 435 #endif 436 415 437 bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorController) 416 438 { -
trunk/WebCore/inspector/InspectorInstrumentation.h
r69760 r70216 43 43 class InspectorController; 44 44 class InspectorTimelineAgent; 45 class KURL; 45 46 class Node; 46 47 class ResourceRequest; 47 48 class ResourceResponse; 48 49 class XMLHttpRequest; 50 51 #if ENABLE(WEB_SOCKETS) 52 class WebSocketHandshakeRequest; 53 class WebSocketHandshakeResponse; 54 #endif 49 55 50 56 typedef pair<InspectorController*, int> InspectorInstrumentationCookie; … … 91 97 static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine); 92 98 99 #if ENABLE(WEB_SOCKETS) 100 static void didCreateWebSocket(ScriptExecutionContext*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL); 101 static void willSendWebSocketHandshakeRequest(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeRequest&); 102 static void didReceiveWebSocketHandshakeResponse(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeResponse&); 103 static void didCloseWebSocket(ScriptExecutionContext*, unsigned long identifier); 104 #endif 105 93 106 #if ENABLE(INSPECTOR) 94 107 static void frontendCreated() { s_frontendCounter += 1; } … … 141 154 static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine); 142 155 156 #if ENABLE(WEB_SOCKETS) 157 static void didCreateWebSocketImpl(InspectorController*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL); 158 static void willSendWebSocketHandshakeRequestImpl(InspectorController*, unsigned long identifier, const WebSocketHandshakeRequest&); 159 static void didReceiveWebSocketHandshakeResponseImpl(InspectorController*, unsigned long identifier, const WebSocketHandshakeResponse&); 160 static void didCloseWebSocketImpl(InspectorController*, unsigned long identifier); 161 #endif 162 143 163 static InspectorController* inspectorControllerForContext(ScriptExecutionContext*); 144 164 static InspectorController* inspectorControllerForDocument(Document*); … … 461 481 } 462 482 483 #if ENABLE(WEB_SOCKETS) 484 inline void InspectorInstrumentation::didCreateWebSocket(ScriptExecutionContext* context, unsigned long identifier, const KURL& requestURL, const KURL& documentURL) 485 { 486 #if ENABLE(INSPECTOR) 487 if (InspectorController* inspectorController = inspectorControllerForContext(context)) 488 didCreateWebSocketImpl(inspectorController, identifier, requestURL, documentURL); 489 #endif 490 } 491 492 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeRequest& request) 493 { 494 #if ENABLE(INSPECTOR) 495 if (InspectorController* inspectorController = inspectorControllerForContext(context)) 496 willSendWebSocketHandshakeRequestImpl(inspectorController, identifier, request); 497 #endif 498 } 499 500 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeResponse& response) 501 { 502 #if ENABLE(INSPECTOR) 503 if (InspectorController* inspectorController = inspectorControllerForContext(context)) 504 didReceiveWebSocketHandshakeResponseImpl(inspectorController, identifier, response); 505 #endif 506 } 507 508 inline void InspectorInstrumentation::didCloseWebSocket(ScriptExecutionContext* context, unsigned long identifier) 509 { 510 #if ENABLE(INSPECTOR) 511 if (InspectorController* inspectorController = inspectorControllerForContext(context)) 512 didCloseWebSocketImpl(inspectorController, identifier); 513 #endif 514 } 515 #endif 463 516 464 517 #if ENABLE(INSPECTOR) -
trunk/WebCore/websockets/WebSocketChannel.cpp
r69798 r70216 37 37 #include "CookieJar.h" 38 38 #include "Document.h" 39 #include "Inspector Controller.h"39 #include "InspectorInstrumentation.h" 40 40 #include "Logging.h" 41 41 #include "Page.h" … … 68 68 , m_shouldDiscardReceivedData(false) 69 69 , m_unhandledBufferedAmount(0) 70 #if ENABLE(INSPECTOR)71 70 , m_identifier(0) 72 #endif 73 { 74 #if ENABLE(INSPECTOR) 75 if (InspectorController* controller = m_context->inspectorController()) 76 controller->didCreateWebSocket(identifier(), url, m_context->url()); 77 #endif 71 { 72 if (m_context->isDocument()) 73 if (Page* page = static_cast<Document*>(m_context)->page()) 74 m_identifier = page->progress()->createUniqueIdentifier(); 75 76 if (m_identifier) 77 InspectorInstrumentation::didCreateWebSocket(m_context, m_identifier, url, m_context->url()); 78 78 } 79 79 … … 125 125 { 126 126 LOG(Network, "WebSocketChannel %p disconnect", this); 127 #if ENABLE(INSPECTOR) 128 if (m_context) 129 if (InspectorController* controller = m_context->inspectorController()) 130 controller->didCloseWebSocket(identifier()); 131 #endif 127 if (m_identifier && m_context) 128 InspectorInstrumentation::didCloseWebSocket(m_context, m_identifier); 132 129 m_handshake.clearScriptExecutionContext(); 133 130 m_client = 0; … … 155 152 if (!m_context) 156 153 return; 157 #if ENABLE(INSPECTOR) 158 if (InspectorController* controller = m_context->inspectorController()) 159 controller->willSendWebSocketHandshakeRequest(identifier(), m_handshake.clientHandshakeRequest()); 160 #endif 154 if (m_identifier) 155 InspectorInstrumentation::willSendWebSocketHandshakeRequest(m_context, m_identifier, m_handshake.clientHandshakeRequest()); 161 156 CString handshakeMessage = m_handshake.clientHandshakeMessage(); 162 157 if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) { … … 169 164 { 170 165 LOG(Network, "WebSocketChannel %p didClose", this); 171 #if ENABLE(INSPECTOR) 172 if (m_context) 173 if (InspectorController* controller = m_context->inspectorController()) 174 controller->didCloseWebSocket(identifier()); 175 #endif 166 if (m_identifier && m_context) 167 InspectorInstrumentation::didCloseWebSocket(m_context, m_identifier); 176 168 ASSERT_UNUSED(handle, handle == m_handle || !m_handle); 177 169 m_closed = true; … … 277 269 return false; 278 270 if (m_handshake.mode() == WebSocketHandshake::Connected) { 279 #if ENABLE(INSPECTOR) 280 if (InspectorController* controller = m_context->inspectorController()) 281 controller->didReceiveWebSocketHandshakeResponse(identifier(), m_handshake.serverHandshakeResponse()); 282 #endif 271 if (m_identifier) 272 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(m_context, m_identifier, m_handshake.serverHandshakeResponse()); 283 273 if (!m_handshake.serverSetCookie().isEmpty()) { 284 274 if (m_context->isDocument()) { … … 398 388 } 399 389 400 #if ENABLE(INSPECTOR)401 unsigned long WebSocketChannel::identifier()402 {403 if (m_identifier)404 return m_identifier;405 406 if (InspectorController* controller = m_context->inspectorController())407 if (Page* page = controller->inspectedPage())408 m_identifier = page->progress()->createUniqueIdentifier();409 410 ASSERT(m_identifier);411 return m_identifier;412 }413 #endif // ENABLE(INSPECTOR)414 415 390 } // namespace WebCore 416 391 -
trunk/WebCore/websockets/WebSocketChannel.h
r67447 r70216 85 85 void resumeTimerFired(Timer<WebSocketChannel>* timer); 86 86 87 #if ENABLE(INSPECTOR)88 unsigned long identifier();89 #endif90 91 87 ScriptExecutionContext* m_context; 92 88 WebSocketChannelClient* m_client; … … 102 98 unsigned long m_unhandledBufferedAmount; 103 99 104 #if ENABLE(INSPECTOR) 105 unsigned long m_identifier; 106 #endif 100 unsigned long m_identifier; // m_identifier == 0 means that we could not obtain a valid identifier. 107 101 }; 108 102
Note: See TracChangeset
for help on using the changeset viewer.