Commit 8897eaaf authored by joepeck@webkit.org's avatar joepeck@webkit.org

Web Inspector: Push InspectorAgent down into JSC, give JSC an InspectorController

https://bugs.webkit.org/show_bug.cgi?id=126763

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Introduce JSGlobalObjectInspectorController. This is the InspectorController
for a JSContext. It is created by the JSGlobalObject Remote Inspector Debuggable
when a remote frontend connects, and is destroyed when the remote frontend
disconnects of the JSGlobalObject is destroyed.

* inspector/JSGlobalObjectInspectorController.h: Added.
* inspector/JSGlobalObjectInspectorController.cpp: Added.
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::~JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::connectFrontend):
(Inspector::JSGlobalObjectInspectorController::disconnectFrontend):
(Inspector::JSGlobalObjectInspectorController::dispatchMessageFromFrontend):
(Inspector::JSGlobalObjectInspectorController::functionCallHandler):
(Inspector::JSGlobalObjectInspectorController::evaluateHandler):
Create/destory agents, create/destroy dispatches, implement InspectorEnvironment.

* runtime/JSGlobalObjectDebuggable.h:
* runtime/JSGlobalObjectDebuggable.cpp:
(JSC::JSGlobalObjectDebuggable::~JSGlobalObjectDebuggable):
(JSC::JSGlobalObjectDebuggable::connect):
(JSC::JSGlobalObjectDebuggable::disconnect):
(JSC::JSGlobalObjectDebuggable::dispatchMessageFromRemoteFrontend):
Forward actions to the InspectorController object.

* inspector/agents/InspectorAgent.h: Renamed from Source/WebCore/inspector/InspectorAgent.h.
* inspector/agents/InspectorAgent.cpp: Renamed from Source/WebCore/inspector/InspectorAgent.cpp.
(Inspector::InspectorAgent::InspectorAgent):
(Inspector::InspectorAgent::~InspectorAgent):
(Inspector::InspectorAgent::didCreateFrontendAndBackend):
(Inspector::InspectorAgent::inspect):
(Inspector::InspectorAgent::evaluateForTestInFrontend):
Implement InspectorAgent in JavaScriptCore in namespace Inspector.

* JavaScriptCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:
* ChangeLog:
* GNUmakefile.am:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.vcxproj/copy-files.cmd:
Add files and new inspector/agents subdirectory.

Source/WebCore:

No new tests, no observable change in functionality.

* CMakeLists.txt:
* ForwardingHeaders/inspector/InspectorAgent.h: Added.
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
InspectorAgent moved to JavaScriptCore.

* inspector/PageConsoleAgent.cpp:
(WebCore::PageConsoleAgent::PageConsoleAgent):
(WebCore::PageConsoleAgent::~PageConsoleAgent):
* inspector/PageConsoleAgent.h:
(WebCore::PageConsoleAgent::create):
* inspector/InspectorApplicationCacheAgent.cpp:
* inspector/InspectorApplicationCacheAgent.h:
InspectorAgent was not used by these files, remove it.

* inspector/CommandLineAPIHost.cpp:
* inspector/CommandLineAPIHost.h:
(WebCore::CommandLineAPIHost::init):
* inspector/InspectorInstrumentation.cpp:
* inspector/InstrumentingAgents.h:
(WebCore::InstrumentingAgents::inspectorAgent):
(WebCore::InstrumentingAgents::setInspectorAgent):
Switch to Inspector::InspectorAgent where applicable.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/InspectorController.h:
Manually add InspectorAgent to the InstrumentingAgents. It is one
of the agents that is always available in InstrumentingAgents.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161733 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b8de1141
......@@ -13,6 +13,7 @@ set(JavaScriptCore_INCLUDE_DIRECTORIES
"${JAVASCRIPTCORE_DIR}/heap"
"${JAVASCRIPTCORE_DIR}/debugger"
"${JAVASCRIPTCORE_DIR}/inspector"
"${JAVASCRIPTCORE_DIR}/inspector/agents"
"${JAVASCRIPTCORE_DIR}/interpreter"
"${JAVASCRIPTCORE_DIR}/jit"
"${JAVASCRIPTCORE_DIR}/llint"
......@@ -235,6 +236,7 @@ set(JavaScriptCore_SOURCES
inspector/InjectedScriptModule.cpp
inspector/JSInjectedScriptHost.cpp
inspector/JSInjectedScriptHostPrototype.cpp
inspector/agents/InspectorAgent.cpp
interpreter/AbstractPC.cpp
interpreter/CallFrame.cpp
......@@ -712,6 +714,7 @@ set(JavaScriptCore_FORWARDING_HEADERS_DIRECTORIES
debugger
heap
inspector
inspector/agents
interpreter
jit
llint
......
2014-01-10 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: Push InspectorAgent down into JSC, give JSC an InspectorController
https://bugs.webkit.org/show_bug.cgi?id=126763
Reviewed by Timothy Hatcher.
Introduce JSGlobalObjectInspectorController. This is the InspectorController
for a JSContext. It is created by the JSGlobalObject Remote Inspector Debuggable
when a remote frontend connects, and is destroyed when the remote frontend
disconnects of the JSGlobalObject is destroyed.
* inspector/JSGlobalObjectInspectorController.h: Added.
* inspector/JSGlobalObjectInspectorController.cpp: Added.
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::~JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::connectFrontend):
(Inspector::JSGlobalObjectInspectorController::disconnectFrontend):
(Inspector::JSGlobalObjectInspectorController::dispatchMessageFromFrontend):
(Inspector::JSGlobalObjectInspectorController::functionCallHandler):
(Inspector::JSGlobalObjectInspectorController::evaluateHandler):
Create/destory agents, create/destroy dispatches, implement InspectorEnvironment.
* runtime/JSGlobalObjectDebuggable.h:
* runtime/JSGlobalObjectDebuggable.cpp:
(JSC::JSGlobalObjectDebuggable::~JSGlobalObjectDebuggable):
(JSC::JSGlobalObjectDebuggable::connect):
(JSC::JSGlobalObjectDebuggable::disconnect):
(JSC::JSGlobalObjectDebuggable::dispatchMessageFromRemoteFrontend):
Forward actions to the InspectorController object.
* inspector/agents/InspectorAgent.h: Renamed from Source/WebCore/inspector/InspectorAgent.h.
* inspector/agents/InspectorAgent.cpp: Renamed from Source/WebCore/inspector/InspectorAgent.cpp.
(Inspector::InspectorAgent::InspectorAgent):
(Inspector::InspectorAgent::~InspectorAgent):
(Inspector::InspectorAgent::didCreateFrontendAndBackend):
(Inspector::InspectorAgent::inspect):
(Inspector::InspectorAgent::evaluateForTestInFrontend):
Implement InspectorAgent in JavaScriptCore in namespace Inspector.
* JavaScriptCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:
* ChangeLog:
* GNUmakefile.am:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.vcxproj/copy-files.cmd:
Add files and new inspector/agents subdirectory.
2014-01-10 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r161702.
......
......@@ -59,6 +59,7 @@ javascriptcore_cppflags += \
-I$(srcdir)/Source/JavaScriptCore/ftl \
-I$(srcdir)/Source/JavaScriptCore/heap \
-I$(srcdir)/Source/JavaScriptCore/inspector \
-I$(srcdir)/Source/JavaScriptCore/inspector/agents \
-I$(srcdir)/Source/JavaScriptCore/interpreter \
-I$(srcdir)/Source/JavaScriptCore/jit \
-I$(srcdir)/Source/JavaScriptCore/llint \
......
......@@ -651,6 +651,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/inspector/JSInjectedScriptHost.h \
Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp \
Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.h \
Source/JavaScriptCore/inspector/agents/InspectorAgent.h \
Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp \
Source/JavaScriptCore/interpreter/AbstractPC.cpp \
Source/JavaScriptCore/interpreter/AbstractPC.h \
Source/JavaScriptCore/interpreter/CachedCall.h \
......
......@@ -485,6 +485,7 @@
<ClCompile Include="..\inspector\InspectorValues.cpp" />
<ClCompile Include="..\inspector\JSInjectedScriptHost.cpp" />
<ClCompile Include="..\inspector\JSInjectedScriptHostPrototype.cpp" />
<ClCompile Include="..\inspector\agents\InspectorAgent.cpp" />
<ClCompile Include="..\interpreter\AbstractPC.cpp" />
<ClCompile Include="..\interpreter\CallFrame.cpp" />
<ClCompile Include="..\interpreter\Interpreter.cpp" />
......@@ -1054,6 +1055,7 @@
<ClInclude Include="..\inspector\InspectorValues.h" />
<ClInclude Include="..\inspector\JSInjectedScriptHost.h" />
<ClInclude Include="..\inspector\JSInjectedScriptHostPrototype.h" />
<ClInclude Include="..\inspector\agents\InspectorAgent.h" />
<ClInclude Include="..\interpreter\AbstractPC.h" />
<ClInclude Include="..\interpreter\CachedCall.h" />
<ClInclude Include="..\interpreter\CallFrame.h" />
......
......@@ -294,6 +294,9 @@
<ClCompile Include="..\inspector\InspectorValues.cpp">
<Filter>inspector</Filter>
</ClCompile>
<ClCompile Include="..\inspector\agents\InspectorAgent.cpp">
<Filter>inspector</Filter>
</ClCompile>
<ClCompile Include="..\interpreter\AbstractPC.cpp">
<Filter>interpreter</Filter>
</ClCompile>
......@@ -1784,6 +1787,9 @@
<ClInclude Include="..\inspector\InspectorValues.h">
<Filter>inspector</Filter>
</ClInclude>
<ClInclude Include="..\inspector\agents\InspectorAgent.h">
<Filter>inspector</Filter>
</ClInclude>
<ClInclude Include="..\interpreter\AbstractPC.h">
<Filter>interpreter</Filter>
</ClInclude>
......
......@@ -47,6 +47,7 @@ for %%d in (
heap
debugger
inspector
inspector\agents
interpreter
jit
llint
......
......@@ -900,6 +900,8 @@
A1712B4111C7B235007A5315 /* RegExpKey.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B4011C7B235007A5315 /* RegExpKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1A009C01831A22D00CF8711 /* MacroAssemblerARM64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8640923C156EED3B00566CB2 /* MacroAssemblerARM64.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1A009C11831A26E00CF8711 /* ARM64Assembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 8640923B156EED3B00566CB2 /* ARM64Assembler.h */; settings = {ATTRIBUTES = (Private, ); }; };
A51007C0187CC3C600B38879 /* JSGlobalObjectInspectorController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A51007BE187CC3C600B38879 /* JSGlobalObjectInspectorController.cpp */; };
A51007C1187CC3C600B38879 /* JSGlobalObjectInspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = A51007BF187CC3C600B38879 /* JSGlobalObjectInspectorController.h */; };
A513E5B7185B8BD3007E95AD /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A513E5B5185B8BD3007E95AD /* InjectedScript.cpp */; };
A513E5B8185B8BD3007E95AD /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = A513E5B6185B8BD3007E95AD /* InjectedScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
A513E5BE185BFACC007E95AD /* InjectedScriptHost.h in Headers */ = {isa = PBXBuildFile; fileRef = A513E5B9185BFACC007E95AD /* InjectedScriptHost.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -955,6 +957,8 @@
A5BA15ED182340B400A82E69 /* RemoteInspectorXPCConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15E6182340B300A82E69 /* RemoteInspectorXPCConnection.h */; };
A5BA15EE182340B400A82E69 /* RemoteInspectorXPCConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15E7182340B300A82E69 /* RemoteInspectorXPCConnection.mm */; };
A5BA15F0182345AF00A82E69 /* RemoteInspectorDebuggable.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15EF182345AF00A82E69 /* RemoteInspectorDebuggable.h */; settings = {ATTRIBUTES = (Private, ); }; };
A5CEEE14187F3BAD00E55C99 /* InspectorAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5CEEE12187F3BAD00E55C99 /* InspectorAgent.cpp */; };
A5CEEE15187F3BAD00E55C99 /* InspectorAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A5CEEE13187F3BAD00E55C99 /* InspectorAgent.h */; settings = {ATTRIBUTES = (Private, ); }; };
A5D0A1BB1862301B00C7B496 /* InspectorEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = A5D0A1BA1862301B00C7B496 /* InspectorEnvironment.h */; settings = {ATTRIBUTES = (Private, ); }; };
A700873917CBE85300C3E643 /* MapConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A700873717CBE85300C3E643 /* MapConstructor.cpp */; };
A700873A17CBE85300C3E643 /* MapConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = A700873817CBE85300C3E643 /* MapConstructor.h */; };
......@@ -2281,6 +2285,8 @@
A1712B3A11C7B212007A5315 /* RegExpCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpCache.cpp; sourceTree = "<group>"; };
A1712B3E11C7B228007A5315 /* RegExpCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCache.h; sourceTree = "<group>"; };
A1712B4011C7B235007A5315 /* RegExpKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpKey.h; sourceTree = "<group>"; };
A51007BE187CC3C600B38879 /* JSGlobalObjectInspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObjectInspectorController.cpp; sourceTree = "<group>"; };
A51007BF187CC3C600B38879 /* JSGlobalObjectInspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObjectInspectorController.h; sourceTree = "<group>"; };
A513E5B5185B8BD3007E95AD /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = "<group>"; };
A513E5B6185B8BD3007E95AD /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; };
A513E5B9185BFACC007E95AD /* InjectedScriptHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScriptHost.h; sourceTree = "<group>"; };
......@@ -2339,6 +2345,8 @@
A5BA15E6182340B300A82E69 /* RemoteInspectorXPCConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspectorXPCConnection.h; sourceTree = "<group>"; };
A5BA15E7182340B300A82E69 /* RemoteInspectorXPCConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteInspectorXPCConnection.mm; sourceTree = "<group>"; };
A5BA15EF182345AF00A82E69 /* RemoteInspectorDebuggable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspectorDebuggable.h; sourceTree = "<group>"; };
A5CEEE12187F3BAD00E55C99 /* InspectorAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorAgent.cpp; sourceTree = "<group>"; };
A5CEEE13187F3BAD00E55C99 /* InspectorAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorAgent.h; sourceTree = "<group>"; };
A5D0A1BA1862301B00C7B496 /* InspectorEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorEnvironment.h; sourceTree = "<group>"; };
A700873717CBE85300C3E643 /* MapConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MapConstructor.cpp; sourceTree = "<group>"; };
A700873817CBE85300C3E643 /* MapConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapConstructor.h; sourceTree = "<group>"; };
......@@ -4317,6 +4325,15 @@
path = bytecode;
sourceTree = "<group>";
};
A513E5CC185FB992007E95AD /* agents */ = {
isa = PBXGroup;
children = (
A5CEEE12187F3BAD00E55C99 /* InspectorAgent.cpp */,
A5CEEE13187F3BAD00E55C99 /* InspectorAgent.h */,
);
path = agents;
sourceTree = "<group>";
};
A532438E185696CE002ED692 /* scripts */ = {
isa = PBXGroup;
children = (
......@@ -4348,6 +4365,7 @@
isa = PBXGroup;
children = (
A532438D185696CA002ED692 /* protocol */,
A513E5CC185FB992007E95AD /* agents */,
A5BA15E01823409D00A82E69 /* remote */,
A532438E185696CE002ED692 /* scripts */,
A513E5B5185B8BD3007E95AD /* InjectedScript.cpp */,
......@@ -4371,6 +4389,8 @@
A55D93AB18514F7900400DED /* InspectorTypeBuilder.h */,
A593CF801840377100BFCE27 /* InspectorValues.cpp */,
A593CF811840377100BFCE27 /* InspectorValues.h */,
A51007BE187CC3C600B38879 /* JSGlobalObjectInspectorController.cpp */,
A51007BF187CC3C600B38879 /* JSGlobalObjectInspectorController.h */,
A513E5BA185BFACC007E95AD /* JSInjectedScriptHost.cpp */,
A513E5BB185BFACC007E95AD /* JSInjectedScriptHost.h */,
A513E5BC185BFACC007E95AD /* JSInjectedScriptHostPrototype.cpp */,
......@@ -4438,6 +4458,7 @@
A76140D0182982CB00750624 /* ArgumentsIteratorPrototype.h in Headers */,
86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
A5CEEE15187F3BAD00E55C99 /* InspectorAgent.h in Headers */,
65C0285D1717966800351E35 /* ARMv7DOpcode.h in Headers */,
2A68295B1875F80500B6C3E2 /* CopyWriteBarrier.h in Headers */,
2A4EC90C1860D6C20094F782 /* WriteBarrierBuffer.h in Headers */,
......@@ -4953,6 +4974,7 @@
A78507D717CBC6FD0011F6E7 /* MapData.h in Headers */,
A700873E17CBE8D300C3E643 /* MapPrototype.h in Headers */,
C2B916C214DA014E00CBAC86 /* MarkedAllocator.h in Headers */,
A51007C1187CC3C600B38879 /* JSGlobalObjectInspectorController.h in Headers */,
142D6F0913539A2800B02E86 /* MarkedBlock.h in Headers */,
141448CB13A176EC00F5BA1A /* MarkedBlockSet.h in Headers */,
14D2F3DB139F4BE200491031 /* MarkedSpace.h in Headers */,
......@@ -5904,6 +5926,7 @@
A7E2EA6C0FB460CF00601F06 /* LiteralParser.cpp in Sources */,
FE20CE9D15F04A9500DF3430 /* LLIntCLoop.cpp in Sources */,
0F4680D214BBD16500BFE272 /* LLIntData.cpp in Sources */,
A51007C0187CC3C600B38879 /* JSGlobalObjectInspectorController.cpp in Sources */,
0F38B01117CF078000B144D3 /* LLIntEntrypoint.cpp in Sources */,
0F4680A814BA7FAB00BFE272 /* LLIntExceptions.cpp in Sources */,
0F4680A414BA7F8D00BFE272 /* LLIntSlowPaths.cpp in Sources */,
......@@ -5978,6 +6001,7 @@
1474C33C16AA2D9B0062F01D /* PrototypeMap.cpp in Sources */,
0F9332A314CA7DD70085F3C6 /* PutByIdStatus.cpp in Sources */,
0FF60AC316740F8800029779 /* ReduceWhitespace.cpp in Sources */,
A5CEEE14187F3BAD00E55C99 /* InspectorAgent.cpp in Sources */,
14280841107EC0930013E7B2 /* RegExp.cpp in Sources */,
A1712B3B11C7B212007A5315 /* RegExpCache.cpp in Sources */,
8642C510151C06A90046D4EF /* RegExpCachedResult.cpp in Sources */,
......
/*
* Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "JSGlobalObjectInspectorController.h"
#if ENABLE(INSPECTOR)
#include "Completion.h"
#include "InjectedScriptHost.h"
#include "InjectedScriptManager.h"
#include "InspectorAgent.h"
#include "InspectorBackendDispatcher.h"
#include "InspectorFrontendChannel.h"
#include "JSGlobalObject.h"
using namespace JSC;
namespace Inspector {
JSGlobalObjectInspectorController::JSGlobalObjectInspectorController(JSGlobalObject& globalObject)
: m_globalObject(globalObject)
, m_injectedScriptManager(std::make_unique<InjectedScriptManager>(*this, InjectedScriptHost::create()))
, m_inspectorFrontendChannel(nullptr)
{
OwnPtr<InspectorAgent> inspectorAgent(InspectorAgent::create());
m_agents.append(inspectorAgent.release());
// FIXME: Create RuntimeAgent.
// FIXME: Create DebuggerAgent.
(void)m_globalObject; // Will be used by RuntimeAgent.
}
JSGlobalObjectInspectorController::~JSGlobalObjectInspectorController()
{
m_agents.discardAgents();
}
void JSGlobalObjectInspectorController::connectFrontend(InspectorFrontendChannel* frontendChannel)
{
ASSERT(!m_inspectorFrontendChannel);
ASSERT(!m_inspectorBackendDispatcher);
m_inspectorFrontendChannel = frontendChannel;
m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendChannel);
m_agents.didCreateFrontendAndBackend(frontendChannel, m_inspectorBackendDispatcher.get());
}
void JSGlobalObjectInspectorController::disconnectFrontend()
{
if (!m_inspectorFrontendChannel)
return;
m_agents.willDestroyFrontendAndBackend();
m_inspectorBackendDispatcher->clearFrontend();
m_inspectorBackendDispatcher.clear();
m_inspectorFrontendChannel = nullptr;
m_injectedScriptManager->disconnect();
}
void JSGlobalObjectInspectorController::dispatchMessageFromFrontend(const String& message)
{
if (m_inspectorBackendDispatcher)
m_inspectorBackendDispatcher->dispatch(message);
}
InspectorFunctionCallHandler JSGlobalObjectInspectorController::functionCallHandler() const
{
return JSC::call;
}
InspectorEvaluateHandler JSGlobalObjectInspectorController::evaluateHandler() const
{
return JSC::evaluate;
}
} // namespace Inspector
#endif // ENABLE(INSPECTOR)
/*
* Copyright (C) 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef JSGlobalObjectInspectorController_h
#define JSGlobalObjectInspectorController_h
#if ENABLE(INSPECTOR)
#include "InspectorAgentRegistry.h"
#include "InspectorEnvironment.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/text/WTFString.h>
namespace JSC {
class ExecState;
class JSGlobalObject;
}
namespace Inspector {
class InjectedScriptManager;
class InspectorBackendDispatcher;
class InspectorFrontendChannel;
class JSGlobalObjectInspectorController FINAL : public InspectorEnvironment {
WTF_MAKE_NONCOPYABLE(JSGlobalObjectInspectorController);
WTF_MAKE_FAST_ALLOCATED;
public:
JSGlobalObjectInspectorController(JSC::JSGlobalObject&);
~JSGlobalObjectInspectorController();
void connectFrontend(InspectorFrontendChannel*);
void disconnectFrontend();
void dispatchMessageFromFrontend(const String&);
virtual bool developerExtrasEnabled() const OVERRIDE { return true; }
virtual bool canAccessInspectedScriptState(JSC::ExecState*) const OVERRIDE { return true; }
virtual InspectorFunctionCallHandler functionCallHandler() const OVERRIDE;
virtual InspectorEvaluateHandler evaluateHandler() const OVERRIDE;
virtual void willCallInjectedScriptFunction(JSC::ExecState*, const String&, int) OVERRIDE { }
virtual void didCallInjectedScriptFunction() OVERRIDE { }
private:
JSC::JSGlobalObject& m_globalObject;
std::unique_ptr<InjectedScriptManager> m_injectedScriptManager;
InspectorAgentRegistry m_agents;
InspectorFrontendChannel* m_inspectorFrontendChannel;
RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
};
} // namespace Inspector
#endif // ENABLE(INSPECTOR)
#endif // !defined(JSGlobalObjectInspectorController_h)
......@@ -29,35 +29,28 @@
*/
#include "config.h"
#include "InspectorAgent.h"
#if ENABLE(INSPECTOR)
#include "InspectorAgent.h"
#include "InstrumentingAgents.h"
#include <bindings/ScriptValue.h>
#include <inspector/InspectorJSFrontendDispatchers.h>
#include <inspector/InspectorValues.h>
#include "InspectorValues.h"
#include "ScriptValue.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
using namespace Inspector;
namespace Inspector {
namespace WebCore {
InspectorAgent::InspectorAgent(InstrumentingAgents* instrumentingAgents)
: InspectorAgentBase(ASCIILiteral("Inspector"), instrumentingAgents)
InspectorAgent::InspectorAgent()
: InspectorAgentBase(ASCIILiteral("Inspector"))
, m_enabled(false)
{
m_instrumentingAgents->setInspectorAgent(this);
}
InspectorAgent::~InspectorAgent()
{
m_instrumentingAgents->setInspectorAgent(0);
}
void InspectorAgent::didCreateFrontendAndBackend(Inspector::InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
void InspectorAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
{
m_frontendDispatcher = std::make_unique<InspectorInspectorFrontendDispatcher>(frontendChannel);
m_backendDispatcher = InspectorInspectorBackendDispatcher::create(backendDispatcher, this);
......@@ -91,26 +84,27 @@ void InspectorAgent::disable(ErrorString*)
m_enabled = false;
}
void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script)
{
if (m_enabled && m_frontendDispatcher)
m_frontendDispatcher->evaluateForTestInFrontend(static_cast<int>(callId), script);
else
m_pendingEvaluateTestCommands.append(std::pair<long, String>(callId, script));
}
void InspectorAgent::inspect(PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints)
void InspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints)
{
if (m_enabled && m_frontendDispatcher) {
m_frontendDispatcher->inspect(objectToInspect, hints);
m_pendingInspectData.first = 0;
m_pendingInspectData.second = 0;
m_pendingInspectData.first = nullptr;
m_pendingInspectData.second = nullptr;
return;
}
m_pendingInspectData.first = objectToInspect;
m_pendingInspectData.second = hints;
}
} // namespace WebCore
void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script)
{
if (m_enabled && m_frontendDispatcher)
m_frontendDispatcher->evaluateForTestInFrontend(static_cast<int>(callId), script);
else
m_pendingEvaluateTestCommands.append(std::pair<long, String>(callId, script));
}
} // namespace Inspector
#endif // ENABLE(INSPECTOR)
......@@ -30,56 +30,45 @@
#ifndef InspectorAgent_h
#define InspectorAgent_h
#include "InspectorWebAgentBase.h"
#include <inspector/InspectorJSBackendDispatchers.h>
#include "InspectorJSBackendDispatchers.h"
#include "InspectorJSFrontendDispatchers.h"
#include "inspector/InspectorAgentBase.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
namespace Inspector {
class InspectorObject;
class InspectorInspectorFrontendDispatcher;
}
namespace WebCore {
class InspectorObject;
class InstrumentingAgents;
typedef String ErrorString;
class InspectorAgent : public InspectorAgentBase, public Inspector::InspectorInspectorBackendDispatcherHandler {
class JS_EXPORT_PRIVATE InspectorAgent FINAL : public InspectorAgentBase, public InspectorInspectorBackendDispatcherHandler {
WTF_MAKE_NONCOPYABLE(InspectorAgent);
public:
static PassOwnPtr<InspectorAgent> create(InstrumentingAgents* instrumentingAgents)
{
return adoptPtr(new InspectorAgent(instrumentingAgents));
}
static PassOwnPtr<InspectorAgent> create() { return adoptPtr(new InspectorAgent); }
virtual ~InspectorAgent();
// Inspector front-end API.
void enable(ErrorString*);
void disable(ErrorString*);
virtual void didCreateFrontendAndBackend(Inspector::InspectorFrontendChannel*, Inspector::InspectorBackendDispatcher*) OVERRIDE;
virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
virtual void willDestroyFrontendAndBackend() OVERRIDE;
// Generic code called from custom implementations.
void evaluateForTestInFrontend(long testCallId, const String& script);
virtual void enable(ErrorString*) OVERRIDE;
virtual void disable(ErrorString*) OVERRIDE;
void inspect(PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<Inspector::InspectorObject> hints);
void inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints);
void evaluateForTestInFrontend(long testCallId, const String& script);
private:
InspectorAgent(InstrumentingAgents*);
InspectorAgent();
std::unique_ptr<Inspector::InspectorInspectorFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::InspectorInspectorBackendDispatcher> m_backendDispatcher;
std::unique_ptr<InspectorInspectorFrontendDispatcher> m_frontendDispatcher;
RefPtr<InspectorInspectorBackendDispatcher> m_backendDispatcher;
Vector<std::pair<long, String>> m_pendingEvaluateTestCommands;
std::pair<RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>, RefPtr<Inspector::InspectorObject>> m_pendingInspectData;
std::pair<RefPtr<TypeBuilder::Runtime::RemoteObject>, RefPtr<InspectorObject>> m_pendingInspectData;
bool m_enabled;
};
} // namespace WebCore
} // namespace Inspector
#endif // !defined(InspectorAgent_h)
......@@ -28,6 +28,7 @@
#if ENABLE(REMOTE_INSPECTOR)
#include "APIShims.h"
#include "InspectorFrontendChannel.h"
#include "JSGlobalObject.h"
#include "RemoteInspector.h"
......@@ -41,29 +42,40 @@ JSGlobalObjectDebuggable::JSGlobalObjectDebuggable(JSGlobalObject& globalObject)
{
}
JSGlobalObjectDebuggable::~JSGlobalObjectDebuggable()
{
if (m_inspectorController)
disconnect();
}
String JSGlobalObjectDebuggable::name() const
{
String name = m_globalObject.name();
return name.isEmpty() ? ASCIILiteral("JSContext") : name;
}
void JSGlobalObjectDebuggable::connect(InspectorFrontendChannel*)
void JSGlobalObjectDebuggable::connect(InspectorFrontendChannel* frontendChannel)
{
// FIXME: Implement.
// Create an InspectorController, InspectorFrontend, InspectorBackend, and Agents.
// "InspectorController::connectFrontend".
APIEntryShim entryShim(&m_globalObject.vm());
ASSERT(!m_inspectorController);
m_inspectorController = std::make_unique<Inspector::JSGlobalObjectInspectorController>(m_globalObject);
m_inspectorController->connectFrontend(frontendChannel);
}
void JSGlobalObjectDebuggable::disconnect()
{
// FIXME: Implement.
// "InspectorController::disconnectFrontend".
APIEntryShim entryShim(&m_globalObject.vm());
m_inspectorController->disconnectFrontend();
m_inspectorController = nullptr;
}
void JSGlobalObjectDebuggable::dispatchMessageFromRemoteFrontend(const String&)
void JSGlobalObjectDebuggable::dispatchMessageFromRemoteFrontend(const String& message)
{
// FIXME: Implement.
// "InspectorController::dispatchMessageFromFrontend"
APIEntryShim entryShim(&m_globalObject.vm());
m_inspectorController->dispatchMessageFromFrontend(message);
}
} // namespace JSC
......
......@@ -28,6 +28,7 @@
#if ENABLE(REMOTE_INSPECTOR)
#include "JSGlobalObjectInspectorController.h"
#include "RemoteInspectorDebuggable.h"
#include <wtf/Noncopyable.h>
......@@ -39,7 +40,7 @@ class JSGlobalObjectDebuggable FINAL : public Inspector::RemoteInspectorDebuggab
WTF_MAKE_NONCOPYABLE(JSGlobalObjectDebuggable);
public:
JSGlobalObjectDebuggable(JSGlobalObject&);
~JSGlobalObjectDebuggable() { }
~JSGlobalObjectDebuggable();
virtual Inspector::RemoteInspectorDebuggable::DebuggableType type() const OVERRIDE { return Inspector::RemoteInspectorDebuggable::JavaScript; }
......@@ -52,6 +53,7 @@ public:
private:
JSGlobalObject& m_globalObject;
std::unique_ptr<Inspector::JSGlobalObjectInspectorController> m_inspectorController;
};
} // namespace JSC
......
......@@ -1585,7 +1585,6 @@ set(WebCore_SOURCES
inspector/DOMPatchSupport.cpp
inspector/IdentifiersFactory.cpp
inspector/InjectedScriptCanvasModule.cpp
inspector/InspectorAgent.cpp
inspector/InspectorApplicationCacheAgent.cpp
inspector/InspectorCSSAgent.cpp
inspector/InspectorCanvasAgent.cpp
......
2014-01-10 Joseph Pecoraro <pecoraro@apple.com>
Web Inspector: Push InspectorAgent down into JSC, give JSC an InspectorController
https://bugs.webkit.org/show_bug.cgi?id=126763