Modified: trunk/Source/WebCore/ChangeLog (224529 => 224530)
--- trunk/Source/WebCore/ChangeLog 2017-11-07 04:09:59 UTC (rev 224529)
+++ trunk/Source/WebCore/ChangeLog 2017-11-07 09:32:14 UTC (rev 224530)
@@ -1,3 +1,23 @@
+2017-11-07 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Create inspector agents lazily
+ https://bugs.webkit.org/show_bug.cgi?id=179360
+
+ Reviewed by Sam Weinig.
+
+ * inspector/CommandLineAPIHost.h:
+ Modernize style.
+
+ * inspector/InspectorController.h:
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ (WebCore::InspectorController::pageAgentContext):
+ (WebCore::InspectorController::createLazyAgents):
+ (WebCore::InspectorController::connectFrontend):
+ Move many of the agent construction to happen lazily. These
+ agent's aren't needed until an inspector connects, so defer
+ creation until an inspector connects.
+
2017-11-06 Zalan Bujtas <za...@apple.com>
[LayoutState cleanup] Move m_layoutState from RenderView to LayoutContext
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (224529 => 224530)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2017-11-07 04:09:59 UTC (rev 224529)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2017-11-07 09:32:14 UTC (rev 224530)
@@ -83,8 +83,8 @@
#include "PageDebuggable.h"
#endif
+namespace WebCore {
-namespace WebCore {
using namespace JSC;
using namespace Inspector;
@@ -101,23 +101,8 @@
{
ASSERT_ARG(inspectorClient, inspectorClient);
- AgentContext baseContext = {
- *this,
- *m_injectedScriptManager,
- m_frontendRouter.get(),
- m_backendDispatcher.get()
- };
+ auto pageContext = pageAgentContext();
- WebAgentContext webContext = {
- baseContext,
- m_instrumentingAgents.get()
- };
-
- PageAgentContext pageContext = {
- webContext,
- m_page
- };
-
auto inspectorAgentPtr = std::make_unique<InspectorAgent>(pageContext);
m_inspectorAgent = inspectorAgentPtr.get();
m_instrumentingAgents->setInspectorAgent(m_inspectorAgent);
@@ -128,31 +113,18 @@
m_pageAgent = pageAgentPtr.get();
m_agents.append(WTFMove(pageAgentPtr));
- auto runtimeAgentPtr = std::make_unique<PageRuntimeAgent>(pageContext, pageAgent);
- PageRuntimeAgent* runtimeAgent = runtimeAgentPtr.get();
- m_instrumentingAgents->setPageRuntimeAgent(runtimeAgent);
- m_agents.append(WTFMove(runtimeAgentPtr));
+ auto runtimeAgent = std::make_unique<PageRuntimeAgent>(pageContext, pageAgent);
+ m_instrumentingAgents->setPageRuntimeAgent(runtimeAgent.get());
+ m_agents.append(WTFMove(runtimeAgent));
auto domAgentPtr = std::make_unique<InspectorDOMAgent>(pageContext, pageAgent, m_overlay.get());
m_domAgent = domAgentPtr.get();
m_agents.append(WTFMove(domAgentPtr));
- m_agents.append(std::make_unique<InspectorCSSAgent>(pageContext, m_domAgent));
-
auto databaseAgentPtr = std::make_unique<InspectorDatabaseAgent>(pageContext);
InspectorDatabaseAgent* databaseAgent = databaseAgentPtr.get();
m_agents.append(WTFMove(databaseAgentPtr));
- m_agents.append(std::make_unique<InspectorNetworkAgent>(pageContext, pageAgent));
-
-#if ENABLE(INDEXED_DATABASE)
- m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext, pageAgent));
-#endif
-
-#if ENABLE(RESOURCE_USAGE)
- m_agents.append(std::make_unique<InspectorMemoryAgent>(pageContext));
-#endif
-
auto domStorageAgentPtr = std::make_unique<InspectorDOMStorageAgent>(pageContext, m_pageAgent);
InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get();
m_agents.append(WTFMove(domStorageAgentPtr));
@@ -170,15 +142,7 @@
m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get());
m_agents.append(WTFMove(consoleAgentPtr));
- auto debuggerAgentPtr = std::make_unique<PageDebuggerAgent>(pageContext, pageAgent, m_overlay.get());
- PageDebuggerAgent* debuggerAgent = debuggerAgentPtr.get();
- m_agents.append(WTFMove(debuggerAgentPtr));
-
m_agents.append(std::make_unique<InspectorTimelineAgent>(pageContext, scriptProfilerAgent, heapAgent, pageAgent));
- m_agents.append(std::make_unique<InspectorDOMDebuggerAgent>(pageContext, m_domAgent, debuggerAgent));
- m_agents.append(std::make_unique<InspectorApplicationCacheAgent>(pageContext, pageAgent));
- m_agents.append(std::make_unique<InspectorLayerTreeAgent>(pageContext));
- m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext));
auto canvasAgentPtr = std::make_unique<InspectorCanvasAgent>(pageContext);
m_instrumentingAgents->setInspectorCanvasAgent(canvasAgentPtr.get());
@@ -186,7 +150,8 @@
ASSERT(m_injectedScriptManager->commandLineAPIHost());
if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) {
- commandLineAPIHost->init(m_inspectorAgent
+ commandLineAPIHost->init(
+ m_inspectorAgent
, consoleAgent
, m_domAgent
, domStorageAgent
@@ -201,6 +166,55 @@
ASSERT(!m_inspectorClient);
}
+PageAgentContext InspectorController::pageAgentContext()
+{
+ AgentContext baseContext = {
+ *this,
+ *m_injectedScriptManager,
+ m_frontendRouter.get(),
+ m_backendDispatcher.get()
+ };
+
+ WebAgentContext webContext = {
+ baseContext,
+ m_instrumentingAgents.get()
+ };
+
+ PageAgentContext pageContext = {
+ webContext,
+ m_page
+ };
+
+ return pageContext;
+}
+
+void InspectorController::createLazyAgents()
+{
+ if (m_didCreateLazyAgents)
+ return;
+
+ m_didCreateLazyAgents = true;
+
+ auto pageContext = pageAgentContext();
+
+ auto debuggerAgent = std::make_unique<PageDebuggerAgent>(pageContext, m_pageAgent, m_overlay.get());
+ auto debuggerAgentPtr = debuggerAgent.get();
+
+ m_agents.append(WTFMove(debuggerAgent));
+ m_agents.append(std::make_unique<InspectorNetworkAgent>(pageContext, m_pageAgent));
+ m_agents.append(std::make_unique<InspectorCSSAgent>(pageContext, m_domAgent));
+ m_agents.append(std::make_unique<InspectorDOMDebuggerAgent>(pageContext, m_domAgent, debuggerAgentPtr));
+ m_agents.append(std::make_unique<InspectorApplicationCacheAgent>(pageContext, m_pageAgent));
+ m_agents.append(std::make_unique<InspectorLayerTreeAgent>(pageContext));
+ m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext));
+#if ENABLE(INDEXED_DATABASE)
+ m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext, m_pageAgent));
+#endif
+#if ENABLE(RESOURCE_USAGE)
+ m_agents.append(std::make_unique<InspectorMemoryAgent>(pageContext));
+#endif
+}
+
void InspectorController::inspectedPageDestroyed()
{
// Clean up resources and disconnect local and remote frontends.
@@ -252,6 +266,8 @@
ASSERT_ARG(frontendChannel, frontendChannel);
ASSERT(m_inspectorClient);
+ createLazyAgents();
+
bool connectedFirstFrontend = !m_frontendRouter->hasFrontends();
m_isAutomaticInspection = isAutomaticInspection;
m_pauseAfterInitialization = immediatelyPause;
Modified: trunk/Source/WebCore/inspector/InspectorController.h (224529 => 224530)
--- trunk/Source/WebCore/inspector/InspectorController.h 2017-11-07 04:09:59 UTC (rev 224529)
+++ trunk/Source/WebCore/inspector/InspectorController.h 2017-11-07 09:32:14 UTC (rev 224530)
@@ -66,6 +66,7 @@
class Node;
class Page;
class WebInjectedScriptManager;
+struct PageAgentContext;
class InspectorController final : public Inspector::InspectorEnvironment {
WTF_MAKE_NONCOPYABLE(InspectorController);
@@ -128,6 +129,9 @@
private:
friend class InspectorInstrumentation;
+ PageAgentContext pageAgentContext();
+ void createLazyAgents();
+
Ref<InstrumentingAgents> m_instrumentingAgents;
std::unique_ptr<WebInjectedScriptManager> m_injectedScriptManager;
Ref<Inspector::FrontendRouter> m_frontendRouter;
@@ -148,6 +152,7 @@
bool m_isUnderTest { false };
bool m_isAutomaticInspection { false };
bool m_pauseAfterInitialization = { false };
+ bool m_didCreateLazyAgents { false };
};
} // namespace WebCore