Web Inspector: Put ScriptDebugServer into InspectorEnvironment and cleanup duplicate...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Nov 2015 19:22:42 +0000 (19:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Nov 2015 19:22:42 +0000 (19:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150869

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-11-05
Reviewed by Brian Burg.

Source/JavaScriptCore:

ScriptDebugServer (JSC::Debugger) is being used by more and more agents
for instrumentation into JavaScriptCore. Currently the ScriptDebugServer
is owned by DebuggerAgent subclasses that make their own ScriptDebugServer
subclass. As more agents want to use it there was added boilerplate.
Instead, put the ScriptDebugServer in the InspectorEnvironment (Controllers).
Then each agent can access it during construction through the environment.

Do the same clean up for RuntimeAgent::globalVM, which is now just a
duplication of InspectorEnvironment::vm.

* inspector/InspectorEnvironment.h:
Add scriptDebugServer().

* inspector/JSGlobalObjectInspectorController.h:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::scriptDebugServer):
Own the JSGlobalObjectScriptDebugServer.

* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::InspectorDebuggerAgent):
(Inspector::InspectorDebuggerAgent::enable):
(Inspector::InspectorDebuggerAgent::disable):
(Inspector::InspectorDebuggerAgent::setBreakpointsActive):
(Inspector::InspectorDebuggerAgent::isPaused):
(Inspector::InspectorDebuggerAgent::setSuppressAllPauses):
(Inspector::InspectorDebuggerAgent::handleConsoleAssert):
(Inspector::InspectorDebuggerAgent::removeBreakpoint):
(Inspector::InspectorDebuggerAgent::continueToLocation):
(Inspector::InspectorDebuggerAgent::resolveBreakpoint):
(Inspector::InspectorDebuggerAgent::schedulePauseOnNextStatement):
(Inspector::InspectorDebuggerAgent::cancelPauseOnNextStatement):
(Inspector::InspectorDebuggerAgent::resume):
(Inspector::InspectorDebuggerAgent::stepOver):
(Inspector::InspectorDebuggerAgent::stepInto):
(Inspector::InspectorDebuggerAgent::stepOut):
(Inspector::InspectorDebuggerAgent::setPauseOnExceptions):
(Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):
(Inspector::InspectorDebuggerAgent::scriptExecutionBlockedByCSP):
(Inspector::InspectorDebuggerAgent::didPause):
(Inspector::InspectorDebuggerAgent::breakProgram):
(Inspector::InspectorDebuggerAgent::clearDebuggerBreakpointState):
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::InspectorRuntimeAgent):
(Inspector::setPauseOnExceptionsState):
(Inspector::InspectorRuntimeAgent::parse):
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
(Inspector::InspectorRuntimeAgent::setTypeProfilerEnabledState):
(Inspector::InspectorRuntimeAgent::getBasicBlocks):
Use VM and ScriptDebugServer passed during construction.

* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
(Inspector::JSGlobalObjectDebuggerAgent::injectedScriptForEval):
(Inspector::JSGlobalObjectDebuggerAgent::JSGlobalObjectDebuggerAgent): Deleted.
One special case needed by this subclass as a convenience to access the global object.

* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
(Inspector::JSGlobalObjectRuntimeAgent::globalVM): Deleted.
This virtual method is no longer needed, the base class has everything now.

Source/WebCore:

Refactoring covered by existing tests.

* WebCore.xcodeproj/project.pbxproj:
Privately export PageScriptDebuggerAgent.h due to InspectorController.h needing it.

* inspector/InspectorController.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::scriptDebugServer):
Own the PageScriptDebugServer.

* inspector/WorkerInspectorController.h:
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::scriptDebugServer):
Own the WorkerScriptDebugServer.

(WebCore::WorkerInspectorController::vm):
Use the VM accessed through the worker global object.

* inspector/InspectorWebAgentBase.h:
(WebCore::InspectorAgentBase::InspectorAgentBase):
Given Web agents a m_environment convenience to access the InspectorEnvironment.

* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::timestamp):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::timestamp):
(WebCore::InspectorPageAgent::enable):
(WebCore::InspectorPageAgent::frameStartedLoading):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
(WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorTimelineAgent::internalStart):
(WebCore::InspectorTimelineAgent::internalStop):
(WebCore::InspectorTimelineAgent::timestamp):
(WebCore::InspectorTimelineAgent::startFromConsole):
(WebCore::InspectorTimelineAgent::willCallFunction):
(WebCore::InspectorTimelineAgent::willEvaluateScript):
(WebCore::InspectorTimelineAgent::setPageScriptDebugServer): Deleted.
* inspector/InspectorTimelineAgent.h:
Use the InspectorEnvironment for VM / ScriptDebugServer.

* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::PageDebuggerAgent): Deleted.
(WebCore::PageDebuggerAgent::scriptDebugServer): Deleted.
* inspector/PageDebuggerAgent.h:
* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::globalVM): Deleted.
* inspector/PageRuntimeAgent.h:
* inspector/WorkerDebuggerAgent.h:
* inspector/WorkerRuntimeAgent.cpp:
(WebCore::WorkerRuntimeAgent::globalVM): Deleted.
* inspector/WorkerRuntimeAgent.h:
* inspector/WorkerDebuggerAgent.cpp:
(WebCore::WorkerDebuggerAgent::WorkerDebuggerAgent): Deleted.
(WebCore::WorkerDebuggerAgent::scriptDebugServer): Deleted.
Remove now unnecessary subclass code.

(WebCore::WorkerDebuggerAgent::interruptAndDispatchInspectorCommands):
One more special case for accessing Worker properties from the ScriptDebugServer.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192061 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InspectorEnvironment.h
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h
Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp
Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.h
Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.cpp
Source/JavaScriptCore/inspector/agents/JSGlobalObjectRuntimeAgent.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/InspectorWebAgentBase.h
Source/WebCore/inspector/PageDebuggerAgent.cpp
Source/WebCore/inspector/PageDebuggerAgent.h
Source/WebCore/inspector/PageRuntimeAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.h
Source/WebCore/inspector/WorkerDebuggerAgent.cpp
Source/WebCore/inspector/WorkerDebuggerAgent.h
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/inspector/WorkerInspectorController.h
Source/WebCore/inspector/WorkerRuntimeAgent.cpp
Source/WebCore/inspector/WorkerRuntimeAgent.h

index 4f222ca..c049098 100644 (file)
@@ -1,3 +1,74 @@
+2015-11-05  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Put ScriptDebugServer into InspectorEnvironment and cleanup duplicate references
+        https://bugs.webkit.org/show_bug.cgi?id=150869
+
+        Reviewed by Brian Burg.
+
+        ScriptDebugServer (JSC::Debugger) is being used by more and more agents
+        for instrumentation into JavaScriptCore. Currently the ScriptDebugServer
+        is owned by DebuggerAgent subclasses that make their own ScriptDebugServer
+        subclass. As more agents want to use it there was added boilerplate.
+        Instead, put the ScriptDebugServer in the InspectorEnvironment (Controllers).
+        Then each agent can access it during construction through the environment.
+
+        Do the same clean up for RuntimeAgent::globalVM, which is now just a
+        duplication of InspectorEnvironment::vm.
+
+        * inspector/InspectorEnvironment.h:
+        Add scriptDebugServer().
+
+        * inspector/JSGlobalObjectInspectorController.h:
+        * inspector/JSGlobalObjectInspectorController.cpp:
+        (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
+        (Inspector::JSGlobalObjectInspectorController::scriptDebugServer):
+        Own the JSGlobalObjectScriptDebugServer.
+
+        * inspector/agents/InspectorDebuggerAgent.h:
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::InspectorDebuggerAgent):
+        (Inspector::InspectorDebuggerAgent::enable):
+        (Inspector::InspectorDebuggerAgent::disable):
+        (Inspector::InspectorDebuggerAgent::setBreakpointsActive):
+        (Inspector::InspectorDebuggerAgent::isPaused):
+        (Inspector::InspectorDebuggerAgent::setSuppressAllPauses):
+        (Inspector::InspectorDebuggerAgent::handleConsoleAssert):
+        (Inspector::InspectorDebuggerAgent::removeBreakpoint):
+        (Inspector::InspectorDebuggerAgent::continueToLocation):
+        (Inspector::InspectorDebuggerAgent::resolveBreakpoint):
+        (Inspector::InspectorDebuggerAgent::schedulePauseOnNextStatement):
+        (Inspector::InspectorDebuggerAgent::cancelPauseOnNextStatement):
+        (Inspector::InspectorDebuggerAgent::resume):
+        (Inspector::InspectorDebuggerAgent::stepOver):
+        (Inspector::InspectorDebuggerAgent::stepInto):
+        (Inspector::InspectorDebuggerAgent::stepOut):
+        (Inspector::InspectorDebuggerAgent::setPauseOnExceptions):
+        (Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):
+        (Inspector::InspectorDebuggerAgent::scriptExecutionBlockedByCSP):
+        (Inspector::InspectorDebuggerAgent::didPause):
+        (Inspector::InspectorDebuggerAgent::breakProgram):
+        (Inspector::InspectorDebuggerAgent::clearDebuggerBreakpointState):
+        * inspector/agents/InspectorRuntimeAgent.h:
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::InspectorRuntimeAgent):
+        (Inspector::setPauseOnExceptionsState):
+        (Inspector::InspectorRuntimeAgent::parse):
+        (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
+        (Inspector::InspectorRuntimeAgent::setTypeProfilerEnabledState):
+        (Inspector::InspectorRuntimeAgent::getBasicBlocks):
+        Use VM and ScriptDebugServer passed during construction.
+
+        * inspector/agents/JSGlobalObjectDebuggerAgent.h:
+        * inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
+        (Inspector::JSGlobalObjectDebuggerAgent::injectedScriptForEval):
+        (Inspector::JSGlobalObjectDebuggerAgent::JSGlobalObjectDebuggerAgent): Deleted.
+        One special case needed by this subclass as a convenience to access the global object.
+
+        * inspector/agents/JSGlobalObjectRuntimeAgent.h:
+        * inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
+        (Inspector::JSGlobalObjectRuntimeAgent::globalVM): Deleted.
+        This virtual method is no longer needed, the base class has everything now.
+
 2015-11-05  Xabier Rodriguez Calvar  <calvaris@igalia.com>
 
         [Streams API] Shield implementation from user mangling Promise.reject and resolve methods
index 75f2ea4..b3d6948 100644 (file)
@@ -40,6 +40,7 @@ class VM;
 
 namespace Inspector {
 
+class ScriptDebugServer;
 typedef JSC::JSValue (*InspectorFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException);
 typedef JSC::JSValue (*InspectorEvaluateHandler)(JSC::ExecState*, const JSC::SourceCode&, JSC::JSValue thisValue, NakedPtr<JSC::Exception>& returnedException);
 
@@ -54,6 +55,7 @@ public:
     virtual void didCallInjectedScriptFunction(JSC::ExecState*) = 0;
     virtual void frontendInitialized() = 0;
     virtual Ref<WTF::Stopwatch> executionStopwatch() = 0;
+    virtual ScriptDebugServer& scriptDebugServer() = 0;
     virtual JSC::VM& vm() = 0;
 };
 
index 4216043..4f984ee 100644 (file)
@@ -66,6 +66,7 @@ JSGlobalObjectInspectorController::JSGlobalObjectInspectorController(JSGlobalObj
     : m_globalObject(globalObject)
     , m_injectedScriptManager(std::make_unique<InjectedScriptManager>(*this, InjectedScriptHost::create()))
     , m_executionStopwatch(Stopwatch::create())
+    , m_scriptDebugServer(globalObject)
     , m_frontendRouter(FrontendRouter::create())
     , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))
 {
@@ -85,21 +86,17 @@ JSGlobalObjectInspectorController::JSGlobalObjectInspectorController(JSGlobalObj
     auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(context);
     auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(context);
     auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, consoleAgent.get());
-    auto heapAgent = std::make_unique<InspectorHeapAgent>(context);
 
     m_inspectorAgent = inspectorAgent.get();
     m_debuggerAgent = debuggerAgent.get();
-    m_heapAgent = heapAgent.get();
     m_consoleAgent = consoleAgent.get();
     m_consoleClient = std::make_unique<JSGlobalObjectConsoleClient>(m_consoleAgent);
 
-    runtimeAgent->setScriptDebugServer(&debuggerAgent->scriptDebugServer());
-
     m_agents.append(WTF::move(inspectorAgent));
     m_agents.append(WTF::move(runtimeAgent));
     m_agents.append(WTF::move(consoleAgent));
     m_agents.append(WTF::move(debuggerAgent));
-    m_agents.append(WTF::move(heapAgent));
+    m_agents.append(std::make_unique<InspectorHeapAgent>(context));
 
     m_executionStopwatch->start();
 }
@@ -285,6 +282,11 @@ Ref<Stopwatch> JSGlobalObjectInspectorController::executionStopwatch()
     return m_executionStopwatch.copyRef();
 }
 
+JSGlobalObjectScriptDebugServer& JSGlobalObjectInspectorController::scriptDebugServer()
+{
+    return m_scriptDebugServer;
+}
+
 VM& JSGlobalObjectInspectorController::vm()
 {
     return m_globalObject.vm();
index f66ebe3..5b09b7d 100644 (file)
@@ -29,6 +29,7 @@
 #include "InspectorAgentRegistry.h"
 #include "InspectorEnvironment.h"
 #include "InspectorFrontendRouter.h"
+#include "JSGlobalObjectScriptDebugServer.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/text/WTFString.h>
 #include "AugmentableInspectorController.h"
 #endif
 
-namespace WTF {
-class Stopwatch;
-}
-
 namespace JSC {
 class ConsoleClient;
 class Exception;
@@ -97,6 +94,7 @@ public:
     virtual void didCallInjectedScriptFunction(JSC::ExecState*) override { }
     virtual void frontendInitialized() override;
     virtual Ref<WTF::Stopwatch> executionStopwatch() override;
+    virtual JSGlobalObjectScriptDebugServer& scriptDebugServer() override;
     virtual JSC::VM& vm() override;
 
 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
@@ -115,12 +113,12 @@ private:
     std::unique_ptr<InjectedScriptManager> m_injectedScriptManager;
     std::unique_ptr<JSGlobalObjectConsoleClient> m_consoleClient;
     Ref<WTF::Stopwatch> m_executionStopwatch;
+    JSGlobalObjectScriptDebugServer m_scriptDebugServer;
 
     AgentRegistry m_agents;
     InspectorAgent* m_inspectorAgent { nullptr };
     InspectorConsoleAgent* m_consoleAgent { nullptr };
     InspectorDebuggerAgent* m_debuggerAgent { nullptr };
-    InspectorHeapAgent* m_heapAgent { nullptr };
 
     Ref<FrontendRouter> m_frontendRouter;
     Ref<BackendDispatcher> m_backendDispatcher;
index 1c09152..aafdc58 100644 (file)
@@ -61,6 +61,7 @@ InspectorDebuggerAgent::InspectorDebuggerAgent(AgentContext& context)
     , m_injectedScriptManager(context.injectedScriptManager)
     , m_frontendDispatcher(std::make_unique<DebuggerFrontendDispatcher>(context.frontendRouter))
     , m_backendDispatcher(DebuggerBackendDispatcher::create(context.backendDispatcher, this))
+    , m_scriptDebugServer(context.environment.scriptDebugServer())
     , m_continueToLocationBreakpointID(JSC::noBreakpointID)
 {
     // FIXME: make breakReason optional so that there was no need to init it with "other".
@@ -86,8 +87,8 @@ void InspectorDebuggerAgent::enable()
     if (m_enabled)
         return;
 
-    scriptDebugServer().setBreakpointsActivated(true);
-    scriptDebugServer().addListener(this);
+    m_scriptDebugServer.setBreakpointsActivated(true);
+    m_scriptDebugServer.addListener(this);
 
     if (m_listener)
         m_listener->debuggerWasEnabled();
@@ -100,7 +101,7 @@ void InspectorDebuggerAgent::disable(bool isBeingDestroyed)
     if (!m_enabled)
         return;
 
-    scriptDebugServer().removeListener(this, isBeingDestroyed);
+    m_scriptDebugServer.removeListener(this, isBeingDestroyed);
     clearInspectorBreakpointState();
 
     ASSERT(m_javaScriptBreakpoints.isEmpty());
@@ -124,19 +125,19 @@ void InspectorDebuggerAgent::disable(ErrorString&)
 void InspectorDebuggerAgent::setBreakpointsActive(ErrorString&, bool active)
 {
     if (active)
-        scriptDebugServer().activateBreakpoints();
+        m_scriptDebugServer.activateBreakpoints();
     else
-        scriptDebugServer().deactivateBreakpoints();
+        m_scriptDebugServer.deactivateBreakpoints();
 }
 
 bool InspectorDebuggerAgent::isPaused()
 {
-    return scriptDebugServer().isPaused();
+    return m_scriptDebugServer.isPaused();
 }
 
 void InspectorDebuggerAgent::setSuppressAllPauses(bool suppress)
 {
-    scriptDebugServer().setSuppressAllPauses(suppress);
+    m_scriptDebugServer.setSuppressAllPauses(suppress);
 }
 
 static RefPtr<InspectorObject> buildAssertPauseReason(const String& message)
@@ -183,7 +184,7 @@ RefPtr<InspectorObject> InspectorDebuggerAgent::buildExceptionPauseReason(const
 
 void InspectorDebuggerAgent::handleConsoleAssert(const String& message)
 {
-    if (scriptDebugServer().pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions)
+    if (m_scriptDebugServer.pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions)
         breakProgram(DebuggerFrontendDispatcher::Reason::Assert, buildAssertPauseReason(message));
 }
 
@@ -388,18 +389,18 @@ void InspectorDebuggerAgent::removeBreakpoint(ErrorString&, const String& breakp
     for (JSC::BreakpointID breakpointID : m_breakpointIdentifierToDebugServerBreakpointIDs.take(breakpointIdentifier)) {
         m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier.remove(breakpointID);
 
-        const BreakpointActions& breakpointActions = scriptDebugServer().getActionsForBreakpoint(breakpointID);
+        const BreakpointActions& breakpointActions = m_scriptDebugServer.getActionsForBreakpoint(breakpointID);
         for (auto& action : breakpointActions)
             m_injectedScriptManager.releaseObjectGroup(objectGroupForBreakpointAction(action));
 
-        scriptDebugServer().removeBreakpoint(breakpointID);
+        m_scriptDebugServer.removeBreakpoint(breakpointID);
     }
 }
 
 void InspectorDebuggerAgent::continueToLocation(ErrorString& errorString, const InspectorObject& location)
 {
     if (m_continueToLocationBreakpointID != JSC::noBreakpointID) {
-        scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointID);
+        m_scriptDebugServer.removeBreakpoint(m_continueToLocationBreakpointID);
         m_continueToLocationBreakpointID = JSC::noBreakpointID;
     }
 
@@ -410,7 +411,7 @@ void InspectorDebuggerAgent::continueToLocation(ErrorString& errorString, const
         return;
 
     ScriptBreakpoint breakpoint(lineNumber, columnNumber, "", false, 0);
-    m_continueToLocationBreakpointID = scriptDebugServer().setBreakpoint(sourceID, breakpoint, &lineNumber, &columnNumber);
+    m_continueToLocationBreakpointID = m_scriptDebugServer.setBreakpoint(sourceID, breakpoint, &lineNumber, &columnNumber);
     resume(errorString);
 }
 
@@ -425,7 +426,7 @@ RefPtr<Inspector::Protocol::Debugger::Location> InspectorDebuggerAgent::resolveB
 
     unsigned actualLineNumber;
     unsigned actualColumnNumber;
-    JSC::BreakpointID debugServerBreakpointID = scriptDebugServer().setBreakpoint(sourceID, breakpoint, &actualLineNumber, &actualColumnNumber);
+    JSC::BreakpointID debugServerBreakpointID = m_scriptDebugServer.setBreakpoint(sourceID, breakpoint, &actualLineNumber, &actualColumnNumber);
     if (debugServerBreakpointID == JSC::noBreakpointID)
         return nullptr;
 
@@ -486,7 +487,7 @@ void InspectorDebuggerAgent::schedulePauseOnNextStatement(DebuggerFrontendDispat
 
     m_breakReason = breakReason;
     m_breakAuxData = WTF::move(data);
-    scriptDebugServer().setPauseOnNextStatement(true);
+    m_scriptDebugServer.setPauseOnNextStatement(true);
 }
 
 void InspectorDebuggerAgent::cancelPauseOnNextStatement()
@@ -495,7 +496,7 @@ void InspectorDebuggerAgent::cancelPauseOnNextStatement()
         return;
 
     clearBreakDetails();
-    scriptDebugServer().setPauseOnNextStatement(false);
+    m_scriptDebugServer.setPauseOnNextStatement(false);
 }
 
 void InspectorDebuggerAgent::pause(ErrorString&)
@@ -510,7 +511,7 @@ void InspectorDebuggerAgent::resume(ErrorString& errorString)
     if (!assertPaused(errorString))
         return;
 
-    scriptDebugServer().continueProgram();
+    m_scriptDebugServer.continueProgram();
 }
 
 void InspectorDebuggerAgent::stepOver(ErrorString& errorString)
@@ -518,7 +519,7 @@ void InspectorDebuggerAgent::stepOver(ErrorString& errorString)
     if (!assertPaused(errorString))
         return;
 
-    scriptDebugServer().stepOverStatement();
+    m_scriptDebugServer.stepOverStatement();
 }
 
 void InspectorDebuggerAgent::stepInto(ErrorString& errorString)
@@ -526,7 +527,7 @@ void InspectorDebuggerAgent::stepInto(ErrorString& errorString)
     if (!assertPaused(errorString))
         return;
 
-    scriptDebugServer().stepIntoStatement();
+    m_scriptDebugServer.stepIntoStatement();
 
     if (m_listener)
         m_listener->stepInto();
@@ -537,7 +538,7 @@ void InspectorDebuggerAgent::stepOut(ErrorString& errorString)
     if (!assertPaused(errorString))
         return;
 
-    scriptDebugServer().stepOutOfFunction();
+    m_scriptDebugServer.stepOutOfFunction();
 }
 
 void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString& errorString, const String& stringPauseState)
@@ -554,8 +555,8 @@ void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString& errorString, cons
         return;
     }
 
-    scriptDebugServer().setPauseOnExceptionsState(static_cast<JSC::Debugger::PauseOnExceptionsState>(pauseState));
-    if (scriptDebugServer().pauseOnExceptionsState() != pauseState)
+    m_scriptDebugServer.setPauseOnExceptionsState(static_cast<JSC::Debugger::PauseOnExceptionsState>(pauseState));
+    if (m_scriptDebugServer.pauseOnExceptionsState() != pauseState)
         errorString = ASCIILiteral("Internal error. Could not change pause on exceptions state");
 }
 
@@ -567,10 +568,10 @@ void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const
         return;
     }
 
-    JSC::Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = scriptDebugServer().pauseOnExceptionsState();
+    JSC::Debugger::PauseOnExceptionsState previousPauseOnExceptionsState = m_scriptDebugServer.pauseOnExceptionsState();
     if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) {
         if (previousPauseOnExceptionsState != JSC::Debugger::DontPauseOnExceptions)
-            scriptDebugServer().setPauseOnExceptionsState(JSC::Debugger::DontPauseOnExceptions);
+            m_scriptDebugServer.setPauseOnExceptionsState(JSC::Debugger::DontPauseOnExceptions);
         muteConsole();
     }
 
@@ -578,8 +579,8 @@ void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const
 
     if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteConsole : false) {
         unmuteConsole();
-        if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExceptionsState)
-            scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExceptionsState);
+        if (m_scriptDebugServer.pauseOnExceptionsState() != previousPauseOnExceptionsState)
+            m_scriptDebugServer.setPauseOnExceptionsState(previousPauseOnExceptionsState);
     }
 }
 
@@ -589,7 +590,7 @@ void InspectorDebuggerAgent::setOverlayMessage(ErrorString&, const String*)
 
 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText)
 {
-    if (scriptDebugServer().pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions)
+    if (m_scriptDebugServer.pauseOnExceptionsState() != JSC::Debugger::DontPauseOnExceptions)
         breakProgram(DebuggerFrontendDispatcher::Reason::CSPViolation, buildCSPViolationPauseReason(directiveText));
 }
 
@@ -670,9 +671,9 @@ void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const Depreca
 
     // If a high level pause pause reason is not already set, try to infer a reason from the debugger.
     if (m_breakReason == DebuggerFrontendDispatcher::Reason::Other) {
-        switch (scriptDebugServer().reasonForPause()) {
+        switch (m_scriptDebugServer.reasonForPause()) {
         case JSC::Debugger::PausedForBreakpoint: {
-            JSC::BreakpointID debuggerBreakpointId = scriptDebugServer().pausingBreakpointID();
+            JSC::BreakpointID debuggerBreakpointId = m_scriptDebugServer.pausingBreakpointID();
             if (debuggerBreakpointId != m_continueToLocationBreakpointID) {
                 m_breakReason = DebuggerFrontendDispatcher::Reason::Breakpoint;
                 m_breakAuxData = buildBreakpointPauseReason(debuggerBreakpointId);
@@ -710,7 +711,7 @@ void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const Depreca
     m_javaScriptPauseScheduled = false;
 
     if (m_continueToLocationBreakpointID != JSC::noBreakpointID) {
-        scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointID);
+        m_scriptDebugServer.removeBreakpoint(m_continueToLocationBreakpointID);
         m_continueToLocationBreakpointID = JSC::noBreakpointID;
     }
 
@@ -764,7 +765,7 @@ void InspectorDebuggerAgent::breakProgram(DebuggerFrontendDispatcher::Reason bre
 {
     m_breakReason = breakReason;
     m_breakAuxData = WTF::move(data);
-    scriptDebugServer().breakProgram();
+    m_scriptDebugServer.breakProgram();
 }
 
 void InspectorDebuggerAgent::clearInspectorBreakpointState()
@@ -782,7 +783,7 @@ void InspectorDebuggerAgent::clearInspectorBreakpointState()
 
 void InspectorDebuggerAgent::clearDebuggerBreakpointState()
 {
-    scriptDebugServer().clearBreakpoints();
+    m_scriptDebugServer.clearBreakpoints();
 
     m_pausedScriptState = nullptr;
     m_currentCallStack = Deprecated::ScriptValue();
@@ -794,7 +795,7 @@ void InspectorDebuggerAgent::clearDebuggerBreakpointState()
     m_javaScriptPauseScheduled = false;
     m_hasExceptionValue = false;
 
-    scriptDebugServer().continueProgram();
+    m_scriptDebugServer.continueProgram();
 }
 
 void InspectorDebuggerAgent::didClearGlobalObject()
index 1b86c37..2064963 100644 (file)
 #include <wtf/Vector.h>
 #include <wtf/text/StringHash.h>
 
-namespace WTF {
-class Stopwatch;
-}
-
 namespace Inspector {
 
 class InjectedScript;
@@ -108,14 +104,14 @@ public:
     };
     void setListener(Listener* listener) { m_listener = listener; }
 
-    virtual ScriptDebugServer& scriptDebugServer() = 0;
-
 protected:
     InspectorDebuggerAgent(AgentContext&);
 
     InjectedScriptManager& injectedScriptManager() const { return m_injectedScriptManager; }
     virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0;
 
+    ScriptDebugServer& scriptDebugServer() { return m_scriptDebugServer; }
+
     virtual void muteConsole() = 0;
     virtual void unmuteConsole() = 0;
 
@@ -157,6 +153,7 @@ private:
     InjectedScriptManager& m_injectedScriptManager;
     std::unique_ptr<DebuggerFrontendDispatcher> m_frontendDispatcher;
     RefPtr<DebuggerBackendDispatcher> m_backendDispatcher;
+    ScriptDebugServer& m_scriptDebugServer;
     Listener* m_listener { nullptr };
     JSC::ExecState* m_pausedScriptState { nullptr };
     Deprecated::ScriptValue m_currentCallStack;
index f15d58d..391a5ba 100644 (file)
@@ -60,6 +60,8 @@ static bool asBool(const bool* const b)
 InspectorRuntimeAgent::InspectorRuntimeAgent(AgentContext& context)
     : InspectorAgentBase(ASCIILiteral("Runtime"))
     , m_injectedScriptManager(context.injectedScriptManager)
+    , m_scriptDebugServer(context.environment.scriptDebugServer())
+    , m_vm(context.environment.vm())
 {
 }
 
@@ -67,12 +69,11 @@ InspectorRuntimeAgent::~InspectorRuntimeAgent()
 {
 }
 
-static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(ScriptDebugServer* scriptDebugServer, ScriptDebugServer::PauseOnExceptionsState newState)
+static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(ScriptDebugServer& scriptDebugServer, ScriptDebugServer::PauseOnExceptionsState newState)
 {
-    ASSERT(scriptDebugServer);
-    ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer->pauseOnExceptionsState();
+    ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer.pauseOnExceptionsState();
     if (presentState != newState)
-        scriptDebugServer->setPauseOnExceptionsState(newState);
+        scriptDebugServer.setPauseOnExceptionsState(newState);
     return presentState;
 }
 
@@ -86,11 +87,10 @@ static Ref<Inspector::Protocol::Runtime::ErrorRange> buildErrorRangeObject(const
 
 void InspectorRuntimeAgent::parse(ErrorString&, const String& expression, Inspector::Protocol::Runtime::SyntaxErrorType* result, Inspector::Protocol::OptOutput<String>* message, RefPtr<Inspector::Protocol::Runtime::ErrorRange>& range)
 {
-    VM& vm = globalVM();
-    JSLockHolder lock(vm);
+    JSLockHolder lock(m_vm);
 
     ParserError error;
-    checkSyntax(vm, JSC::makeSource(expression), error);
+    checkSyntax(m_vm, JSC::makeSource(expression), error);
 
     switch (error.syntaxErrorType()) {
     case ParserError::SyntaxErrorNone:
@@ -249,15 +249,15 @@ void InspectorRuntimeAgent::run(ErrorString&)
 void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString& errorString, const Inspector::InspectorArray& locations, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>>& typeDescriptions)
 {
     static const bool verbose = false;
-    VM& vm = globalVM();
+
     typeDescriptions = Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>::create();
-    if (!vm.typeProfiler()) {
+    if (!m_vm.typeProfiler()) {
         errorString = ASCIILiteral("The VM does not currently have Type Information.");
         return;
     }
 
     double start = currentTimeMS();
-    vm.typeProfilerLog()->processLogEntries(ASCIILiteral("User Query"));
+    m_vm.typeProfilerLog()->processLogEntries(ASCIILiteral("User Query"));
 
     for (size_t i = 0; i < locations.length(); i++) {
         RefPtr<Inspector::InspectorValue> value = locations.get(i);
@@ -275,7 +275,7 @@ void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString& er
         location->getInteger(ASCIILiteral("divot"), divot);
 
         bool okay;
-        TypeLocation* typeLocation = vm.typeProfiler()->findLocation(divot, sourceIDAsString.toIntPtrStrict(&okay), static_cast<TypeProfilerSearchDescriptor>(descriptor), vm);
+        TypeLocation* typeLocation = m_vm.typeProfiler()->findLocation(divot, sourceIDAsString.toIntPtrStrict(&okay), static_cast<TypeProfilerSearchDescriptor>(descriptor), m_vm);
         ASSERT(okay);
 
         RefPtr<TypeSet> typeSet;
@@ -328,7 +328,7 @@ void InspectorRuntimeAgent::setTypeProfilerEnabledState(bool isTypeProfilingEnab
         return;
     m_isTypeProfilingEnabled = isTypeProfilingEnabled;
 
-    VM& vm = globalVM();
+    VM& vm = m_vm;
     vm.whenIdle([&vm, isTypeProfilingEnabled] () {
         bool shouldRecompileFromTypeProfiler = (isTypeProfilingEnabled ? vm.enableTypeProfiler() : vm.disableTypeProfiler());
         bool shouldRecompileFromControlFlowProfiler = (isTypeProfilingEnabled ? vm.enableControlFlowProfiler() : vm.disableControlFlowProfiler());
@@ -341,8 +341,7 @@ void InspectorRuntimeAgent::setTypeProfilerEnabledState(bool isTypeProfilingEnab
 
 void InspectorRuntimeAgent::getBasicBlocks(ErrorString& errorString, const String& sourceIDAsString, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::BasicBlock>>& basicBlocks)
 {
-    VM& vm = globalVM();
-    if (!vm.controlFlowProfiler()) {
+    if (!m_vm.controlFlowProfiler()) {
         errorString = ASCIILiteral("The VM does not currently have a Control Flow Profiler.");
         return;
     }
@@ -350,7 +349,7 @@ void InspectorRuntimeAgent::getBasicBlocks(ErrorString& errorString, const Strin
     bool okay;
     intptr_t sourceID = sourceIDAsString.toIntPtrStrict(&okay);
     ASSERT(okay);
-    const Vector<BasicBlockRange>& basicBlockRanges = vm.controlFlowProfiler()->getBasicBlocksForSourceID(sourceID, vm);
+    const Vector<BasicBlockRange>& basicBlockRanges = m_vm.controlFlowProfiler()->getBasicBlocksForSourceID(sourceID, m_vm);
     basicBlocks = Inspector::Protocol::Array<Inspector::Protocol::Runtime::BasicBlock>::create();
     for (const BasicBlockRange& block : basicBlockRanges) {
         Ref<Inspector::Protocol::Runtime::BasicBlock> location = Inspector::Protocol::Runtime::BasicBlock::create()
index 770e407..0e50b5a 100644 (file)
@@ -73,8 +73,6 @@ public:
     virtual void enableTypeProfiler(ErrorString&) override;
     virtual void disableTypeProfiler(ErrorString&) override;
     virtual void getBasicBlocks(ErrorString&, const String& in_sourceID, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::BasicBlock>>& out_basicBlocks) override;
-    
-    void setScriptDebugServer(ScriptDebugServer* scriptDebugServer) { m_scriptDebugServer = scriptDebugServer; }
 
     bool enabled() const { return m_enabled; }
 
@@ -83,7 +81,6 @@ protected:
 
     InjectedScriptManager& injectedScriptManager() { return m_injectedScriptManager; }
 
-    virtual JSC::VM& globalVM() = 0;
     virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0;
 
     virtual void muteConsole() = 0;
@@ -93,9 +90,10 @@ private:
     void setTypeProfilerEnabledState(bool);
 
     InjectedScriptManager& m_injectedScriptManager;
-    ScriptDebugServer* m_scriptDebugServer { nullptr };
-    bool m_enabled { false };
-    bool m_isTypeProfilingEnabled { false };
+    ScriptDebugServer& m_scriptDebugServer;
+    JSC::VM& m_vm;
+    bool m_enabled {false};
+    bool m_isTypeProfilingEnabled {false};
 };
 
 } // namespace Inspector
index 6c14cfc..e508b87 100644 (file)
@@ -40,7 +40,6 @@ namespace Inspector {
 
 JSGlobalObjectDebuggerAgent::JSGlobalObjectDebuggerAgent(JSAgentContext& context, InspectorConsoleAgent* consoleAgent)
     : InspectorDebuggerAgent(context)
-    , m_scriptDebugServer(context.inspectedGlobalObject)
     , m_consoleAgent(consoleAgent)
 {
 }
@@ -52,7 +51,7 @@ InjectedScript JSGlobalObjectDebuggerAgent::injectedScriptForEval(ErrorString& e
         return InjectedScript();
     }
 
-    ExecState* exec = m_scriptDebugServer.globalObject().globalExec();
+    ExecState* exec = static_cast<JSGlobalObjectScriptDebugServer&>(scriptDebugServer()).globalObject().globalExec();
     return injectedScriptManager().injectedScriptFor(exec);
 }
 
index f105e95..450ecf2 100644 (file)
@@ -40,8 +40,6 @@ public:
     JSGlobalObjectDebuggerAgent(JSAgentContext&, InspectorConsoleAgent*);
     virtual ~JSGlobalObjectDebuggerAgent() { }
 
-    virtual JSGlobalObjectScriptDebugServer& scriptDebugServer() override { return m_scriptDebugServer; }
-
     virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
 
     virtual void breakpointActionLog(JSC::ExecState*, const String&) override;
@@ -52,7 +50,6 @@ public:
     virtual void unmuteConsole() override { }
 
 private:
-    JSGlobalObjectScriptDebugServer m_scriptDebugServer;
     InspectorConsoleAgent* m_consoleAgent { nullptr };
 };
 
index 23d31e2..b748eeb 100644 (file)
@@ -46,11 +46,6 @@ void JSGlobalObjectRuntimeAgent::didCreateFrontendAndBackend(FrontendRouter*, Ba
 {
 }
 
-VM& JSGlobalObjectRuntimeAgent::globalVM()
-{
-    return m_globalObject.vm();
-}
-
 InjectedScript JSGlobalObjectRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
 {
     ASSERT_UNUSED(executionContextId, !executionContextId);
index deb8e8c..dfa5ab1 100644 (file)
@@ -40,7 +40,6 @@ public:
 
     virtual void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override;
 
-    virtual JSC::VM& globalVM() override;
     virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
 
     // NOTE: JavaScript inspector does not yet need to mute a console because no messages
index c5b63dc..ccbad3f 100644 (file)
@@ -1,3 +1,72 @@
+2015-11-05  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Put ScriptDebugServer into InspectorEnvironment and cleanup duplicate references
+        https://bugs.webkit.org/show_bug.cgi?id=150869
+
+        Reviewed by Brian Burg.
+
+        Refactoring covered by existing tests.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Privately export PageScriptDebuggerAgent.h due to InspectorController.h needing it.
+
+        * inspector/InspectorController.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::scriptDebugServer):
+        Own the PageScriptDebugServer.
+
+        * inspector/WorkerInspectorController.h:
+        * inspector/WorkerInspectorController.cpp:
+        (WebCore::WorkerInspectorController::WorkerInspectorController):
+        (WebCore::WorkerInspectorController::scriptDebugServer):
+        Own the WorkerScriptDebugServer.
+
+        (WebCore::WorkerInspectorController::vm):
+        Use the VM accessed through the worker global object.
+
+        * inspector/InspectorWebAgentBase.h:
+        (WebCore::InspectorAgentBase::InspectorAgentBase):
+        Given Web agents a m_environment convenience to access the InspectorEnvironment.
+
+        * inspector/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::timestamp):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::timestamp):
+        (WebCore::InspectorPageAgent::enable):
+        (WebCore::InspectorPageAgent::frameStartedLoading):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorTimelineAgent::internalStart):
+        (WebCore::InspectorTimelineAgent::internalStop):
+        (WebCore::InspectorTimelineAgent::timestamp):
+        (WebCore::InspectorTimelineAgent::startFromConsole):
+        (WebCore::InspectorTimelineAgent::willCallFunction):
+        (WebCore::InspectorTimelineAgent::willEvaluateScript):
+        (WebCore::InspectorTimelineAgent::setPageScriptDebugServer): Deleted.
+        * inspector/InspectorTimelineAgent.h:
+        Use the InspectorEnvironment for VM / ScriptDebugServer.
+
+        * inspector/PageDebuggerAgent.cpp:
+        (WebCore::PageDebuggerAgent::PageDebuggerAgent): Deleted.
+        (WebCore::PageDebuggerAgent::scriptDebugServer): Deleted.
+        * inspector/PageDebuggerAgent.h:
+        * inspector/PageRuntimeAgent.cpp:
+        (WebCore::PageRuntimeAgent::globalVM): Deleted.
+        * inspector/PageRuntimeAgent.h:
+        * inspector/WorkerDebuggerAgent.h:
+        * inspector/WorkerRuntimeAgent.cpp:
+        (WebCore::WorkerRuntimeAgent::globalVM): Deleted.
+        * inspector/WorkerRuntimeAgent.h:
+        * inspector/WorkerDebuggerAgent.cpp:
+        (WebCore::WorkerDebuggerAgent::WorkerDebuggerAgent): Deleted.
+        (WebCore::WorkerDebuggerAgent::scriptDebugServer): Deleted.
+        Remove now unnecessary subclass code.
+
+        (WebCore::WorkerDebuggerAgent::interruptAndDispatchInspectorCommands):
+        One more special case for accessing Worker properties from the ScriptDebugServer.
+
 2015-11-05  Xabier Rodriguez Calvar  <calvaris@igalia.com>
 
         [Streams API] Shield implementation from user mangling Promise.reject and resolve methods
index 12e5c3f..706f267 100644 (file)
                A5E616731894581F009ADF50 /* WebDebuggerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5E616711894581F009ADF50 /* WebDebuggerAgent.cpp */; };
                A5E616741894581F009ADF50 /* WebDebuggerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A5E616721894581F009ADF50 /* WebDebuggerAgent.h */; };
                A5F36D3A18F758720054C024 /* PageScriptDebugServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5F36D3818F758720054C024 /* PageScriptDebugServer.cpp */; };
-               A5F36D3B18F758720054C024 /* PageScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = A5F36D3918F758720054C024 /* PageScriptDebugServer.h */; };
+               A5F36D3B18F758720054C024 /* PageScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = A5F36D3918F758720054C024 /* PageScriptDebugServer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A5F6E16B132ED46E008EDAE3 /* Autocapitalize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5F6E16C132ED46E008EDAE3 /* Autocapitalize.cpp */; };
                A6148A6212E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */; };
                A6148A6712E41D940044A784 /* DOMHTMLKeygenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */; };
index 85e6d0a..0410972 100644 (file)
@@ -91,6 +91,7 @@ InspectorController::InspectorController(Page& page, InspectorClient* inspectorC
     , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))
     , m_overlay(std::make_unique<InspectorOverlay>(page, inspectorClient))
     , m_executionStopwatch(Stopwatch::create())
+    , m_scriptDebugServer(page)
     , m_page(page)
     , m_inspectorClient(inspectorClient)
 {
@@ -180,9 +181,6 @@ InspectorController::InspectorController(Page& page, InspectorClient* inspectorC
             , databaseAgent
         );
     }
-
-    runtimeAgent->setScriptDebugServer(&debuggerAgent->scriptDebugServer());
-    m_timelineAgent->setPageScriptDebugServer(&debuggerAgent->scriptDebugServer());
 }
 
 InspectorController::~InspectorController()
@@ -471,6 +469,11 @@ Ref<Stopwatch> InspectorController::executionStopwatch()
     return m_executionStopwatch.copyRef();
 }
 
+PageScriptDebugServer& InspectorController::scriptDebugServer()
+{
+    return m_scriptDebugServer;
+}
+
 JSC::VM& InspectorController::vm()
 {
     return JSDOMWindowBase::commonVM();
index ae0df23..34445a4 100644 (file)
@@ -33,6 +33,7 @@
 #define InspectorController_h
 
 #include "InspectorOverlay.h"
+#include "PageScriptDebugServer.h"
 #include <inspector/InspectorAgentRegistry.h>
 #include <inspector/InspectorEnvironment.h>
 #include <wtf/Forward.h>
@@ -124,6 +125,7 @@ public:
     virtual void didCallInjectedScriptFunction(JSC::ExecState*) override;
     virtual void frontendInitialized() override;
     virtual Ref<WTF::Stopwatch> executionStopwatch() override;
+    virtual PageScriptDebugServer& scriptDebugServer() override;
     virtual JSC::VM& vm() override;
 
     WEBCORE_EXPORT void didComposite(Frame&);
@@ -137,6 +139,7 @@ private:
     Ref<Inspector::BackendDispatcher> m_backendDispatcher;
     std::unique_ptr<InspectorOverlay> m_overlay;
     Ref<WTF::Stopwatch> m_executionStopwatch;
+    PageScriptDebugServer m_scriptDebugServer;
     Inspector::AgentRegistry m_agents;
 
     Page& m_page;
index 444fee3..f5fc6e6 100644 (file)
@@ -266,7 +266,7 @@ InspectorNetworkAgent::~InspectorNetworkAgent()
 
 double InspectorNetworkAgent::timestamp()
 {
-    return m_instrumentingAgents.inspectorEnvironment().executionStopwatch()->elapsedTime();
+    return m_environment.executionStopwatch()->elapsedTime();
 }
 
 void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader& loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
index 3e63cab..54eb5a7 100644 (file)
@@ -351,7 +351,7 @@ void InspectorPageAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReas
 
 double InspectorPageAgent::timestamp()
 {
-    return m_instrumentingAgents.inspectorEnvironment().executionStopwatch()->elapsedTime();
+    return m_environment.executionStopwatch()->elapsedTime();
 }
 
 void InspectorPageAgent::enable(ErrorString&)
@@ -359,7 +359,7 @@ void InspectorPageAgent::enable(ErrorString&)
     m_enabled = true;
     m_instrumentingAgents.setInspectorPageAgent(this);
 
-    auto stopwatch = m_instrumentingAgents.inspectorEnvironment().executionStopwatch();
+    auto stopwatch = m_environment.executionStopwatch();
     stopwatch->reset();
     stopwatch->start();
 
@@ -804,7 +804,7 @@ void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader& loader)
 void InspectorPageAgent::frameStartedLoading(Frame& frame)
 {
     if (frame.isMainFrame()) {
-        auto stopwatch = m_instrumentingAgents.inspectorEnvironment().executionStopwatch();
+        auto stopwatch = m_environment.executionStopwatch();
         stopwatch->reset();
         stopwatch->start();
     }
index e2f473e..ee895d3 100644 (file)
@@ -85,18 +85,17 @@ void InspectorTimelineAgent::didCreateFrontendAndBackend(Inspector::FrontendRout
 {
     m_instrumentingAgents.setPersistentInspectorTimelineAgent(this);
 
-    if (m_scriptDebugServer)
-        m_scriptDebugServer->recompileAllJSFunctions();
+    // Recompile to include profiling information.
+    // FIXME: This doesn't seem like the most appropriate place.
+    m_environment.scriptDebugServer().recompileAllJSFunctions();
 }
 
 void InspectorTimelineAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason reason)
 {
     m_instrumentingAgents.setPersistentInspectorTimelineAgent(nullptr);
 
-    if (reason != Inspector::DisconnectReason::InspectedTargetDestroyed) {
-        if (m_scriptDebugServer)
-            m_scriptDebugServer->recompileAllJSFunctions();
-    }
+    if (reason != Inspector::DisconnectReason::InspectedTargetDestroyed)
+        m_environment.scriptDebugServer().recompileAllJSFunctions();
 
     ErrorString unused;
     stop(unused);
@@ -128,8 +127,7 @@ void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth)
 
     m_instrumentingAgents.setInspectorTimelineAgent(this);
 
-    if (m_scriptDebugServer)
-        m_scriptDebugServer->addListener(this);
+    m_environment.scriptDebugServer().addListener(this);
 
     m_enabled = true;
 
@@ -137,7 +135,7 @@ void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth)
 
 #if PLATFORM(COCOA)
     m_frameStartObserver = RunLoopObserver::create(0, [this]() {
-        if (!m_enabled || m_scriptDebugServer->isPaused())
+        if (!m_enabled || m_environment.scriptDebugServer().isPaused())
             return;
 
         if (!m_runLoopNestingLevel)
@@ -146,7 +144,7 @@ void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth)
     });
 
     m_frameStopObserver = RunLoopObserver::create(frameStopRunLoopOrder, [this]() {
-        if (!m_enabled || m_scriptDebugServer->isPaused())
+        if (!m_enabled || m_environment.scriptDebugServer().isPaused())
             return;
 
         ASSERT(m_runLoopNestingLevel > 0);
@@ -180,8 +178,7 @@ void InspectorTimelineAgent::internalStop()
 
     m_instrumentingAgents.setInspectorTimelineAgent(nullptr);
 
-    if (m_scriptDebugServer)
-        m_scriptDebugServer->removeListener(this, true);
+    m_environment.scriptDebugServer().removeListener(this, true);
 
 #if PLATFORM(COCOA)
     m_frameStartObserver = nullptr;
@@ -203,15 +200,7 @@ void InspectorTimelineAgent::internalStop()
 
 double InspectorTimelineAgent::timestamp()
 {
-    return m_instrumentingAgents.inspectorEnvironment().executionStopwatch()->elapsedTime();
-}
-
-void InspectorTimelineAgent::setPageScriptDebugServer(PageScriptDebugServer* scriptDebugServer)
-{
-    ASSERT(!m_enabled);
-    ASSERT(!m_scriptDebugServer);
-
-    m_scriptDebugServer = scriptDebugServer;
+    return m_environment.executionStopwatch()->elapsedTime();
 }
 
 static inline void startProfiling(JSC::ExecState* exec, const String& title, RefPtr<Stopwatch>&& stopwatch)
@@ -250,7 +239,7 @@ void InspectorTimelineAgent::startFromConsole(JSC::ExecState* exec, const String
     if (!m_enabled && m_pendingConsoleProfileRecords.isEmpty())
         internalStart();
 
-    startProfiling(exec, title, m_instrumentingAgents.inspectorEnvironment().executionStopwatch());
+    startProfiling(exec, title, m_environment.executionStopwatch());
 
     m_pendingConsoleProfileRecords.append(createRecordEntry(TimelineRecordFactory::createConsoleProfileData(title), TimelineRecordType::ConsoleProfile, true, frameFromExecState(exec)));
 }
@@ -289,7 +278,7 @@ void InspectorTimelineAgent::willCallFunction(const String& scriptName, int scri
     pushCurrentRecord(TimelineRecordFactory::createFunctionCallData(scriptName, scriptLine), TimelineRecordType::FunctionCall, true, frame);
 
     if (frame && !m_callStackDepth)
-        startProfiling(frame, ASCIILiteral("Timeline FunctionCall"), m_instrumentingAgents.inspectorEnvironment().executionStopwatch());
+        startProfiling(frame, ASCIILiteral("Timeline FunctionCall"), m_environment.executionStopwatch());
 
     ++m_callStackDepth;
 }
@@ -421,7 +410,7 @@ void InspectorTimelineAgent::willEvaluateScript(const String& url, int lineNumbe
 
     if (!m_callStackDepth) {
         ++m_callStackDepth;
-        startProfiling(&frame, ASCIILiteral("Timeline EvaluateScript"), m_instrumentingAgents.inspectorEnvironment().executionStopwatch());
+        startProfiling(&frame, ASCIILiteral("Timeline EvaluateScript"), m_environment.executionStopwatch());
     }
 }
 
index 01dcc1f..f01e703 100644 (file)
@@ -51,7 +51,6 @@ class Event;
 class FloatQuad;
 class Frame;
 class InspectorPageAgent;
-class PageScriptDebugServer;
 class RenderObject;
 class RunLoopObserver;
 
@@ -106,8 +105,6 @@ public:
 
     int id() const { return m_id; }
 
-    void setPageScriptDebugServer(PageScriptDebugServer*);
-
     void didCommitLoad();
 
     // Methods called from WebCore.
@@ -199,8 +196,6 @@ private:
     RefPtr<Inspector::TimelineBackendDispatcher> m_backendDispatcher;
     InspectorPageAgent* m_pageAgent;
 
-    PageScriptDebugServer* m_scriptDebugServer { nullptr };
-
     Vector<TimelineRecordEntry> m_recordStack;
     int m_id { 1 };
     int m_callStackDepth { 0 };
index 7434293..031e4c9 100644 (file)
@@ -72,10 +72,12 @@ protected:
     InspectorAgentBase(const String& name, WebAgentContext& context)
         : Inspector::InspectorAgentBase(name)
         , m_instrumentingAgents(context.instrumentingAgents)
+        , m_environment(context.environment)
     {
     }
 
     InstrumentingAgents& m_instrumentingAgents;
+    Inspector::InspectorEnvironment& m_environment;
 };
     
 } // namespace WebCore
index 193489e..f1adf1d 100644 (file)
@@ -56,7 +56,6 @@ PageDebuggerAgent::PageDebuggerAgent(PageAgentContext& context, InspectorPageAge
     , m_page(context.inspectedPage)
     , m_pageAgent(pageAgent)
     , m_overlay(overlay)
-    , m_scriptDebugServer(m_page)
 {
 }
 
@@ -93,11 +92,6 @@ String PageDebuggerAgent::sourceMapURLForScript(const Script& script)
     return InspectorDebuggerAgent::sourceMapURLForScript(script);
 }
 
-PageScriptDebugServer& PageDebuggerAgent::scriptDebugServer()
-{
-    return m_scriptDebugServer;
-}
-
 void PageDebuggerAgent::muteConsole()
 {
     PageConsoleClient::mute();
index 7816730..133b469 100644 (file)
@@ -32,7 +32,6 @@
 #ifndef PageDebuggerAgent_h
 #define PageDebuggerAgent_h
 
-#include "PageScriptDebugServer.h"
 #include "WebDebuggerAgent.h"
 
 namespace WebCore {
@@ -40,7 +39,6 @@ namespace WebCore {
 class InspectorOverlay;
 class InspectorPageAgent;
 class Page;
-class PageScriptDebugServer;
 
 class PageDebuggerAgent final : public WebDebuggerAgent {
     WTF_MAKE_NONCOPYABLE(PageDebuggerAgent);
@@ -55,8 +53,6 @@ public:
     void mainFrameStoppedLoading();
     void mainFrameNavigated();
 
-    virtual PageScriptDebugServer& scriptDebugServer() override;
-
 protected:
     virtual void enable() override;
     virtual void disable(bool isBeingDestroyed) override;
@@ -76,7 +72,6 @@ private:
 
     InspectorPageAgent* m_pageAgent;
     InspectorOverlay* m_overlay { nullptr };
-    PageScriptDebugServer m_scriptDebugServer;
 };
 
 } // namespace WebCore
index 015dce1..a5fae4c 100644 (file)
@@ -108,11 +108,6 @@ void PageRuntimeAgent::didCreateMainWorldContext(Frame& frame)
     notifyContextCreated(frameId, scriptState, nullptr, true);
 }
 
-JSC::VM& PageRuntimeAgent::globalVM()
-{
-    return JSDOMWindowBase::commonVM();
-}
-
 InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
 {
     if (!executionContextId) {
index b790e70..b5f1adb 100644 (file)
@@ -67,7 +67,6 @@ public:
     void didCreateMainWorldContext(Frame&);
 
 private:
-    virtual JSC::VM& globalVM() override;
     virtual Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
     virtual void muteConsole() override;
     virtual void unmuteConsole() override;
index 859461f..31b30ff 100644 (file)
@@ -33,6 +33,7 @@
 #include "WorkerDebuggerAgent.h"
 
 #include "WorkerGlobalScope.h"
+#include "WorkerScriptDebugServer.h"
 #include "WorkerThread.h"
 #include <inspector/InjectedScript.h>
 #include <inspector/InjectedScriptManager.h>
@@ -83,7 +84,6 @@ const char* WorkerDebuggerAgent::debuggerTaskMode = "debugger";
 
 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerAgentContext& context)
     : WebDebuggerAgent(context)
-    , m_scriptDebugServer(context.workerGlobalScope, WorkerDebuggerAgent::debuggerTaskMode)
     , m_inspectedWorkerGlobalScope(context.workerGlobalScope)
 {
     std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex);
@@ -102,8 +102,10 @@ void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th
 {
     std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex);
 
-    if (WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread))
-        agent->m_scriptDebugServer.interruptAndRunTask(std::make_unique<RunInspectorCommandsTask>(thread, &agent->m_inspectedWorkerGlobalScope));
+    if (WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread)) {
+        WorkerScriptDebugServer& workerScriptDebugServer = static_cast<WorkerScriptDebugServer&>(agent->scriptDebugServer());
+        workerScriptDebugServer.interruptAndRunTask(std::make_unique<RunInspectorCommandsTask>(thread, &agent->m_inspectedWorkerGlobalScope));
+    }
 }
 
 void WorkerDebuggerAgent::breakpointActionLog(JSC::ExecState*, const String& message)
@@ -111,11 +113,6 @@ void WorkerDebuggerAgent::breakpointActionLog(JSC::ExecState*, const String& mes
     m_inspectedWorkerGlobalScope.addConsoleMessage(MessageSource::JS, MessageLevel::Log, message);
 }
 
-WorkerScriptDebugServer& WorkerDebuggerAgent::scriptDebugServer()
-{
-    return m_scriptDebugServer;
-}
-
 InjectedScript WorkerDebuggerAgent::injectedScriptForEval(ErrorString& error, const int* executionContextId)
 {
     if (executionContextId) {
index ac19080..55666ef 100644 (file)
@@ -33,7 +33,6 @@
 #define WorkerDebuggerAgent_h
 
 #include "WebDebuggerAgent.h"
-#include "WorkerScriptDebugServer.h"
 
 namespace WebCore {
 
@@ -50,7 +49,6 @@ public:
     static const char* debuggerTaskMode;
     static void interruptAndDispatchInspectorCommands(WorkerThread*);
 
-    virtual WorkerScriptDebugServer& scriptDebugServer() override;
     virtual Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
     virtual void muteConsole() override;
     virtual void unmuteConsole() override;
@@ -58,7 +56,6 @@ public:
     virtual void breakpointActionLog(JSC::ExecState*, const String&) override;
 
 private:
-    WorkerScriptDebugServer m_scriptDebugServer;
     WorkerGlobalScope& m_inspectedWorkerGlobalScope;
 };
 
index 28cdec0..27a8a26 100644 (file)
@@ -83,6 +83,7 @@ WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope& workerGl
     , m_instrumentingAgents(InstrumentingAgents::create(*this))
     , m_injectedScriptManager(std::make_unique<WebInjectedScriptManager>(*this, WebInjectedScriptHost::create()))
     , m_executionStopwatch(Stopwatch::create())
+    , m_scriptDebugServer(workerGlobalScope, WorkerDebuggerAgent::debuggerTaskMode)
     , m_frontendRouter(FrontendRouter::create())
     , m_backendDispatcher(BackendDispatcher::create(m_frontendRouter.copyRef()))
 {
@@ -112,7 +113,6 @@ WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope& workerGl
     m_instrumentingAgents->setWebConsoleAgent(consoleAgent.get());
 
     auto debuggerAgent = std::make_unique<WorkerDebuggerAgent>(workerContext);
-    m_runtimeAgent->setScriptDebugServer(&debuggerAgent->scriptDebugServer());
     m_agents.append(WTF::move(debuggerAgent));
 
     m_agents.append(std::make_unique<InspectorTimelineAgent>(workerContext, nullptr, InspectorTimelineAgent::WorkerInspector));
@@ -197,9 +197,14 @@ Ref<Stopwatch> WorkerInspectorController::executionStopwatch()
     return m_executionStopwatch.copyRef();
 }
 
+WorkerScriptDebugServer& WorkerInspectorController::scriptDebugServer()
+{
+    return m_scriptDebugServer;
+}
+
 VM& WorkerInspectorController::vm()
 {
-    return JSDOMWindowBase::commonVM();
+    return m_workerGlobalScope.vm();
 }
 
 } // namespace WebCore
index 7f42473..2f51b42 100644 (file)
 
 #include "InspectorInstrumentationCookie.h"
 #include "InspectorWebAgentBase.h"
+#include "WorkerScriptDebugServer.h"
 #include <inspector/InspectorAgentRegistry.h>
 #include <inspector/InspectorEnvironment.h>
-#include <wtf/FastMalloc.h>
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
 namespace Inspector {
@@ -75,6 +74,7 @@ public:
     virtual void didCallInjectedScriptFunction(JSC::ExecState*) override;
     virtual void frontendInitialized() override { }
     virtual Ref<WTF::Stopwatch> executionStopwatch() override;
+    virtual WorkerScriptDebugServer& scriptDebugServer() override;
     virtual JSC::VM& vm() override;
 
 private:
@@ -87,6 +87,7 @@ private:
     Inspector::AgentRegistry m_agents;
     std::unique_ptr<Inspector::FrontendChannel> m_forwardingChannel;
     Ref<WTF::Stopwatch> m_executionStopwatch;
+    WorkerScriptDebugServer m_scriptDebugServer;
     Ref<Inspector::FrontendRouter> m_frontendRouter;
     Ref<Inspector::BackendDispatcher> m_backendDispatcher;
     Vector<InspectorInstrumentationCookie, 2> m_injectedScriptInstrumentationCookies;
index 53030ea..52879c5 100644 (file)
@@ -89,11 +89,6 @@ void WorkerRuntimeAgent::run(ErrorString&)
     m_paused = false;
 }
 
-JSC::VM& WorkerRuntimeAgent::globalVM()
-{
-    return JSDOMWindowBase::commonVM();
-}
-
 void WorkerRuntimeAgent::pauseWorkerGlobalScope(WorkerGlobalScope* context)
 {
     m_paused = true;
index f82ccaf..2c4de92 100644 (file)
@@ -53,7 +53,6 @@ public:
     void pauseWorkerGlobalScope(WorkerGlobalScope*);
 
 private:
-    virtual JSC::VM& globalVM() override;
     virtual Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
     virtual void muteConsole() override;
     virtual void unmuteConsole() override;