diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp')
-rw-r--r-- | Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp | 95 |
1 files changed, 65 insertions, 30 deletions
diff --git a/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp index fcee46e9d..f64baf3d3 100644 --- a/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp +++ b/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2007-2010, 2015 Apple Inc. All rights reserved. * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> * Copyright (C) 2011 Google Inc. All rights reserved. * @@ -12,7 +12,7 @@ * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -31,18 +31,18 @@ #include "config.h" #include "InspectorAgent.h" -#if ENABLE(INSPECTOR) - +#include "InspectorEnvironment.h" +#include "InspectorFrontendRouter.h" #include "InspectorValues.h" #include "ScriptValue.h" -#include <wtf/PassRefPtr.h> -#include <wtf/RefPtr.h> namespace Inspector { -InspectorAgent::InspectorAgent() +InspectorAgent::InspectorAgent(AgentContext& context) : InspectorAgentBase(ASCIILiteral("Inspector")) - , m_enabled(false) + , m_environment(context.environment) + , m_frontendDispatcher(std::make_unique<InspectorFrontendDispatcher>(context.frontendRouter)) + , m_backendDispatcher(InspectorBackendDispatcher::create(context.backendDispatcher, this)) { } @@ -50,43 +50,49 @@ InspectorAgent::~InspectorAgent() { } -void InspectorAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher) +void InspectorAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) { - m_frontendDispatcher = std::make_unique<InspectorInspectorFrontendDispatcher>(frontendChannel); - m_backendDispatcher = InspectorInspectorBackendDispatcher::create(backendDispatcher, this); } -void InspectorAgent::willDestroyFrontendAndBackend(InspectorDisconnectReason) +void InspectorAgent::willDestroyFrontendAndBackend(DisconnectReason) { - m_frontendDispatcher = nullptr; - m_backendDispatcher.clear(); - m_pendingEvaluateTestCommands.clear(); - ErrorString error; - disable(&error); + ErrorString unused; + disable(unused); } -void InspectorAgent::enable(ErrorString*) +void InspectorAgent::enable(ErrorString&) { m_enabled = true; if (m_pendingInspectData.first) - inspect(m_pendingInspectData.first, m_pendingInspectData.second); + inspect(m_pendingInspectData.first.copyRef(), m_pendingInspectData.second.copyRef()); + +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) + if (m_pendingExtraDomainsData) + m_frontendDispatcher->activateExtraDomains(m_pendingExtraDomainsData); +#endif + + for (auto& testCommand : m_pendingEvaluateTestCommands) + m_frontendDispatcher->evaluateForTestInFrontend(testCommand); - for (Vector<std::pair<long, String>>::iterator it = m_pendingEvaluateTestCommands.begin(); m_frontendDispatcher && it != m_pendingEvaluateTestCommands.end(); ++it) - m_frontendDispatcher->evaluateForTestInFrontend(static_cast<int>((*it).first), (*it).second); m_pendingEvaluateTestCommands.clear(); } -void InspectorAgent::disable(ErrorString*) +void InspectorAgent::disable(ErrorString&) { m_enabled = false; } -void InspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints) +void InspectorAgent::initialized(ErrorString&) { - if (m_enabled && m_frontendDispatcher) { + m_environment.frontendInitialized(); +} + +void InspectorAgent::inspect(RefPtr<Protocol::Runtime::RemoteObject>&& objectToInspect, RefPtr<InspectorObject>&& hints) +{ + if (m_enabled) { m_frontendDispatcher->inspect(objectToInspect, hints); m_pendingInspectData.first = nullptr; m_pendingInspectData.second = nullptr; @@ -97,14 +103,43 @@ void InspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> obje m_pendingInspectData.second = hints; } -void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script) +void InspectorAgent::evaluateForTestInFrontend(const String& script) { - if (m_enabled && m_frontendDispatcher) - m_frontendDispatcher->evaluateForTestInFrontend(static_cast<int>(callId), script); + if (m_enabled) + m_frontendDispatcher->evaluateForTestInFrontend(script); else - m_pendingEvaluateTestCommands.append(std::pair<long, String>(callId, script)); + m_pendingEvaluateTestCommands.append(script); } -} // namespace Inspector +#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS) +void InspectorAgent::activateExtraDomain(const String& domainName) +{ + if (!m_enabled) { + if (!m_pendingExtraDomainsData) + m_pendingExtraDomainsData = Inspector::Protocol::Array<String>::create(); + m_pendingExtraDomainsData->addItem(domainName); + return; + } -#endif // ENABLE(INSPECTOR) + auto domainNames = Inspector::Protocol::Array<String>::create(); + domainNames->addItem(domainName); + m_frontendDispatcher->activateExtraDomains(WTFMove(domainNames)); +} + +void InspectorAgent::activateExtraDomains(const Vector<String>& extraDomains) +{ + if (extraDomains.isEmpty()) + return; + + auto domainNames = Inspector::Protocol::Array<String>::create(); + for (auto domainName : extraDomains) + domainNames->addItem(domainName); + + if (!m_enabled) + m_pendingExtraDomainsData = WTFMove(domainNames); + else + m_frontendDispatcher->activateExtraDomains(WTFMove(domainNames)); +} +#endif + +} // namespace Inspector |