Changeset 109540 in webkit


Ignore:
Timestamp:
Mar 2, 2012 2:39:04 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: enable Timeline panel for workers
https://bugs.webkit.org/show_bug.cgi?id=80130

Enabled Timeline panel for worker inspector. Refactored
JS function calls instrumentation to work for both
worker contexts and documents.

Reviewed by Pavel Feldman.

  • bindings/js/JSCallbackData.cpp:

(WebCore::JSCallbackData::invokeCallback):

  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):

  • bindings/js/JSMainThreadExecState.h:

(WebCore):
(WebCore::JSMainThreadExecState::instrumentedCall):

  • bindings/js/ScriptState.cpp:

(WebCore::scriptExecutionContextFromScriptState):
(WebCore):

  • bindings/js/ScriptState.h:

(WebCore):

  • bindings/v8/ScriptState.cpp:

(WebCore::ScriptState::scriptExecutionContext):
(WebCore):
(WebCore::scriptExecutionContextFromScriptState):

  • bindings/v8/ScriptState.h:

(WebCore):
(ScriptState):

  • bindings/v8/V8Proxy.cpp:

(WebCore::V8Proxy::instrumentedCallFunction):

  • bindings/v8/V8WorkerContextEventListener.cpp:

(WebCore::V8WorkerContextEventListener::callListenerFunction):

  • inspector/InjectedScript.cpp:

(WebCore::InjectedScript::callFunctionWithEvalEnabled):

  • inspector/InspectorInstrumentation.cpp:

(WebCore):
(WebCore::InspectorInstrumentation::instrumentingAgentsForNonDocumentContext):

  • inspector/InspectorInstrumentation.h:

(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::willCallFunction):
(WebCore):
(WebCore::InspectorInstrumentation::instrumentingAgentsForContext):

  • inspector/WorkerInspectorController.cpp:

(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::connectFrontend):
(WebCore::WorkerInspectorController::disconnectFrontend):
(WebCore::WorkerInspectorController::restoreInspectorStateFromCookie):

  • inspector/WorkerInspectorController.h:

(WebCore):
(WorkerInspectorController):

  • inspector/front-end/inspector.js:

(WebInspector._createPanels):

Location:
trunk/Source/WebCore
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109538 r109540  
     12012-03-02  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: enable Timeline panel for workers
     4        https://bugs.webkit.org/show_bug.cgi?id=80130
     5
     6        Enabled Timeline panel for worker inspector. Refactored
     7        JS function calls instrumentation to work for both
     8        worker contexts and documents.
     9
     10        Reviewed by Pavel Feldman.
     11
     12        * bindings/js/JSCallbackData.cpp:
     13        (WebCore::JSCallbackData::invokeCallback):
     14        * bindings/js/JSEventListener.cpp:
     15        (WebCore::JSEventListener::handleEvent):
     16        * bindings/js/JSMainThreadExecState.h:
     17        (WebCore):
     18        (WebCore::JSMainThreadExecState::instrumentedCall):
     19        * bindings/js/ScriptState.cpp:
     20        (WebCore::scriptExecutionContextFromScriptState):
     21        (WebCore):
     22        * bindings/js/ScriptState.h:
     23        (WebCore):
     24        * bindings/v8/ScriptState.cpp:
     25        (WebCore::ScriptState::scriptExecutionContext):
     26        (WebCore):
     27        (WebCore::scriptExecutionContextFromScriptState):
     28        * bindings/v8/ScriptState.h:
     29        (WebCore):
     30        (ScriptState):
     31        * bindings/v8/V8Proxy.cpp:
     32        (WebCore::V8Proxy::instrumentedCallFunction):
     33        * bindings/v8/V8WorkerContextEventListener.cpp:
     34        (WebCore::V8WorkerContextEventListener::callListenerFunction):
     35        * inspector/InjectedScript.cpp:
     36        (WebCore::InjectedScript::callFunctionWithEvalEnabled):
     37        * inspector/InspectorInstrumentation.cpp:
     38        (WebCore):
     39        (WebCore::InspectorInstrumentation::instrumentingAgentsForNonDocumentContext):
     40        * inspector/InspectorInstrumentation.h:
     41        (InspectorInstrumentation):
     42        (WebCore::InspectorInstrumentation::willCallFunction):
     43        (WebCore):
     44        (WebCore::InspectorInstrumentation::instrumentingAgentsForContext):
     45        * inspector/WorkerInspectorController.cpp:
     46        (WebCore::WorkerInspectorController::WorkerInspectorController):
     47        (WebCore::WorkerInspectorController::connectFrontend):
     48        (WebCore::WorkerInspectorController::disconnectFrontend):
     49        (WebCore::WorkerInspectorController::restoreInspectorStateFromCookie):
     50        * inspector/WorkerInspectorController.h:
     51        (WebCore):
     52        (WorkerInspectorController):
     53        * inspector/front-end/inspector.js:
     54        (WebInspector._createPanels):
     55
    1562012-03-02  Kenichi Ishibashi  <bashi@chromium.org>
    257
  • trunk/Source/WebCore/bindings/js/JSCallbackData.cpp

    r106030 r109540  
    6767    globalObject()->globalData().timeoutChecker.start();
    6868
    69     bool contextIsDocument = context->isDocument();
    70     JSValue result;
    71     if (contextIsDocument) {
    72         Frame* frame = static_cast<JSDOMWindow*>(globalObject())->impl()->frame();
    73         Page* page = frame ? frame->page() : 0;
    74         result = JSMainThreadExecState::instrumentedCall(page, exec, function, callType, callData, callback(), args);
    75     } else
    76         result = JSC::call(exec, function, callType, callData, callback(), args);
     69    JSValue result = JSMainThreadExecState::instrumentedCall(context, exec, function, callType, callData, callback(), args);
    7770
    7871    globalObject()->globalData().timeoutChecker.stop();
    7972
    80     if (contextIsDocument)
     73    if (context->isDocument())
    8174        Document::updateStyleForAllDocuments();
    8275
  • trunk/Source/WebCore/bindings/js/JSEventListener.cpp

    r108047 r109540  
    123123        globalData.timeoutChecker.start();
    124124        JSValue thisValue = handleEventFunction == jsFunction ? toJS(exec, globalObject, event->currentTarget()) : jsFunction;
    125         JSValue retval = scriptExecutionContext->isDocument()
    126             ? JSMainThreadExecState::instrumentedCall(frame ? frame->page() : 0, exec, handleEventFunction, callType, callData, thisValue, args)
    127             : JSC::call(exec, handleEventFunction, callType, callData, thisValue, args);
     125        JSValue retval = JSMainThreadExecState::instrumentedCall(scriptExecutionContext, exec, handleEventFunction, callType, callData, thisValue, args);
    128126        globalData.timeoutChecker.stop();
    129127
  • trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h

    r107149 r109540  
    3737namespace WebCore {
    3838
    39 class Page;
     39class ScriptExecutionContext;
    4040
    4141class JSMainThreadExecState {
     
    5757    };
    5858
    59     static JSC::JSValue instrumentedCall(Page* page, JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args)
     59    static JSC::JSValue instrumentedCall(ScriptExecutionContext* context, JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args)
    6060    {
    6161        InspectorInstrumentationCookie cookie;
     
    7070                resourceName = "undefined";
    7171
    72             cookie = InspectorInstrumentation::willCallFunction(page, resourceName, lineNumber);
     72            cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber);
    7373        }
    7474
  • trunk/Source/WebCore/bindings/js/ScriptState.cpp

    r106657 r109540  
    7272}
    7373
     74ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState* scriptState)
     75{
     76    JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
     77    if (!globalObject->inherits(&JSDOMGlobalObject::s_info))
     78        return 0;
     79    return static_cast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext();
     80}
     81
    7482bool evalEnabled(ScriptState* scriptState)
    7583{
  • trunk/Source/WebCore/bindings/js/ScriptState.h

    r106657 r109540  
    4747class Node;
    4848class Page;
     49class ScriptExecutionContext;
    4950class WorkerContext;
    5051
     
    6667
    6768DOMWindow* domWindowFromScriptState(ScriptState*);
     69ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState*);
    6870
    6971bool evalEnabled(ScriptState*);
  • trunk/Source/WebCore/bindings/v8/ScriptState.cpp

    r106657 r109540  
    3838#include "V8DOMWindow.h"
    3939#include "V8HiddenPropertyName.h"
    40 
     40#include "V8WorkerContext.h"
    4141#include "WorkerContext.h"
    4242#include "WorkerContextExecutionProxy.h"
     
    6767        return 0;
    6868    return V8DOMWindow::toNative(v8RealGlobal);
     69}
     70
     71ScriptExecutionContext* ScriptState::scriptExecutionContext() const
     72{
     73    v8::HandleScope handleScope;
     74
     75    v8::Handle<v8::Object> global = m_context->Global();
     76    v8::Handle<v8::Object> v8RealGlobal = v8::Handle<v8::Object>::Cast(global->GetPrototype());
     77    if (V8DOMWrapper::isWrapperOfType(v8RealGlobal, &V8DOMWindow::info))
     78        return V8DOMWindow::toNative(v8RealGlobal)->scriptExecutionContext();
     79#if ENABLE(WORKERS)
     80    global = V8DOMWrapper::lookupDOMWrapper(V8WorkerContext::GetTemplate(), global);
     81    if (!global.IsEmpty())
     82        return V8WorkerContext::toNative(global)->scriptExecutionContext();
     83#endif
     84    return 0;
    6985}
    7086
     
    108124{
    109125    return scriptState->domWindow();
     126}
     127
     128ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState* scriptState)
     129{
     130    return scriptState->scriptExecutionContext();
    110131}
    111132
  • trunk/Source/WebCore/bindings/v8/ScriptState.h

    r106657 r109540  
    4343class Node;
    4444class Page;
     45class ScriptExecutionContext;
    4546class WorkerContext;
    4647
     
    6162
    6263    DOMWindow* domWindow() const;
     64    ScriptExecutionContext* scriptExecutionContext() const;
    6365
    6466    static ScriptState* forContext(v8::Local<v8::Context>);
     
    109111
    110112DOMWindow* domWindowFromScriptState(ScriptState*);
     113ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState*);
    111114
    112115bool evalEnabled(ScriptState*);
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r107685 r109540  
    415415        return handleMaxRecursionDepthExceeded();
    416416
     417    ScriptExecutionContext* context = frame ? frame->document() : 0;
     418
    417419    InspectorInstrumentationCookie cookie;
    418     if (InspectorInstrumentation::hasFrontends() && frame) {
     420    if (InspectorInstrumentation::hasFrontends() && context) {
    419421        String resourceName("undefined");
    420422        int lineNumber = 1;
     
    424426            lineNumber = function->GetScriptLineNumber() + 1;
    425427        }
    426         cookie = InspectorInstrumentation::willCallFunction(frame->page(), resourceName, lineNumber);
     428        cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber);
    427429    }
    428430
     
    432434        TRACE_EVENT0("v8", "v8.callFunction");
    433435#endif
    434         V8RecursionScope recursionScope(frame ? frame->document() : 0);
     436        V8RecursionScope recursionScope(context);
    435437        result = function->Call(receiver, argc, args);
    436438    }
  • trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp

    r108867 r109540  
    3535#include "V8WorkerContextEventListener.h"
    3636
     37#include "InspectorInstrumentation.h"
    3738#include "V8Binding.h"
    3839#include "V8DOMWrapper.h"
     
    9192        return v8::Local<v8::Value>();
    9293
     94    InspectorInstrumentationCookie cookie;
     95    if (InspectorInstrumentation::hasFrontends()) {
     96        String resourceName("undefined");
     97        int lineNumber = 1;
     98        v8::ScriptOrigin origin = handlerFunction->GetScriptOrigin();
     99        if (!origin.ResourceName().IsEmpty()) {
     100            resourceName = toWebCoreString(origin.ResourceName());
     101            lineNumber = handlerFunction->GetScriptLineNumber() + 1;
     102        }
     103        cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber);
     104    }
     105
    93106    v8::Handle<v8::Value> parameters[1] = { jsEvent };
    94107    V8RecursionScope recursionScope(context);
     
    97110    if (WorkerContextExecutionProxy* proxy = workerProxy(context))
    98111        proxy->trackEvent(event);
     112
     113    InspectorInstrumentation::didCallFunction(cookie);
    99114
    100115    return result;
  • trunk/Source/WebCore/inspector/InjectedScript.cpp

    r108337 r109540  
    219219ScriptValue InjectedScript::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const
    220220{
    221     DOMWindow* domWindow = domWindowFromScriptState(m_injectedScriptObject.scriptState());
    222     InspectorInstrumentationCookie cookie = domWindow && domWindow->frame() ? InspectorInstrumentation::willCallFunction(domWindow->frame()->page(), "InjectedScript", 1) : InspectorInstrumentationCookie();
     221    ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromScriptState(m_injectedScriptObject.scriptState());
     222    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(scriptExecutionContext, "InjectedScript", 1);
    223223
    224224    ScriptState* scriptState = m_injectedScriptObject.scriptState();
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r109116 r109540  
    10621062    return instrumentationForWorkerContext(workerContext);
    10631063}
     1064
     1065InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForNonDocumentContext(ScriptExecutionContext* context)
     1066{
     1067    if (context->isWorkerContext())
     1068        return instrumentationForWorkerContext(static_cast<WorkerContext*>(context));
     1069    return 0;
     1070}
    10641071#endif
    10651072
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r109091 r109540  
    107107    static void didRemoveTimer(ScriptExecutionContext*, int timerId);
    108108
    109     static InspectorInstrumentationCookie willCallFunction(Page*, const String& scriptName, int scriptLine);
     109    static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
    110110    static void didCallFunction(const InspectorInstrumentationCookie&);
    111111    static InspectorInstrumentationCookie willChangeXHRReadyState(ScriptExecutionContext*, XMLHttpRequest* request);
     
    373373#if ENABLE(WORKERS)
    374374    static InstrumentingAgents* instrumentingAgentsForWorkerContext(WorkerContext*);
     375    static InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ScriptExecutionContext*);
    375376#endif
    376377
     
    576577}
    577578
    578 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(Page* page, const String& scriptName, int scriptLine)
    579 {
    580 #if ENABLE(INSPECTOR)
    581     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
    582     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
     579inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine)
     580{
     581#if ENABLE(INSPECTOR)
     582    FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
     583    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
    583584        return willCallFunctionImpl(instrumentingAgents, scriptName, scriptLine);
    584585#endif
    585586    return InspectorInstrumentationCookie();
    586587}
     588
    587589
    588590inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie)
     
    12421244inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
    12431245{
    1244     if (context && context->isDocument())
     1246    if (!context)
     1247        return 0;
     1248    if (context->isDocument())
    12451249        return instrumentingAgentsForPage(static_cast<Document*>(context)->page());
     1250#if ENABLE(WORKERS)
     1251    return instrumentingAgentsForNonDocumentContext(context);
     1252#else
    12461253    return 0;
     1254#endif
    12471255}
    12481256
  • trunk/Source/WebCore/inspector/WorkerInspectorController.cpp

    r109214 r109540  
    4545#include "InspectorState.h"
    4646#include "InspectorStateClient.h"
     47#include "InspectorTimelineAgent.h"
    4748#include "InstrumentingAgents.h"
    4849#include "WorkerConsoleAgent.h"
     
    102103    m_profilerAgent = InspectorProfilerAgent::create(m_instrumentingAgents.get(), m_consoleAgent.get(), workerContext, m_state.get(), m_injectedScriptManager.get());
    103104#endif
     105    m_timelineAgent = InspectorTimelineAgent::create(m_instrumentingAgents.get(), m_state.get());
    104106
    105107    m_injectedScriptManager->injectedScriptHost()->init(0
     
    129131    m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.get());
    130132    m_consoleAgent->registerInDispatcher(m_backendDispatcher.get());
     133    m_timelineAgent->registerInDispatcher(m_backendDispatcher.get());
    131134#if ENABLE(JAVASCRIPT_DEBUGGER)
    132135    m_debuggerAgent->registerInDispatcher(m_backendDispatcher.get());
     
    140143#endif
    141144    m_consoleAgent->setFrontend(m_frontend.get());
     145    m_timelineAgent->setFrontend(m_frontend.get());
    142146}
    143147
     
    156160#endif
    157161    m_consoleAgent->clearFrontend();
     162    m_timelineAgent->clearFrontend();
    158163
    159164    m_frontend.clear();
     
    172177#endif
    173178    m_consoleAgent->restore();
     179    m_timelineAgent->restore();
    174180}
    175181
  • trunk/Source/WebCore/inspector/WorkerInspectorController.h

    r109214 r109540  
    5656class InspectorState;
    5757class InspectorStateClient;
     58class InspectorTimelineAgent;
    5859class InstrumentingAgents;
    5960class WorkerContext;
     
    8990    OwnPtr<InspectorRuntimeAgent> m_runtimeAgent;
    9091    OwnPtr<InspectorConsoleAgent> m_consoleAgent;
     92    OwnPtr<InspectorTimelineAgent> m_timelineAgent;
    9193
    9294    OwnPtr<InspectorFrontendChannel> m_frontendChannel;
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r109214 r109540  
    4040        if (WebInspector.WorkerManager.isWorkerFrontend()) {
    4141            this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel);
     42            this.panels.timeline = new WebInspector.TimelinePanel();
    4243            this.panels.profiles = new WebInspector.ProfilesPanel();
    4344            this.panels.console = new WebInspector.ConsolePanel();
Note: See TracChangeset for help on using the changeset viewer.