⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243243 in webkit


Ignore:
Timestamp:
Mar 20, 2019, 2:53:06 PM (7 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Runtime: lazily create the agent
https://bugs.webkit.org/show_bug.cgi?id=195972
<rdar://problem/49039655>

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

  • inspector/JSGlobalObjectInspectorController.cpp:

(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::createLazyAgents):

  • inspector/agents/InspectorRuntimeAgent.h:

(Inspector::InspectorRuntimeAgent::enabled): Deleted.

  • inspector/agents/InspectorRuntimeAgent.cpp:

(Inspector::InspectorRuntimeAgent::didCreateFrontendAndBackend): Added.
(Inspector::InspectorRuntimeAgent::willDestroyFrontendAndBackend):

  • inspector/agents/JSGlobalObjectRuntimeAgent.h:
  • inspector/agents/JSGlobalObjectRuntimeAgent.cpp:

(Inspector::JSGlobalObjectRuntimeAgent::didCreateFrontendAndBackend): Deleted.

Source/WebCore:

No change in functionality.

  • inspector/InspectorController.cpp:

(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::createLazyAgents):

  • inspector/WorkerInspectorController.cpp:

(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::createLazyAgents):

  • inspector/agents/page/PageRuntimeAgent.h:
  • inspector/agents/page/PageRuntimeAgent.cpp:

(WebCore::PageRuntimeAgent::PageRuntimeAgent):
(WebCore::PageRuntimeAgent::enable):
(WebCore::PageRuntimeAgent::disable):
(WebCore::PageRuntimeAgent::didCreateMainWorldContext):
(WebCore::PageRuntimeAgent::reportExecutionContextCreation):
(WebCore::PageRuntimeAgent::didCreateFrontendAndBackend): Deleted.
(WebCore::PageRuntimeAgent::willDestroyFrontendAndBackend): Deleted.

  • inspector/agents/worker/WorkerRuntimeAgent.h:
  • inspector/agents/worker/WorkerRuntimeAgent.cpp:

(WebCore::WorkerRuntimeAgent::didCreateFrontendAndBackend): Deleted.
(WebCore::WorkerRuntimeAgent::willDestroyFrontendAndBackend): Deleted.

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r243237 r243243  
     12019-03-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Runtime: lazily create the agent
     4        https://bugs.webkit.org/show_bug.cgi?id=195972
     5        <rdar://problem/49039655>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/JSGlobalObjectInspectorController.cpp:
     10        (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
     11        (Inspector::JSGlobalObjectInspectorController::createLazyAgents):
     12
     13        * inspector/agents/InspectorRuntimeAgent.h:
     14        (Inspector::InspectorRuntimeAgent::enabled): Deleted.
     15        * inspector/agents/InspectorRuntimeAgent.cpp:
     16        (Inspector::InspectorRuntimeAgent::didCreateFrontendAndBackend): Added.
     17        (Inspector::InspectorRuntimeAgent::willDestroyFrontendAndBackend):
     18
     19        * inspector/agents/JSGlobalObjectRuntimeAgent.h:
     20        * inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
     21        (Inspector::JSGlobalObjectRuntimeAgent::didCreateFrontendAndBackend): Deleted.
     22
    1232019-03-20  Michael Saboff  <msaboff@apple.com>
    224
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp

    r243192 r243243  
    7373
    7474    auto inspectorAgent = std::make_unique<InspectorAgent>(context);
    75     auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(context);
    7675    auto consoleAgent = std::make_unique<InspectorConsoleAgent>(context);
    7776
     
    8180
    8281    m_agents.append(WTFMove(inspectorAgent));
    83     m_agents.append(WTFMove(runtimeAgent));
    8482    m_agents.append(WTFMove(consoleAgent));
    8583
     
    310308    auto context = jsAgentContext();
    311309
     310    m_agents.append(std::make_unique<JSGlobalObjectRuntimeAgent>(context));
     311
    312312    auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, m_consoleAgent);
    313313    m_debuggerAgent = debuggerAgent.get();
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp

    r241633 r243243  
    333333}
    334334
     335void InspectorRuntimeAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
     336{
     337}
     338
    335339void InspectorRuntimeAgent::willDestroyFrontendAndBackend(DisconnectReason reason)
    336340{
    337341    if (reason != DisconnectReason::InspectedTargetDestroyed && m_isTypeProfilingEnabled)
    338342        setTypeProfilerEnabledState(false);
     343
     344    String unused;
     345    disable(unused);
    339346}
    340347
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h

    r241633 r243243  
    5454    virtual ~InspectorRuntimeAgent();
    5555
     56    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
    5657    void willDestroyFrontendAndBackend(DisconnectReason) override;
    5758
     
    7576    void disableControlFlowProfiler(ErrorString&) override;
    7677    void getBasicBlocks(ErrorString&, const String& in_sourceID, RefPtr<JSON::ArrayOf<Protocol::Runtime::BasicBlock>>& out_basicBlocks) override;
    77 
    78     bool enabled() const { return m_enabled; }
    7978
    8079protected:
  • trunk/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.cpp

    r233122 r243243  
    4343}
    4444
    45 void JSGlobalObjectRuntimeAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)
    46 {
    47 }
    48 
    4945InjectedScript JSGlobalObjectRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
    5046{
  • trunk/Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.h

    r225263 r243243  
    4141    JSGlobalObjectRuntimeAgent(JSAgentContext&);
    4242
    43     void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override;
    44 
    4543    InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
    4644
  • trunk/Source/WebCore/ChangeLog

    r243239 r243243  
     12019-03-20  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Runtime: lazily create the agent
     4        https://bugs.webkit.org/show_bug.cgi?id=195972
     5        <rdar://problem/49039655>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        No change in functionality.
     10
     11        * inspector/InspectorController.cpp:
     12        (WebCore::InspectorController::InspectorController):
     13        (WebCore::InspectorController::createLazyAgents):
     14
     15        * inspector/WorkerInspectorController.cpp:
     16        (WebCore::WorkerInspectorController::WorkerInspectorController):
     17        (WebCore::WorkerInspectorController::createLazyAgents):
     18
     19        * inspector/agents/page/PageRuntimeAgent.h:
     20        * inspector/agents/page/PageRuntimeAgent.cpp:
     21        (WebCore::PageRuntimeAgent::PageRuntimeAgent):
     22        (WebCore::PageRuntimeAgent::enable):
     23        (WebCore::PageRuntimeAgent::disable):
     24        (WebCore::PageRuntimeAgent::didCreateMainWorldContext):
     25        (WebCore::PageRuntimeAgent::reportExecutionContextCreation):
     26        (WebCore::PageRuntimeAgent::didCreateFrontendAndBackend): Deleted.
     27        (WebCore::PageRuntimeAgent::willDestroyFrontendAndBackend): Deleted.
     28
     29        * inspector/agents/worker/WorkerRuntimeAgent.h:
     30        * inspector/agents/worker/WorkerRuntimeAgent.cpp:
     31        (WebCore::WorkerRuntimeAgent::didCreateFrontendAndBackend): Deleted.
     32        (WebCore::WorkerRuntimeAgent::willDestroyFrontendAndBackend): Deleted.
     33
    1342019-03-19  Ryosuke Niwa  <rniwa@webkit.org>
    235
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r243219 r243243  
    116116    m_agents.append(WTFMove(pageAgentPtr));
    117117
    118     auto runtimeAgent = std::make_unique<PageRuntimeAgent>(pageContext, pageAgent);
    119     m_instrumentingAgents->setPageRuntimeAgent(runtimeAgent.get());
    120     m_agents.append(WTFMove(runtimeAgent));
    121 
    122118    auto domAgentPtr = std::make_unique<InspectorDOMAgent>(pageContext, pageAgent, m_overlay.get());
    123119    m_domAgent = domAgentPtr.get();
     
    170166    auto pageContext = pageAgentContext();
    171167
     168    m_agents.append(std::make_unique<PageRuntimeAgent>(pageContext));
     169
    172170    auto debuggerAgent = std::make_unique<PageDebuggerAgent>(pageContext, m_pageAgent);
    173171    auto debuggerAgentPtr = debuggerAgent.get();
    174 
    175172    m_agents.append(WTFMove(debuggerAgent));
     173
    176174    m_agents.append(std::make_unique<PageNetworkAgent>(pageContext, m_pageAgent));
    177175    m_agents.append(std::make_unique<InspectorCSSAgent>(pageContext, m_domAgent));
  • trunk/Source/WebCore/inspector/WorkerInspectorController.cpp

    r243219 r243243  
    7272    auto consoleAgent = std::make_unique<WorkerConsoleAgent>(workerContext);
    7373    m_instrumentingAgents->setWebConsoleAgent(consoleAgent.get());
    74 
    75     m_agents.append(std::make_unique<WorkerRuntimeAgent>(workerContext));
    7674    m_agents.append(WTFMove(consoleAgent));
    7775
     
    168166    auto workerContext = workerAgentContext();
    169167
     168    m_agents.append(std::make_unique<WorkerRuntimeAgent>(workerContext));
     169
    170170#if ENABLE(SERVICE_WORKER)
    171171    if (is<ServiceWorkerGlobalScope>(m_workerGlobalScope)) {
  • trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp

    r241633 r243243  
    5454using namespace Inspector;
    5555
    56 PageRuntimeAgent::PageRuntimeAgent(PageAgentContext& context, InspectorPageAgent* pageAgent)
     56PageRuntimeAgent::PageRuntimeAgent(PageAgentContext& context)
    5757    : InspectorRuntimeAgent(context)
    5858    , m_frontendDispatcher(std::make_unique<Inspector::RuntimeFrontendDispatcher>(context.frontendRouter))
    5959    , m_backendDispatcher(Inspector::RuntimeBackendDispatcher::create(context.backendDispatcher, this))
    60     , m_pageAgent(pageAgent)
     60    , m_instrumentingAgents(context.instrumentingAgents)
    6161    , m_inspectedPage(context.inspectedPage)
    6262{
    6363}
    6464
    65 void PageRuntimeAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
    66 {
    67 }
    68 
    69 void PageRuntimeAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason reason)
    70 {
    71     String unused;
    72     disable(unused);
    73 
    74     InspectorRuntimeAgent::willDestroyFrontendAndBackend(reason);
    75 }
    76 
    7765void PageRuntimeAgent::enable(ErrorString& errorString)
    7866{
    79     if (enabled())
    80         return;
     67    bool enabled = m_instrumentingAgents.pageRuntimeAgent() == this;
    8168
    8269    InspectorRuntimeAgent::enable(errorString);
    8370
    84     // Only report existing contexts if the page did commit load, otherwise we may
    85     // unintentionally initialize contexts in the frames which may trigger some listeners
    86     // that are expected to be triggered only after the load is committed, see http://crbug.com/131623
    87     if (m_mainWorldContextCreated)
     71    m_instrumentingAgents.setPageRuntimeAgent(this);
     72
     73    if (!enabled)
    8874        reportExecutionContextCreation();
    8975}
     
    9177void PageRuntimeAgent::disable(ErrorString& errorString)
    9278{
    93     if (!enabled())
    94         return;
     79    m_instrumentingAgents.setPageRuntimeAgent(nullptr);
    9580
    9681    InspectorRuntimeAgent::disable(errorString);
     
    9984void PageRuntimeAgent::didCreateMainWorldContext(Frame& frame)
    10085{
    101     m_mainWorldContextCreated = true;
    102 
    103     if (!enabled())
     86    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     87    if (!pageAgent)
    10488        return;
    10589
    106     String frameId = m_pageAgent->frameId(&frame);
    107     JSC::ExecState* scriptState = mainWorldExecState(&frame);
     90    auto frameId = pageAgent->frameId(&frame);
     91    auto* scriptState = mainWorldExecState(&frame);
    10892    notifyContextCreated(frameId, scriptState, nullptr, true);
    10993}
     
    137121void PageRuntimeAgent::reportExecutionContextCreation()
    138122{
     123    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     124    if (!pageAgent)
     125        return;
     126
    139127    Vector<std::pair<JSC::ExecState*, SecurityOrigin*>> isolatedContexts;
    140128    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
    141129        if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
    142130            continue;
    143         String frameId = m_pageAgent->frameId(frame);
     131        String frameId = pageAgent->frameId(frame);
    144132
    145133        JSC::ExecState* scriptState = mainWorldExecState(frame);
  • trunk/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h

    r241633 r243243  
    4242namespace WebCore {
    4343
    44 class InspectorPageAgent;
    4544class Frame;
    4645class Page;
     
    5251    WTF_MAKE_FAST_ALLOCATED;
    5352public:
    54     PageRuntimeAgent(PageAgentContext&, InspectorPageAgent*);
     53    PageRuntimeAgent(PageAgentContext&);
    5554    virtual ~PageRuntimeAgent() = default;
    5655
    57     void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
    58     void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
     56    // RuntimeBackendDispatcherHandler
    5957    void enable(ErrorString&) override;
    6058    void disable(ErrorString&) override;
     
    7371    std::unique_ptr<Inspector::RuntimeFrontendDispatcher> m_frontendDispatcher;
    7472    RefPtr<Inspector::RuntimeBackendDispatcher> m_backendDispatcher;
    75     InspectorPageAgent* m_pageAgent;
     73
     74    InstrumentingAgents& m_instrumentingAgents;
    7675
    7776    Page& m_inspectedPage;
    78 
    79     bool m_mainWorldContextCreated { false };
    8077};
    8178
  • trunk/Source/WebCore/inspector/agents/worker/WorkerRuntimeAgent.cpp

    r237766 r243243  
    5050}
    5151
    52 void WorkerRuntimeAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)
    53 {
    54 }
    55 
    56 void WorkerRuntimeAgent::willDestroyFrontendAndBackend(DisconnectReason reason)
    57 {
    58     InspectorRuntimeAgent::willDestroyFrontendAndBackend(reason);
    59 }
    60 
    6152InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
    6253{
  • trunk/Source/WebCore/inspector/agents/worker/WorkerRuntimeAgent.h

    r228218 r243243  
    4747    ~WorkerRuntimeAgent() = default;
    4848
    49     void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
    50     void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
    51 
    5249private:
    5350    Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
Note: See TracChangeset for help on using the changeset viewer.