Changeset 243119 in webkit


Ignore:
Timestamp:
Mar 18, 2019 5:31:24 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Timeline: lazily create the agent
https://bugs.webkit.org/show_bug.cgi?id=195865
<rdar://problem/48965403>

Reviewed by Joseph Pecoraro.

No change in functionality.

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

(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::toggleScriptProfilerInstrument):
(WebCore::InspectorTimelineAgent::toggleHeapInstrument):
(WebCore::InspectorTimelineAgent::setFrameIdentifier):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::startProfiling):
(WebCore::InspectorInstrumentation::stopProfiling):
(WebCore::InspectorInstrumentation::didRequestAnimationFrame):
(WebCore::InspectorInstrumentation::didCancelAnimationFrame):

  • inspector/InstrumentingAgents.h:

(WebCore::InstrumentingAgents::inspectorScriptProfilerAgent const): Added.
(WebCore::InstrumentingAgents::setInspectorScriptProfilerAgent): Added.

  • inspector/InstrumentingAgents.cpp:

(WebCore::InstrumentingAgents::reset):

  • inspector/InspectorController.cpp:

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

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243118 r243119  
     12019-03-18  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Timeline: lazily create the agent
     4        https://bugs.webkit.org/show_bug.cgi?id=195865
     5        <rdar://problem/48965403>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        No change in functionality.
     10
     11        * inspector/agents/InspectorTimelineAgent.h:
     12        * inspector/agents/InspectorTimelineAgent.cpp:
     13        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
     14        (WebCore::InspectorTimelineAgent::toggleScriptProfilerInstrument):
     15        (WebCore::InspectorTimelineAgent::toggleHeapInstrument):
     16        (WebCore::InspectorTimelineAgent::setFrameIdentifier):
     17
     18        * inspector/InspectorInstrumentation.h:
     19        (WebCore::InspectorInstrumentation::startProfiling):
     20        (WebCore::InspectorInstrumentation::stopProfiling):
     21        (WebCore::InspectorInstrumentation::didRequestAnimationFrame):
     22        (WebCore::InspectorInstrumentation::didCancelAnimationFrame):
     23
     24        * inspector/InstrumentingAgents.h:
     25        (WebCore::InstrumentingAgents::inspectorScriptProfilerAgent const): Added.
     26        (WebCore::InstrumentingAgents::setInspectorScriptProfilerAgent): Added.
     27        * inspector/InstrumentingAgents.cpp:
     28        (WebCore::InstrumentingAgents::reset):
     29
     30        * inspector/InspectorController.cpp:
     31        (WebCore::InspectorController::InspectorController):
     32        (WebCore::InspectorController::createLazyAgents):
     33
    1342019-03-18  Darin Adler  <darin@apple.com>
    235
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r242940 r243119  
    137137
    138138    auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(pageContext);
    139     InspectorScriptProfilerAgent* scriptProfilerAgent = scriptProfilerAgentPtr.get();
     139    m_instrumentingAgents->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
    140140    m_agents.append(WTFMove(scriptProfilerAgentPtr));
    141141
     
    144144    m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get());
    145145    m_agents.append(WTFMove(consoleAgentPtr));
    146 
    147     m_agents.append(std::make_unique<InspectorTimelineAgent>(pageContext, scriptProfilerAgent, heapAgent, pageAgent));
    148146
    149147    ASSERT(m_injectedScriptManager->commandLineAPIHost());
     
    208206    m_agents.append(std::make_unique<PageAuditAgent>(pageContext));
    209207    m_agents.append(std::make_unique<InspectorCanvasAgent>(pageContext));
     208    m_agents.append(std::make_unique<InspectorTimelineAgent>(pageContext));
    210209}
    211210
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r242992 r243119  
    14091409inline void InspectorInstrumentation::startProfiling(Page& page, JSC::ExecState* exec, const String &title)
    14101410{
     1411    FAST_RETURN_IF_NO_FRONTENDS(void());
    14111412    startProfilingImpl(instrumentingAgentsForPage(page), exec, title);
    14121413}
     
    14141415inline void InspectorInstrumentation::stopProfiling(Page& page, JSC::ExecState* exec, const String &title)
    14151416{
     1417    FAST_RETURN_IF_NO_FRONTENDS(void());
    14161418    stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
    14171419}
     
    14261428inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)
    14271429{
     1430    FAST_RETURN_IF_NO_FRONTENDS(void());
    14281431    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
    14291432        didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document);
     
    14321435inline void InspectorInstrumentation::didCancelAnimationFrame(Document& document, int callbackId)
    14331436{
     1437    FAST_RETURN_IF_NO_FRONTENDS(void());
    14341438    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
    14351439        didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document);
  • trunk/Source/WebCore/inspector/InstrumentingAgents.cpp

    r240457 r243119  
    5454    m_inspectorNetworkAgent = nullptr;
    5555    m_pageRuntimeAgent = nullptr;
     56    m_inspectorScriptProfilerAgent = nullptr;
    5657    m_inspectorTimelineAgent = nullptr;
    5758    m_persistentInspectorTimelineAgent = nullptr;
  • trunk/Source/WebCore/inspector/InstrumentingAgents.h

    r240457 r243119  
    4040class InspectorAgent;
    4141class InspectorDebuggerAgent;
     42class InspectorScriptProfilerAgent;
    4243}
    4344
     
    103104    void setPageRuntimeAgent(PageRuntimeAgent* agent) { m_pageRuntimeAgent = agent; }
    104105
     106    Inspector::InspectorScriptProfilerAgent* inspectorScriptProfilerAgent() const { return m_inspectorScriptProfilerAgent; }
     107    void setInspectorScriptProfilerAgent(Inspector::InspectorScriptProfilerAgent* agent) { m_inspectorScriptProfilerAgent = agent; }
     108
    105109    InspectorTimelineAgent* inspectorTimelineAgent() const { return m_inspectorTimelineAgent; }
    106110    void setInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_inspectorTimelineAgent = agent; }
     
    158162    InspectorNetworkAgent* m_inspectorNetworkAgent { nullptr };
    159163    PageRuntimeAgent* m_pageRuntimeAgent { nullptr };
     164    Inspector::InspectorScriptProfilerAgent* m_inspectorScriptProfilerAgent { nullptr };
    160165    InspectorTimelineAgent* m_inspectorTimelineAgent { nullptr };
    161166    InspectorTimelineAgent* m_persistentInspectorTimelineAgent { nullptr };
  • trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp

    r240457 r243119  
    4242#include "InstrumentingAgents.h"
    4343#include "JSDOMWindow.h"
     44#include "PageHeapAgent.h"
    4445#include "PageScriptDebugServer.h"
    4546#include "RenderView.h"
     
    4950#include <JavaScriptCore/ConsoleMessage.h>
    5051#include <JavaScriptCore/InspectorDebuggerAgent.h>
    51 #include <JavaScriptCore/InspectorHeapAgent.h>
    5252#include <JavaScriptCore/InspectorScriptProfilerAgent.h>
    5353#include <JavaScriptCore/ScriptBreakpoint.h>
     
    8484#endif
    8585
    86 InspectorTimelineAgent::InspectorTimelineAgent(WebAgentContext& context, InspectorScriptProfilerAgent* scriptProfileAgent, InspectorHeapAgent* heapAgent, InspectorPageAgent* pageAgent)
     86InspectorTimelineAgent::InspectorTimelineAgent(WebAgentContext& context)
    8787    : InspectorAgentBase("Timeline"_s, context)
    8888    , m_frontendDispatcher(std::make_unique<Inspector::TimelineFrontendDispatcher>(context.frontendRouter))
    8989    , m_backendDispatcher(Inspector::TimelineBackendDispatcher::create(context.backendDispatcher, this))
    90     , m_scriptProfilerAgent(scriptProfileAgent)
    91     , m_heapAgent(heapAgent)
    92     , m_pageAgent(pageAgent)
    9390{
    9491}
     
    533530void InspectorTimelineAgent::toggleScriptProfilerInstrument(InstrumentState state)
    534531{
    535     if (m_scriptProfilerAgent) {
     532    if (auto* scriptProfilerAgent = m_instrumentingAgents.inspectorScriptProfilerAgent()) {
    536533        ErrorString unused;
    537534        if (state == InstrumentState::Start) {
    538535            const bool includeSamples = true;
    539             m_scriptProfilerAgent->startTracking(unused, &includeSamples);
     536            scriptProfilerAgent->startTracking(unused, &includeSamples);
    540537        } else
    541             m_scriptProfilerAgent->stopTracking(unused);
     538            scriptProfilerAgent->stopTracking(unused);
    542539    }
    543540}
     
    545542void InspectorTimelineAgent::toggleHeapInstrument(InstrumentState state)
    546543{
    547     if (m_heapAgent) {
     544    if (auto* heapAgent = m_instrumentingAgents.pageHeapAgent()) {
    548545        ErrorString unused;
    549546        if (state == InstrumentState::Start) {
    550547            if (m_autoCapturePhase == AutoCapturePhase::None || m_autoCapturePhase == AutoCapturePhase::FirstNavigation)
    551                 m_heapAgent->startTracking(unused);
     548                heapAgent->startTracking(unused);
    552549        } else
    553             m_heapAgent->stopTracking(unused);
     550            heapAgent->stopTracking(unused);
    554551    }
    555552}
     
    713710void InspectorTimelineAgent::setFrameIdentifier(JSON::Object* record, Frame* frame)
    714711{
    715     if (!frame || !m_pageAgent)
     712    if (!frame)
    716713        return;
    717     String frameId;
    718     if (frame && m_pageAgent)
    719         frameId = m_pageAgent->frameId(frame);
    720     record->setString("frameId", frameId);
     714
     715    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     716    if (!pageAgent)
     717        return;
     718
     719    record->setString("frameId"_s, pageAgent->frameId(frame));
    721720}
    722721
  • trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h

    r240457 r243119  
    4141#include <wtf/Vector.h>
    4242
    43 namespace Inspector {
    44 class InspectorHeapAgent;
    45 class InspectorScriptProfilerAgent;
    46 }
    47 
    4843namespace WebCore {
    4944
     
    5146class FloatQuad;
    5247class Frame;
    53 class InspectorPageAgent;
    5448class RenderObject;
    5549class RunLoopObserver;
     
    9589    WTF_MAKE_FAST_ALLOCATED;
    9690public:
    97     InspectorTimelineAgent(WebAgentContext&, Inspector::InspectorScriptProfilerAgent*, Inspector::InspectorHeapAgent*, InspectorPageAgent*);
     91    InspectorTimelineAgent(WebAgentContext&);
    9892    virtual ~InspectorTimelineAgent();
    9993
     
    213207    std::unique_ptr<Inspector::TimelineFrontendDispatcher> m_frontendDispatcher;
    214208    RefPtr<Inspector::TimelineBackendDispatcher> m_backendDispatcher;
    215     Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent;
    216     Inspector::InspectorHeapAgent* m_heapAgent;
    217     InspectorPageAgent* m_pageAgent;
    218209
    219210    Vector<TimelineRecordEntry> m_recordStack;
Note: See TracChangeset for help on using the changeset viewer.