summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp')
-rw-r--r--Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp95
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