Skip to content

Commit

Permalink
[DevTools] Move v8-related instrumentation from agents to InspectorSe…
Browse files Browse the repository at this point in the history
…ssion.

Added V8InspectorSessionClient which gets notified when instrumentation
should start and stop.

BUG=590878,580337

Review URL: https://codereview.chromium.org/1907663005

Cr-Commit-Position: refs/heads/master@{#389556}
  • Loading branch information
dgozman authored and Commit bot committed Apr 25, 2016
1 parent e481a6c commit 821ac29
Show file tree
Hide file tree
Showing 24 changed files with 275 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ def generate_param_name(param_type):


def agent_class_name(agent):
if agent == "V8":
return "InspectorSession"
custom_agent_names = ["PageDebugger", "PageRuntime", "WorkerRuntime", "PageConsole"]
if agent in custom_agent_names:
return "%sAgent" % agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ DEFINE_TRACE(InspectorDebuggerAgent)
void InspectorDebuggerAgent::enable(ErrorString* errorString)
{
m_v8DebuggerAgent->enable(errorString);
m_instrumentingAgents->setInspectorDebuggerAgent(this);
m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true);
}

void InspectorDebuggerAgent::disable(ErrorString* errorString)
{
m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false);
m_instrumentingAgents->setInspectorDebuggerAgent(nullptr);
m_v8DebuggerAgent->disable(errorString);
}

Expand Down Expand Up @@ -257,43 +255,6 @@ void InspectorDebuggerAgent::setBlackboxedRanges(
m_v8DebuggerAgent->setBlackboxedRanges(errorString, inScriptId, std::move(inPositions));
}

void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText)
{
OwnPtr<protocol::DictionaryValue> directive = protocol::DictionaryValue::create();
directive->setString("directiveText", directiveText);
m_v8DebuggerAgent->breakProgramOnException(protocol::Debugger::Paused::ReasonEnum::CSPViolation, directive.release());
}

void InspectorDebuggerAgent::asyncTaskScheduled(const String& taskName, void* task)
{
m_v8DebuggerAgent->asyncTaskScheduled(taskName, task, false);
}

void InspectorDebuggerAgent::asyncTaskScheduled(const String& operationName, void* task, bool recurring)
{
m_v8DebuggerAgent->asyncTaskScheduled(operationName, task, recurring);
}

void InspectorDebuggerAgent::asyncTaskCanceled(void* task)
{
m_v8DebuggerAgent->asyncTaskCanceled(task);
}

void InspectorDebuggerAgent::allAsyncTasksCanceled()
{
m_v8DebuggerAgent->allAsyncTasksCanceled();
}

void InspectorDebuggerAgent::asyncTaskStarted(void* task)
{
m_v8DebuggerAgent->asyncTaskStarted(task);
}

void InspectorDebuggerAgent::asyncTaskFinished(void* task)
{
m_v8DebuggerAgent->asyncTaskFinished(task);
}

// InspectorBaseAgent overrides.
void InspectorDebuggerAgent::init(InstrumentingAgents* instrumentingAgents, protocol::Frontend* baseFrontend, protocol::Dispatcher* dispatcher, protocol::DictionaryValue* state)
{
Expand Down
11 changes: 0 additions & 11 deletions third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ class CORE_EXPORT InspectorDebuggerAgent
void setBlackboxPatterns(ErrorString*, PassOwnPtr<protocol::Array<String16>> patterns) override;
void setBlackboxedRanges(ErrorString*, const String16& scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> positions) override;

// Called by InspectorInstrumentation.
void scriptExecutionBlockedByCSP(const String& directiveText);

// Async stack implementation.
void asyncTaskScheduled(const String& taskName, void* task);
void asyncTaskScheduled(const String& taskName, void* task, bool recurring);
void asyncTaskCanceled(void* task);
void allAsyncTasksCanceled();
void asyncTaskStarted(void* task);
void asyncTaskFinished(void* task);

// InspectorBaseAgent overrides.
void init(InstrumentingAgents*, protocol::Frontend*, protocol::Dispatcher*, protocol::DictionaryValue*) override;
void dispose() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ AsyncTask::AsyncTask(ExecutionContext* context, void* task, bool enabled)
if (!m_instrumentingSessions || m_instrumentingSessions->isEmpty())
return;
for (InspectorSession* session : *m_instrumentingSessions) {
if (session->instrumentingAgents()->inspectorDebuggerAgent())
session->instrumentingAgents()->inspectorDebuggerAgent()->asyncTaskStarted(m_task);
if (session->instrumentingAgents()->inspectorSession())
session->instrumentingAgents()->inspectorSession()->asyncTaskStarted(m_task);
}
}

Expand All @@ -83,8 +83,8 @@ AsyncTask::~AsyncTask()
if (!m_instrumentingSessions || m_instrumentingSessions->isEmpty())
return;
for (InspectorSession* session : *m_instrumentingSessions) {
if (session->instrumentingAgents()->inspectorDebuggerAgent())
session->instrumentingAgents()->inspectorDebuggerAgent()->asyncTaskFinished(m_task);
if (session->instrumentingAgents()->inspectorSession())
session->instrumentingAgents()->inspectorSession()->asyncTaskFinished(m_task);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class WorkerInspectorProxy;
class XMLHttpRequest;

// We should call PageDebuggerAgent method first otherwise this method resets script cache and removes scripts executed by other agents.
[PageRuntime, Page, Animation]
[V8, Page, Animation]
void didClearDocumentOfWindowObject([Keep] LocalFrame*);

[DOMDebugger]
Expand Down Expand Up @@ -206,13 +206,13 @@ class XMLHttpRequest;
[Resource]
void scriptImported(ExecutionContext*, unsigned long identifier, const String& sourceString);

[Debugger]
[V8]
void scriptExecutionBlockedByCSP(ExecutionContext*, const String& directiveText);

[Resource]
void didReceiveScriptResponse(ExecutionContext*, unsigned long identifier);

[PageDebugger]
[V8]
void didStartProvisionalLoad([Keep] LocalFrame*);

[DOM, Page]
Expand Down Expand Up @@ -257,17 +257,23 @@ class XMLHttpRequest;
[Worker, PageConsole]
void workerTerminated(ExecutionContext*, WorkerInspectorProxy* proxy);

[Profiler]
void willProcessTask(WorkerGlobalScope* context);
[V8]
void willProcessTask(WorkerGlobalScope*);

[Profiler]
void didProcessTask(WorkerGlobalScope* context);
[V8]
void didProcessTask(WorkerGlobalScope*);

[Profiler]
void willEnterNestedRunLoop(WorkerGlobalScope* context);
[V8]
void willProcessTask(LocalFrame*);

[Profiler]
void didLeaveNestedRunLoop(WorkerGlobalScope* context);
[V8]
void didProcessTask(LocalFrame*);

[V8]
void willEnterNestedRunLoop(WorkerGlobalScope*);

[V8]
void didLeaveNestedRunLoop(WorkerGlobalScope*);

[Resource]
void didCreateWebSocket([Keep] Document*, unsigned long identifier, const KURL& requestURL, const String& protocol);
Expand Down Expand Up @@ -305,16 +311,16 @@ class XMLHttpRequest;
[DOM]
void pseudoElementDestroyed([Keep] PseudoElement*);

[Debugger]
[V8]
void asyncTaskScheduled(ExecutionContext*, const String& name, void*);

[Debugger]
[V8]
void asyncTaskScheduled(ExecutionContext*, const String& name, void*, bool recurring);

[Debugger]
[V8]
void asyncTaskCanceled(ExecutionContext*, void*);

[Debugger]
[V8]
void allAsyncTasksCanceled(ExecutionContext*);

[Animation]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include "bindings/core/v8/ScriptCallStack.h"
#include "bindings/core/v8/V8Binding.h"
#include "core/frame/UseCounter.h"
#include "platform/v8_inspector/public/V8ProfilerAgent.h"

namespace blink {
Expand Down Expand Up @@ -83,12 +82,10 @@ void InspectorProfilerAgent::enable(ErrorString* errorString)
{
m_v8ProfilerAgent->enable(errorString);
m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
m_instrumentingAgents->setInspectorProfilerAgent(this);
}

void InspectorProfilerAgent::disable(ErrorString* errorString)
{
m_instrumentingAgents->setInspectorProfilerAgent(nullptr);
m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
m_v8ProfilerAgent->disable(errorString);
}
Expand All @@ -112,26 +109,6 @@ void InspectorProfilerAgent::stop(ErrorString* errorString, OwnPtr<protocol::Pro
m_v8ProfilerAgent->stop(errorString, profile);
}

void InspectorProfilerAgent::willProcessTask()
{
m_v8ProfilerAgent->idleFinished();
}

void InspectorProfilerAgent::didProcessTask()
{
m_v8ProfilerAgent->idleStarted();
}

void InspectorProfilerAgent::willEnterNestedRunLoop()
{
m_v8ProfilerAgent->idleStarted();
}

void InspectorProfilerAgent::didLeaveNestedRunLoop()
{
m_v8ProfilerAgent->idleFinished();
}

DEFINE_TRACE(InspectorProfilerAgent)
{
InspectorBaseAgent::trace(visitor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ class CORE_EXPORT InspectorProfilerAgent final : public InspectorBaseAgent<Inspe
void start(ErrorString*) override;
void stop(ErrorString*, OwnPtr<protocol::Profiler::CPUProfile>*) override;

void willProcessTask();
void didProcessTask();
void willEnterNestedRunLoop();
void didLeaveNestedRunLoop();

private:
InspectorProfilerAgent(V8ProfilerAgent*, Client*);

Expand Down
Loading

0 comments on commit 821ac29

Please sign in to comment.