Diff
Modified: trunk/Source/WebCore/ChangeLog (243118 => 243119)
--- trunk/Source/WebCore/ChangeLog 2019-03-19 00:27:10 UTC (rev 243118)
+++ trunk/Source/WebCore/ChangeLog 2019-03-19 00:31:24 UTC (rev 243119)
@@ -1,3 +1,36 @@
+2019-03-18 Devin Rousso <[email protected]>
+
+ 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):
+
2019-03-18 Darin Adler <[email protected]>
Cut down on use of StringBuffer, possibly leading toward removing it entirely
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (243118 => 243119)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2019-03-19 00:27:10 UTC (rev 243118)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2019-03-19 00:31:24 UTC (rev 243119)
@@ -136,7 +136,7 @@
m_agents.append(WTFMove(heapAgentPtr));
auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(pageContext);
- InspectorScriptProfilerAgent* scriptProfilerAgent = scriptProfilerAgentPtr.get();
+ m_instrumentingAgents->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
m_agents.append(WTFMove(scriptProfilerAgentPtr));
auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, heapAgent, m_domAgent);
@@ -144,8 +144,6 @@
m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get());
m_agents.append(WTFMove(consoleAgentPtr));
- m_agents.append(std::make_unique<InspectorTimelineAgent>(pageContext, scriptProfilerAgent, heapAgent, pageAgent));
-
ASSERT(m_injectedScriptManager->commandLineAPIHost());
if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
commandLineAPIHost->init(m_inspectorAgent, consoleAgent, domStorageAgent, databaseAgent);
@@ -207,6 +205,7 @@
#endif
m_agents.append(std::make_unique<PageAuditAgent>(pageContext));
m_agents.append(std::make_unique<InspectorCanvasAgent>(pageContext));
+ m_agents.append(std::make_unique<InspectorTimelineAgent>(pageContext));
}
void InspectorController::inspectedPageDestroyed()
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (243118 => 243119)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2019-03-19 00:27:10 UTC (rev 243118)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2019-03-19 00:31:24 UTC (rev 243119)
@@ -1408,11 +1408,13 @@
inline void InspectorInstrumentation::startProfiling(Page& page, JSC::ExecState* exec, const String &title)
{
+ FAST_RETURN_IF_NO_FRONTENDS(void());
startProfilingImpl(instrumentingAgentsForPage(page), exec, title);
}
inline void InspectorInstrumentation::stopProfiling(Page& page, JSC::ExecState* exec, const String &title)
{
+ FAST_RETURN_IF_NO_FRONTENDS(void());
stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
}
@@ -1425,6 +1427,7 @@
inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)
{
+ FAST_RETURN_IF_NO_FRONTENDS(void());
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document);
}
@@ -1431,6 +1434,7 @@
inline void InspectorInstrumentation::didCancelAnimationFrame(Document& document, int callbackId)
{
+ FAST_RETURN_IF_NO_FRONTENDS(void());
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document);
}
Modified: trunk/Source/WebCore/inspector/InstrumentingAgents.cpp (243118 => 243119)
--- trunk/Source/WebCore/inspector/InstrumentingAgents.cpp 2019-03-19 00:27:10 UTC (rev 243118)
+++ trunk/Source/WebCore/inspector/InstrumentingAgents.cpp 2019-03-19 00:31:24 UTC (rev 243119)
@@ -53,6 +53,7 @@
m_inspectorDOMAgent = nullptr;
m_inspectorNetworkAgent = nullptr;
m_pageRuntimeAgent = nullptr;
+ m_inspectorScriptProfilerAgent = nullptr;
m_inspectorTimelineAgent = nullptr;
m_persistentInspectorTimelineAgent = nullptr;
m_inspectorDOMStorageAgent = nullptr;
Modified: trunk/Source/WebCore/inspector/InstrumentingAgents.h (243118 => 243119)
--- trunk/Source/WebCore/inspector/InstrumentingAgents.h 2019-03-19 00:27:10 UTC (rev 243118)
+++ trunk/Source/WebCore/inspector/InstrumentingAgents.h 2019-03-19 00:31:24 UTC (rev 243119)
@@ -39,6 +39,7 @@
namespace Inspector {
class InspectorAgent;
class InspectorDebuggerAgent;
+class InspectorScriptProfilerAgent;
}
namespace WebCore {
@@ -102,6 +103,9 @@
PageRuntimeAgent* pageRuntimeAgent() const { return m_pageRuntimeAgent; }
void setPageRuntimeAgent(PageRuntimeAgent* agent) { m_pageRuntimeAgent = agent; }
+ Inspector::InspectorScriptProfilerAgent* inspectorScriptProfilerAgent() const { return m_inspectorScriptProfilerAgent; }
+ void setInspectorScriptProfilerAgent(Inspector::InspectorScriptProfilerAgent* agent) { m_inspectorScriptProfilerAgent = agent; }
+
InspectorTimelineAgent* inspectorTimelineAgent() const { return m_inspectorTimelineAgent; }
void setInspectorTimelineAgent(InspectorTimelineAgent* agent) { m_inspectorTimelineAgent = agent; }
@@ -157,6 +161,7 @@
InspectorDOMAgent* m_inspectorDOMAgent { nullptr };
InspectorNetworkAgent* m_inspectorNetworkAgent { nullptr };
PageRuntimeAgent* m_pageRuntimeAgent { nullptr };
+ Inspector::InspectorScriptProfilerAgent* m_inspectorScriptProfilerAgent { nullptr };
InspectorTimelineAgent* m_inspectorTimelineAgent { nullptr };
InspectorTimelineAgent* m_persistentInspectorTimelineAgent { nullptr };
InspectorDOMStorageAgent* m_inspectorDOMStorageAgent { nullptr };
Modified: trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp (243118 => 243119)
--- trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp 2019-03-19 00:27:10 UTC (rev 243118)
+++ trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp 2019-03-19 00:31:24 UTC (rev 243119)
@@ -41,6 +41,7 @@
#include "InspectorPageAgent.h"
#include "InstrumentingAgents.h"
#include "JSDOMWindow.h"
+#include "PageHeapAgent.h"
#include "PageScriptDebugServer.h"
#include "RenderView.h"
#include "ScriptState.h"
@@ -48,7 +49,6 @@
#include "WebConsoleAgent.h"
#include <_javascript_Core/ConsoleMessage.h>
#include <_javascript_Core/InspectorDebuggerAgent.h>
-#include <_javascript_Core/InspectorHeapAgent.h>
#include <_javascript_Core/InspectorScriptProfilerAgent.h>
#include <_javascript_Core/ScriptBreakpoint.h>
#include <wtf/Stopwatch.h>
@@ -83,13 +83,10 @@
}
#endif
-InspectorTimelineAgent::InspectorTimelineAgent(WebAgentContext& context, InspectorScriptProfilerAgent* scriptProfileAgent, InspectorHeapAgent* heapAgent, InspectorPageAgent* pageAgent)
+InspectorTimelineAgent::InspectorTimelineAgent(WebAgentContext& context)
: InspectorAgentBase("Timeline"_s, context)
, m_frontendDispatcher(std::make_unique<Inspector::TimelineFrontendDispatcher>(context.frontendRouter))
, m_backendDispatcher(Inspector::TimelineBackendDispatcher::create(context.backendDispatcher, this))
- , m_scriptProfilerAgent(scriptProfileAgent)
- , m_heapAgent(heapAgent)
- , m_pageAgent(pageAgent)
{
}
@@ -532,25 +529,25 @@
void InspectorTimelineAgent::toggleScriptProfilerInstrument(InstrumentState state)
{
- if (m_scriptProfilerAgent) {
+ if (auto* scriptProfilerAgent = m_instrumentingAgents.inspectorScriptProfilerAgent()) {
ErrorString unused;
if (state == InstrumentState::Start) {
const bool includeSamples = true;
- m_scriptProfilerAgent->startTracking(unused, &includeSamples);
+ scriptProfilerAgent->startTracking(unused, &includeSamples);
} else
- m_scriptProfilerAgent->stopTracking(unused);
+ scriptProfilerAgent->stopTracking(unused);
}
}
void InspectorTimelineAgent::toggleHeapInstrument(InstrumentState state)
{
- if (m_heapAgent) {
+ if (auto* heapAgent = m_instrumentingAgents.pageHeapAgent()) {
ErrorString unused;
if (state == InstrumentState::Start) {
if (m_autoCapturePhase == AutoCapturePhase::None || m_autoCapturePhase == AutoCapturePhase::FirstNavigation)
- m_heapAgent->startTracking(unused);
+ heapAgent->startTracking(unused);
} else
- m_heapAgent->stopTracking(unused);
+ heapAgent->stopTracking(unused);
}
}
@@ -712,12 +709,14 @@
void InspectorTimelineAgent::setFrameIdentifier(JSON::Object* record, Frame* frame)
{
- if (!frame || !m_pageAgent)
+ if (!frame)
return;
- String frameId;
- if (frame && m_pageAgent)
- frameId = m_pageAgent->frameId(frame);
- record->setString("frameId", frameId);
+
+ auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
+ if (!pageAgent)
+ return;
+
+ record->setString("frameId"_s, pageAgent->frameId(frame));
}
void InspectorTimelineAgent::didCompleteRecordEntry(const TimelineRecordEntry& entry)
Modified: trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h (243118 => 243119)
--- trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h 2019-03-19 00:27:10 UTC (rev 243118)
+++ trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h 2019-03-19 00:31:24 UTC (rev 243119)
@@ -40,17 +40,11 @@
#include <wtf/JSONValues.h>
#include <wtf/Vector.h>
-namespace Inspector {
-class InspectorHeapAgent;
-class InspectorScriptProfilerAgent;
-}
-
namespace WebCore {
class Event;
class FloatQuad;
class Frame;
-class InspectorPageAgent;
class RenderObject;
class RunLoopObserver;
@@ -94,7 +88,7 @@
WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent);
WTF_MAKE_FAST_ALLOCATED;
public:
- InspectorTimelineAgent(WebAgentContext&, Inspector::InspectorScriptProfilerAgent*, Inspector::InspectorHeapAgent*, InspectorPageAgent*);
+ InspectorTimelineAgent(WebAgentContext&);
virtual ~InspectorTimelineAgent();
void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) final;
@@ -212,9 +206,6 @@
std::unique_ptr<Inspector::TimelineFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::TimelineBackendDispatcher> m_backendDispatcher;
- Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent;
- Inspector::InspectorHeapAgent* m_heapAgent;
- InspectorPageAgent* m_pageAgent;
Vector<TimelineRecordEntry> m_recordStack;
Vector<TimelineRecordEntry> m_pendingConsoleProfileRecords;