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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorSession.cpp

Issue 1907663005: [DevTools] Move v8-related instrumentation from agents to InspectorSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1889533002
Patch Set: profiler agent restore starts instrumenting Created 4 years, 8 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/core/inspector/InspectorSession.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorSession.cpp b/third_party/WebKit/Source/core/inspector/InspectorSession.cpp
index 83d0445537357082ddc3f49eac07178d5fe08c2d..762fa10641d9f41a74237a096acbfd0ec17d4a0c 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorSession.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorSession.cpp
@@ -4,20 +4,30 @@
#include "core/inspector/InspectorSession.h"
+#include "bindings/core/v8/ScriptController.h"
#include "core/InstrumentingAgents.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/UseCounter.h"
+#include "core/inspector/InspectedFrames.h"
#include "core/inspector/InspectorBaseAgent.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "platform/inspector_protocol/Backend.h"
#include "platform/inspector_protocol/Parser.h"
#include "platform/inspector_protocol/TypeBuilder.h"
+#include "platform/v8_inspector/public/V8DebuggerAgent.h"
+#include "platform/v8_inspector/public/V8InspectorSession.h"
+#include "platform/v8_inspector/public/V8ProfilerAgent.h"
+#include "platform/v8_inspector/public/V8RuntimeAgent.h"
namespace blink {
-InspectorSession::InspectorSession(Client* client, int sessionId, bool autoFlush)
+InspectorSession::InspectorSession(Client* client, InspectedFrames* inspectedFrames, int sessionId, bool autoFlush)
: m_client(client)
+ , m_v8Session(nullptr)
, m_sessionId(sessionId)
, m_autoFlush(autoFlush)
, m_attached(false)
+ , m_inspectedFrames(inspectedFrames)
, m_instrumentingAgents(new InstrumentingAgents())
, m_inspectorFrontend(adoptPtr(new protocol::Frontend(this)))
, m_inspectorBackendDispatcher(protocol::Dispatcher::create(this))
@@ -29,10 +39,12 @@ void InspectorSession::append(InspectorAgent* agent)
m_agents.append(agent);
}
-void InspectorSession::attach(const String* savedState)
+void InspectorSession::attach(V8InspectorSession* v8Session, const String* savedState)
{
ASSERT(!m_attached);
m_attached = true;
+ m_v8Session = v8Session;
+ m_v8Session->setClient(this);
InspectorInstrumentation::frontendCreated();
bool restore = savedState;
@@ -59,13 +71,15 @@ void InspectorSession::detach()
{
ASSERT(m_attached);
m_attached = false;
-
m_inspectorBackendDispatcher->clearFrontend();
m_inspectorBackendDispatcher.clear();
for (size_t i = m_agents.size(); i > 0; i--)
m_agents[i - 1]->dispose();
m_inspectorFrontend.clear();
m_agents.clear();
+ m_v8Session->setClient(nullptr);
+ m_v8Session = nullptr;
+ ASSERT(!isInstrumenting());
InspectorInstrumentation::frontendDeleted();
}
@@ -120,9 +134,123 @@ void InspectorSession::flushPendingProtocolNotifications()
m_notificationQueue.clear();
}
+void InspectorSession::scriptExecutionBlockedByCSP(const String& directiveText)
+{
+ ASSERT(isInstrumenting());
+ OwnPtr<protocol::DictionaryValue> directive = protocol::DictionaryValue::create();
+ directive->setString("directiveText", directiveText);
+ m_v8Session->debuggerAgent()->breakProgramOnException(protocol::Debugger::Paused::ReasonEnum::CSPViolation, directive.release());
+}
+
+void InspectorSession::asyncTaskScheduled(const String& taskName, void* task)
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->debuggerAgent()->asyncTaskScheduled(taskName, task, false);
+}
+
+void InspectorSession::asyncTaskScheduled(const String& operationName, void* task, bool recurring)
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->debuggerAgent()->asyncTaskScheduled(operationName, task, recurring);
+}
+
+void InspectorSession::asyncTaskCanceled(void* task)
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->debuggerAgent()->asyncTaskCanceled(task);
+}
+
+void InspectorSession::allAsyncTasksCanceled()
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->debuggerAgent()->allAsyncTasksCanceled();
+}
+
+void InspectorSession::asyncTaskStarted(void* task)
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->debuggerAgent()->asyncTaskStarted(task);
+}
+
+void InspectorSession::asyncTaskFinished(void* task)
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->debuggerAgent()->asyncTaskFinished(task);
+}
+
+void InspectorSession::didStartProvisionalLoad(LocalFrame* frame)
+{
+ ASSERT(isInstrumenting());
+ if (m_inspectedFrames && m_inspectedFrames->root() == frame) {
+ ErrorString error;
+ m_v8Session->debuggerAgent()->resume(&error);
+ }
+}
+
+void InspectorSession::didClearDocumentOfWindowObject(LocalFrame* frame)
+{
+ ASSERT(isInstrumenting());
+ frame->script().initializeMainWorld();
+}
+
+void InspectorSession::willProcessTask()
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->profilerAgent()->idleFinished();
+}
+
+void InspectorSession::didProcessTask()
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->profilerAgent()->idleStarted();
+}
+
+void InspectorSession::willEnterNestedRunLoop()
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->profilerAgent()->idleStarted();
+}
+
+void InspectorSession::didLeaveNestedRunLoop()
+{
+ ASSERT(isInstrumenting());
+ m_v8Session->profilerAgent()->idleFinished();
+}
+
+void InspectorSession::startInstrumenting()
+{
+ ASSERT(!isInstrumenting());
+ m_instrumentingAgents->setInspectorSession(this);
+ forceContextsInAllFrames();
+}
+
+void InspectorSession::stopInstrumenting()
+{
+ ASSERT(isInstrumenting());
+ m_instrumentingAgents->setInspectorSession(nullptr);
+}
+
+void InspectorSession::forceContextsInAllFrames()
+{
+ if (!m_inspectedFrames)
+ return;
+ if (!m_inspectedFrames->root()->loader().stateMachine()->committedFirstRealDocumentLoad())
+ return;
+ for (const LocalFrame* frame : *m_inspectedFrames)
+ frame->script().initializeMainWorld();
+}
+
+#if ENABLE(ASSERT)
+bool InspectorSession::isInstrumenting()
+{
+ return m_instrumentingAgents->inspectorSession() == this;
+}
+#endif
+
DEFINE_TRACE(InspectorSession)
{
visitor->trace(m_instrumentingAgents);
+ visitor->trace(m_inspectedFrames);
visitor->trace(m_agents);
}

Powered by Google App Engine
This is Rietveld 408576698