Title: [243160] trunk/Source
Revision
243160
Author
[email protected]
Date
2019-03-19 12:25:52 -0700 (Tue, 19 Mar 2019)

Log Message

Web Inspector: ScriptProfiler: lazily create the agent
https://bugs.webkit.org/show_bug.cgi?id=195591
<rdar://problem/48791756>

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

* inspector/JSGlobalObjectConsoleClient.h:
(Inspector::JSGlobalObjectConsoleClient::setInspectorScriptProfilerAgent): Added.
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient):
(Inspector::JSGlobalObjectConsoleClient::startConsoleProfile):
(Inspector::JSGlobalObjectConsoleClient::stopConsoleProfile):

* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::createLazyAgents):

Source/WebCore:

No change in functionality.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::createLazyAgents):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (243159 => 243160)


--- trunk/Source/_javascript_Core/ChangeLog	2019-03-19 19:19:21 UTC (rev 243159)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-03-19 19:25:52 UTC (rev 243160)
@@ -1,5 +1,24 @@
 2019-03-19  Devin Rousso  <[email protected]>
 
+        Web Inspector: ScriptProfiler: lazily create the agent
+        https://bugs.webkit.org/show_bug.cgi?id=195591
+        <rdar://problem/48791756>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/JSGlobalObjectConsoleClient.h:
+        (Inspector::JSGlobalObjectConsoleClient::setInspectorScriptProfilerAgent): Added.
+        * inspector/JSGlobalObjectConsoleClient.cpp:
+        (Inspector::JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient):
+        (Inspector::JSGlobalObjectConsoleClient::startConsoleProfile):
+        (Inspector::JSGlobalObjectConsoleClient::stopConsoleProfile):
+
+        * inspector/JSGlobalObjectInspectorController.cpp:
+        (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
+        (Inspector::JSGlobalObjectInspectorController::createLazyAgents):
+
+2019-03-19  Devin Rousso  <[email protected]>
+
         Web Inspector: Heap: lazily create the agent
         https://bugs.webkit.org/show_bug.cgi?id=195590
         <rdar://problem/48791750>

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp (243159 => 243160)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2019-03-19 19:19:21 UTC (rev 243159)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2019-03-19 19:25:52 UTC (rev 243160)
@@ -54,11 +54,10 @@
     sLogToSystemConsole = shouldLog;
 }
 
-JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient(InspectorConsoleAgent* consoleAgent, InspectorDebuggerAgent* debuggerAgent, InspectorScriptProfilerAgent* scriptProfilerAgent)
+JSGlobalObjectConsoleClient::JSGlobalObjectConsoleClient(InspectorConsoleAgent* consoleAgent, InspectorDebuggerAgent* debuggerAgent)
     : ConsoleClient()
     , m_consoleAgent(consoleAgent)
     , m_debuggerAgent(debuggerAgent)
-    , m_scriptProfilerAgent(scriptProfilerAgent)
 {
 }
 
@@ -121,27 +120,33 @@
 
 void JSGlobalObjectConsoleClient::startConsoleProfile()
 {
+    ErrorString unused;
+
     // FIXME: <https://webkit.org/b/158753> Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection
-    m_scriptProfilerAgent->programmaticCaptureStarted();
+    if (m_scriptProfilerAgent)
+        m_scriptProfilerAgent->programmaticCaptureStarted();
 
     m_profileRestoreBreakpointActiveValue = m_debuggerAgent->breakpointsActive();
-
-    ErrorString unused;
     m_debuggerAgent->setBreakpointsActive(unused, false);
 
-    const bool includeSamples = true;
-    m_scriptProfilerAgent->startTracking(unused, &includeSamples);
+    if (m_scriptProfilerAgent) {
+        const bool includeSamples = true;
+        m_scriptProfilerAgent->startTracking(unused, &includeSamples);
+    }
 }
 
 void JSGlobalObjectConsoleClient::stopConsoleProfile()
 {
     ErrorString unused;
-    m_scriptProfilerAgent->stopTracking(unused);
 
+    if (m_scriptProfilerAgent)
+        m_scriptProfilerAgent->stopTracking(unused);
+
     m_debuggerAgent->setBreakpointsActive(unused, m_profileRestoreBreakpointActiveValue);
 
     // FIXME: <https://webkit.org/b/158753> Generalize the concept of Instruments on the backend to work equally for JSContext and Web inspection
-    m_scriptProfilerAgent->programmaticCaptureStopped();
+    if (m_scriptProfilerAgent)
+        m_scriptProfilerAgent->programmaticCaptureStopped();
 }
 
 void JSGlobalObjectConsoleClient::takeHeapSnapshot(JSC::ExecState*, const String& title)

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h (243159 => 243160)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2019-03-19 19:19:21 UTC (rev 243159)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2019-03-19 19:25:52 UTC (rev 243160)
@@ -38,12 +38,14 @@
 class JSGlobalObjectConsoleClient final : public JSC::ConsoleClient {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit JSGlobalObjectConsoleClient(InspectorConsoleAgent*, InspectorDebuggerAgent*, InspectorScriptProfilerAgent*);
+    explicit JSGlobalObjectConsoleClient(InspectorConsoleAgent*, InspectorDebuggerAgent*);
     virtual ~JSGlobalObjectConsoleClient() { }
 
     static bool logToSystemConsole();
     static void setLogToSystemConsole(bool);
 
+    void setInspectorScriptProfilerAgent(InspectorScriptProfilerAgent* agent) { m_scriptProfilerAgent = agent; }
+
 protected:
     void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<ScriptArguments>&&) override;
     void count(JSC::ExecState*, Ref<ScriptArguments>&&) override;
@@ -66,7 +68,7 @@
 
     InspectorConsoleAgent* m_consoleAgent;
     InspectorDebuggerAgent* m_debuggerAgent;
-    InspectorScriptProfilerAgent* m_scriptProfilerAgent;
+    InspectorScriptProfilerAgent* m_scriptProfilerAgent { nullptr };
     Vector<String> m_profiles;
     bool m_profileRestoreBreakpointActiveValue { false };
 };

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp (243159 => 243160)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2019-03-19 19:19:21 UTC (rev 243159)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2019-03-19 19:25:52 UTC (rev 243160)
@@ -75,18 +75,16 @@
     auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(context);
     auto consoleAgent = std::make_unique<InspectorConsoleAgent>(context);
     auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, consoleAgent.get());
-    auto scriptProfilerAgent = std::make_unique<InspectorScriptProfilerAgent>(context);
 
     m_inspectorAgent = inspectorAgent.get();
     m_debuggerAgent = debuggerAgent.get();
     m_consoleAgent = consoleAgent.get();
-    m_consoleClient = std::make_unique<JSGlobalObjectConsoleClient>(m_consoleAgent, m_debuggerAgent, scriptProfilerAgent.get());
+    m_consoleClient = std::make_unique<JSGlobalObjectConsoleClient>(m_consoleAgent, m_debuggerAgent);
 
     m_agents.append(WTFMove(inspectorAgent));
     m_agents.append(WTFMove(runtimeAgent));
     m_agents.append(WTFMove(consoleAgent));
     m_agents.append(WTFMove(debuggerAgent));
-    m_agents.append(WTFMove(scriptProfilerAgent));
 
     m_executionStopwatch->start();
 }
@@ -312,6 +310,10 @@
 
     auto context = jsAgentContext();
 
+    auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(context);
+    m_consoleClient->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
+    m_agents.append(WTFMove(scriptProfilerAgentPtr));
+
     auto heapAgent = std::make_unique<InspectorHeapAgent>(context);
     if (m_consoleAgent)
         m_consoleAgent->setInspectorHeapAgent(heapAgent.get());

Modified: trunk/Source/WebCore/ChangeLog (243159 => 243160)


--- trunk/Source/WebCore/ChangeLog	2019-03-19 19:19:21 UTC (rev 243159)
+++ trunk/Source/WebCore/ChangeLog	2019-03-19 19:25:52 UTC (rev 243160)
@@ -1,5 +1,19 @@
 2019-03-19  Devin Rousso  <[email protected]>
 
+        Web Inspector: ScriptProfiler: lazily create the agent
+        https://bugs.webkit.org/show_bug.cgi?id=195591
+        <rdar://problem/48791756>
+
+        Reviewed by Joseph Pecoraro.
+
+        No change in functionality.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::createLazyAgents):
+
+2019-03-19  Devin Rousso  <[email protected]>
+
         Web Inspector: DOMStorage: lazily create the agent
         https://bugs.webkit.org/show_bug.cgi?id=195588
         <rdar://problem/48791878>

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (243159 => 243160)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2019-03-19 19:19:21 UTC (rev 243159)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2019-03-19 19:25:52 UTC (rev 243160)
@@ -127,10 +127,6 @@
     InspectorDatabaseAgent* databaseAgent = databaseAgentPtr.get();
     m_agents.append(WTFMove(databaseAgentPtr));
 
-    auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(pageContext);
-    m_instrumentingAgents->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
-    m_agents.append(WTFMove(scriptProfilerAgentPtr));
-
     auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, m_domAgent);
     WebConsoleAgent* consoleAgent = consoleAgentPtr.get();
     m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get());
@@ -192,6 +188,11 @@
 #if ENABLE(INDEXED_DATABASE)
     m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext, m_pageAgent));
 #endif
+
+    auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(pageContext);
+    m_instrumentingAgents->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
+    m_agents.append(WTFMove(scriptProfilerAgentPtr));
+
 #if ENABLE(RESOURCE_USAGE)
     m_agents.append(std::make_unique<InspectorCPUProfilerAgent>(pageContext));
     m_agents.append(std::make_unique<InspectorMemoryAgent>(pageContext));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to