Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp

Issue 1967933002: [DevTools] Dispatch messages to V8InspectorSession directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1936593002
Patch Set: rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp
index c728f9e2ff594f70ef684ed3f2ef71d8f358a12d..0f93696384ec6b27cfcaeb6de5406bba2ece075e 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp
@@ -4,6 +4,7 @@
#include "platform/v8_inspector/V8InspectorSessionImpl.h"
+#include "platform/inspector_protocol/Parser.h"
#include "platform/v8_inspector/InjectedScript.h"
#include "platform/v8_inspector/InspectedContext.h"
#include "platform/v8_inspector/RemoteObjectId.h"
@@ -19,53 +20,86 @@ namespace blink {
const char V8InspectorSession::backtraceObjectGroup[] = "backtrace";
-PassOwnPtr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8DebuggerImpl* debugger, int contextGroupId)
+// static
+bool V8InspectorSession::isV8ProtocolMethod(const String16& method)
{
- return adoptPtr(new V8InspectorSessionImpl(debugger, contextGroupId));
+ return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime.");
}
-V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int contextGroupId)
+PassOwnPtr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8DebuggerImpl* debugger, int contextGroupId, V8InspectorSessionClient* client, const String16* state)
+{
+ return adoptPtr(new V8InspectorSessionImpl(debugger, contextGroupId, client, state));
+}
+
+V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int contextGroupId, V8InspectorSessionClient* client, const String16* savedState)
: m_contextGroupId(contextGroupId)
, m_debugger(debugger)
- , m_client(nullptr)
+ , m_client(client)
, m_customObjectFormatterEnabled(false)
, m_instrumentationCounter(0)
- , m_runtimeAgent(adoptPtr(new V8RuntimeAgentImpl(this)))
- , m_debuggerAgent(adoptPtr(new V8DebuggerAgentImpl(this)))
- , m_heapProfilerAgent(adoptPtr(new V8HeapProfilerAgentImpl(this)))
- , m_profilerAgent(adoptPtr(new V8ProfilerAgentImpl(this)))
+ , m_frontend(adoptPtr(new protocol::Frontend(client)))
+ , m_dispatcher(protocol::Dispatcher::create(client))
+ , m_state(nullptr)
+ , m_runtimeAgent(nullptr)
+ , m_debuggerAgent(nullptr)
+ , m_heapProfilerAgent(nullptr)
+ , m_profilerAgent(nullptr)
{
-}
+ if (savedState) {
+ OwnPtr<protocol::Value> state = protocol::parseJSON(*savedState);
+ if (state)
+ m_state = protocol::DictionaryValue::cast(std::move(state));
+ if (!m_state)
+ m_state = protocol::DictionaryValue::create();
+ } else {
+ m_state = protocol::DictionaryValue::create();
+ }
-V8InspectorSessionImpl::~V8InspectorSessionImpl()
-{
- discardInjectedScripts();
- m_debugger->disconnect(this);
-}
+ m_runtimeAgent = adoptPtr(new V8RuntimeAgentImpl(this, protocol::Frontend::Runtime::from(m_frontend.get()), agentState("Runtime")));
+ m_dispatcher->registerAgent(static_cast<protocol::Backend::Runtime*>(m_runtimeAgent.get()));
-V8DebuggerAgent* V8InspectorSessionImpl::debuggerAgent()
-{
- return m_debuggerAgent.get();
-}
+ m_debuggerAgent = adoptPtr(new V8DebuggerAgentImpl(this, protocol::Frontend::Debugger::from(m_frontend.get()), agentState("Debugger")));
+ m_dispatcher->registerAgent(static_cast<protocol::Backend::Debugger*>(m_debuggerAgent.get()));
-V8HeapProfilerAgent* V8InspectorSessionImpl::heapProfilerAgent()
-{
- return m_heapProfilerAgent.get();
-}
+ m_heapProfilerAgent = adoptPtr(new V8HeapProfilerAgentImpl(this, protocol::Frontend::HeapProfiler::from(m_frontend.get()), agentState("HeapProfiler")));
+ m_dispatcher->registerAgent(static_cast<protocol::Backend::HeapProfiler*>(m_heapProfilerAgent.get()));
-V8ProfilerAgent* V8InspectorSessionImpl::profilerAgent()
-{
- return m_profilerAgent.get();
+ m_profilerAgent = adoptPtr(new V8ProfilerAgentImpl(this, protocol::Frontend::Profiler::from(m_frontend.get()), agentState("Profiler")));
+ m_dispatcher->registerAgent(static_cast<protocol::Backend::Profiler*>(m_profilerAgent.get()));
+
+ if (savedState) {
+ m_runtimeAgent->restore();
+ m_debuggerAgent->restore();
+ m_heapProfilerAgent->restore();
+ m_profilerAgent->restore();
+ }
}
-V8RuntimeAgent* V8InspectorSessionImpl::runtimeAgent()
+V8InspectorSessionImpl::~V8InspectorSessionImpl()
{
- return m_runtimeAgent.get();
+ m_dispatcher->clearFrontend();
+ m_dispatcher.clear();
+
+ ErrorString errorString;
+ m_profilerAgent->disable(&errorString);
+ m_heapProfilerAgent->disable(&errorString);
+ m_debuggerAgent->disable(&errorString);
+ m_runtimeAgent->disable(&errorString);
+
+ m_frontend.clear();
+ discardInjectedScripts();
+ m_debugger->disconnect(this);
}
-void V8InspectorSessionImpl::setClient(V8InspectorSessionClient* client)
+protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& name)
{
- m_client = client;
+ protocol::DictionaryValue* state = m_state->getObject(name);
+ if (!state) {
+ OwnPtr<protocol::DictionaryValue> newState = protocol::DictionaryValue::create();
+ state = newState.get();
+ m_state->setObject(name, std::move(newState));
+ }
+ return state;
}
void V8InspectorSessionImpl::reset()
@@ -204,13 +238,23 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent)
void V8InspectorSessionImpl::changeInstrumentationCounter(int delta)
{
DCHECK_GE(m_instrumentationCounter + delta, 0);
- if (!m_instrumentationCounter && m_client)
+ if (!m_instrumentationCounter)
m_client->startInstrumenting();
m_instrumentationCounter += delta;
- if (!m_instrumentationCounter && m_client)
+ if (!m_instrumentationCounter)
m_client->stopInstrumenting();
}
+void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message)
+{
+ m_dispatcher->dispatch(message);
+}
+
+String16 V8InspectorSessionImpl::stateJSON()
+{
+ return m_state->toJSONString();
+}
+
void V8InspectorSessionImpl::addInspectedObject(PassOwnPtr<V8InspectorSession::Inspectable> inspectable)
{
m_inspectedObjects.prepend(std::move(inspectable));
@@ -251,6 +295,18 @@ void V8InspectorSessionImpl::setSkipAllPauses(bool skip)
m_debuggerAgent->setSkipAllPauses(&errorString, skip);
}
+void V8InspectorSessionImpl::resume()
+{
+ ErrorString errorString;
+ m_debuggerAgent->resume(&errorString);
+}
+
+void V8InspectorSessionImpl::stepOver()
+{
+ ErrorString errorString;
+ m_debuggerAgent->stepOver(&errorString);
+}
+
void V8InspectorSessionImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring)
{
m_debuggerAgent->asyncTaskScheduled(taskName, task, recurring);

Powered by Google App Engine
This is Rietveld 408576698