Changeset 70216 in webkit


Ignore:
Timestamp:
Oct 21, 2010 2:23:39 AM (14 years ago)
Author:
yutak@chromium.org
Message:

2010-10-21 Yuta Kitamura <yutak@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: Handle WebSocket events via InspectorInstrumentation
https://bugs.webkit.org/show_bug.cgi?id=47968

  • inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::didCreateWebSocketImpl): (WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl): (WebCore::InspectorInstrumentation::didReceiveWebSocketHandshakeResponseImpl): (WebCore::InspectorInstrumentation::didCloseWebSocketImpl):
  • inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::didCreateWebSocket): (WebCore::InspectorInstrumentation::willSendWebSocketHandshakeRequest): (WebCore::InspectorInstrumentation::didReceiveWebSocketHandshakeResponse): (WebCore::InspectorInstrumentation::didCloseWebSocket):
  • websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::WebSocketChannel): Now we do not depend on InspectorController to generate a resource identifier. (WebCore::WebSocketChannel::disconnect): Check if m_identifier is valid in case we could not obtain an identifier. (WebCore::WebSocketChannel::didOpen): (WebCore::WebSocketChannel::didClose): (WebCore::WebSocketChannel::processBuffer):
  • websockets/WebSocketChannel.h:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70214 r70216  
     12010-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
    1282010-10-20  Pavel Feldman  <pfeldman@chromium.org>
    229
  • trunk/WebCore/inspector/InspectorInstrumentation.cpp

    r69960 r70216  
    413413}
    414414
     415#if ENABLE(WEB_SOCKETS)
     416void InspectorInstrumentation::didCreateWebSocketImpl(InspectorController* inspectorController, unsigned long identifier, const KURL& requestURL, const KURL& documentURL)
     417{
     418    inspectorController->didCreateWebSocket(identifier, requestURL, documentURL);
     419}
     420
     421void InspectorInstrumentation::willSendWebSocketHandshakeRequestImpl(InspectorController* inspectorController, unsigned long identifier, const WebSocketHandshakeRequest& request)
     422{
     423    inspectorController->willSendWebSocketHandshakeRequest(identifier, request);
     424}
     425
     426void InspectorInstrumentation::didReceiveWebSocketHandshakeResponseImpl(InspectorController* inspectorController, unsigned long identifier, const WebSocketHandshakeResponse& response)
     427{
     428    inspectorController->didReceiveWebSocketHandshakeResponse(identifier, response);
     429}
     430
     431void InspectorInstrumentation::didCloseWebSocketImpl(InspectorController* inspectorController, unsigned long identifier)
     432{
     433    inspectorController->didCloseWebSocket(identifier);
     434}
     435#endif
     436
    415437bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorController)
    416438{
  • trunk/WebCore/inspector/InspectorInstrumentation.h

    r69760 r70216  
    4343class InspectorController;
    4444class InspectorTimelineAgent;
     45class KURL;
    4546class Node;
    4647class ResourceRequest;
    4748class ResourceResponse;
    4849class XMLHttpRequest;
     50
     51#if ENABLE(WEB_SOCKETS)
     52class WebSocketHandshakeRequest;
     53class WebSocketHandshakeResponse;
     54#endif
    4955
    5056typedef pair<InspectorController*, int> InspectorInstrumentationCookie;
     
    9197    static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine);
    9298
     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
    93106#if ENABLE(INSPECTOR)
    94107    static void frontendCreated() { s_frontendCounter += 1; }
     
    141154    static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine);
    142155
     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
    143163    static InspectorController* inspectorControllerForContext(ScriptExecutionContext*);
    144164    static InspectorController* inspectorControllerForDocument(Document*);
     
    461481}
    462482
     483#if ENABLE(WEB_SOCKETS)
     484inline 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
     492inline 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
     500inline 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
     508inline 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
    463516
    464517#if ENABLE(INSPECTOR)
  • trunk/WebCore/websockets/WebSocketChannel.cpp

    r69798 r70216  
    3737#include "CookieJar.h"
    3838#include "Document.h"
    39 #include "InspectorController.h"
     39#include "InspectorInstrumentation.h"
    4040#include "Logging.h"
    4141#include "Page.h"
     
    6868    , m_shouldDiscardReceivedData(false)
    6969    , m_unhandledBufferedAmount(0)
    70 #if ENABLE(INSPECTOR)
    7170    , 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());
    7878}
    7979
     
    125125{
    126126    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);
    132129    m_handshake.clearScriptExecutionContext();
    133130    m_client = 0;
     
    155152    if (!m_context)
    156153        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());
    161156    CString handshakeMessage = m_handshake.clientHandshakeMessage();
    162157    if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) {
     
    169164{
    170165    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);
    176168    ASSERT_UNUSED(handle, handle == m_handle || !m_handle);
    177169    m_closed = true;
     
    277269            return false;
    278270        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());
    283273            if (!m_handshake.serverSetCookie().isEmpty()) {
    284274                if (m_context->isDocument()) {
     
    398388}
    399389
    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 
    415390}  // namespace WebCore
    416391
  • trunk/WebCore/websockets/WebSocketChannel.h

    r67447 r70216  
    8585        void resumeTimerFired(Timer<WebSocketChannel>* timer);
    8686
    87 #if ENABLE(INSPECTOR)
    88         unsigned long identifier();
    89 #endif
    90 
    9187        ScriptExecutionContext* m_context;
    9288        WebSocketChannelClient* m_client;
     
    10298        unsigned long m_unhandledBufferedAmount;
    10399
    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.
    107101    };
    108102
Note: See TracChangeset for help on using the changeset viewer.