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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.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/platform/v8_inspector/V8ProfilerAgentImpl.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp
index c1604f8fb8a85f7af5368701c368dbd74624ab48..631d080844c2fc4b39d87e981ae9e0064610149b 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp
@@ -121,8 +121,8 @@ public:
};
V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session)
- : m_debugger(session->debugger())
- , m_isolate(m_debugger->isolate())
+ : m_session(session)
+ , m_isolate(m_session->debugger()->isolate())
, m_state(nullptr)
, m_frontend(nullptr)
, m_enabled(false)
@@ -136,16 +136,20 @@ V8ProfilerAgentImpl::~V8ProfilerAgentImpl()
void V8ProfilerAgentImpl::consoleProfile(const String16& title)
{
- ASSERT(m_frontend && m_enabled);
+ if (!m_enabled)
+ return;
+ ASSERT(m_frontend);
String16 id = nextProfileId();
m_startedProfiles.append(ProfileDescriptor(id, title));
startProfiling(id);
- m_frontend->consoleProfileStarted(id, currentDebugLocation(m_debugger), title);
+ m_frontend->consoleProfileStarted(id, currentDebugLocation(m_session->debugger()), title);
}
void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
{
- ASSERT(m_frontend && m_enabled);
+ if (!m_enabled)
+ return;
+ ASSERT(m_frontend);
String16 id;
String16 resolvedTitle;
// Take last started profile if no title was passed.
@@ -170,17 +174,23 @@ void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
OwnPtr<protocol::Profiler::CPUProfile> profile = stopProfiling(id, true);
if (!profile)
return;
- OwnPtr<protocol::Debugger::Location> location = currentDebugLocation(m_debugger);
+ OwnPtr<protocol::Debugger::Location> location = currentDebugLocation(m_session->debugger());
m_frontend->consoleProfileFinished(id, location.release(), profile.release(), resolvedTitle);
}
void V8ProfilerAgentImpl::enable(ErrorString*)
{
+ if (m_enabled)
+ return;
m_enabled = true;
+ m_session->changeInstrumentationCounter(+1);
}
void V8ProfilerAgentImpl::disable(ErrorString* errorString)
{
+ if (!m_enabled)
+ return;
+ m_session->changeInstrumentationCounter(-1);
for (size_t i = m_startedProfiles.size(); i > 0; --i)
stopProfiling(m_startedProfiles[i - 1].m_id, false);
m_startedProfiles.clear();
@@ -208,7 +218,9 @@ void V8ProfilerAgentImpl::clearFrontend()
void V8ProfilerAgentImpl::restore()
{
+ ASSERT(!m_enabled);
m_enabled = true;
+ m_session->changeInstrumentationCounter(+1);
int interval = 0;
m_state->getNumber(ProfilerAgentState::samplingInterval, &interval);
if (interval)

Powered by Google App Engine
This is Rietveld 408576698