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

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

Issue 2127423003: DevTools: Switch V8ProfilerAgent to use v8::CpuProfiler::New API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b09f4f55ee24bf0025cfcd6e9ed3ff3a3b93b822..6e7016b0da64dd82f61d91cea7c911ba2f14bac2 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp
@@ -126,6 +126,7 @@ public:
V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
: m_session(session)
, m_isolate(m_session->debugger()->isolate())
+ , m_profiler(nullptr)
, m_state(state)
, m_frontend(frontendChannel)
, m_enabled(false)
@@ -135,6 +136,10 @@ V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protoc
V8ProfilerAgentImpl::~V8ProfilerAgentImpl()
{
+#if V8_MAJOR_VERSION * 100 + V8_MINOR_VERSION >= 504
pfeldman 2016/07/08 19:10:08 I'd rather that we hold off deprecation before v8
alph 2016/07/08 19:22:10 It landed today. What's wrong with deprecation? Th
+ if (m_profiler)
+ m_profiler->Dispose();
+#endif
}
void V8ProfilerAgentImpl::consoleProfile(const String16& title)
@@ -184,6 +189,10 @@ void V8ProfilerAgentImpl::enable(ErrorString*)
if (m_enabled)
return;
m_enabled = true;
+#if V8_MAJOR_VERSION * 100 + V8_MINOR_VERSION >= 504
+ DCHECK(!m_profiler);
+ m_profiler = v8::CpuProfiler::New(m_isolate);
+#endif
m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
m_session->changeInstrumentationCounter(+1);
}
@@ -197,6 +206,10 @@ void V8ProfilerAgentImpl::disable(ErrorString* errorString)
stopProfiling(m_startedProfiles[i - 1].m_id, false);
m_startedProfiles.clear();
stop(nullptr, nullptr);
+#if V8_MAJOR_VERSION * 100 + V8_MINOR_VERSION >= 504
+ m_profiler->Dispose();
+ m_profiler = nullptr;
+#endif
m_enabled = false;
m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
}
@@ -208,7 +221,7 @@ void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval)
return;
}
m_state->setNumber(ProfilerAgentState::samplingInterval, interval);
- m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
+ profiler()->SetSamplingInterval(interval);
}
void V8ProfilerAgentImpl::restore()
@@ -221,7 +234,7 @@ void V8ProfilerAgentImpl::restore()
int interval = 0;
m_state->getNumber(ProfilerAgentState::samplingInterval, &interval);
if (interval)
- m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
+ profiler()->SetSamplingInterval(interval);
if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, false)) {
ErrorString error;
start(&error);
@@ -270,13 +283,13 @@ String16 V8ProfilerAgentImpl::nextProfileId()
void V8ProfilerAgentImpl::startProfiling(const String16& title)
{
v8::HandleScope handleScope(m_isolate);
- m_isolate->GetCpuProfiler()->StartProfiling(toV8String(m_isolate, title), true);
+ profiler()->StartProfiling(toV8String(m_isolate, title), true);
}
std::unique_ptr<protocol::Profiler::CPUProfile> V8ProfilerAgentImpl::stopProfiling(const String16& title, bool serialize)
{
v8::HandleScope handleScope(m_isolate);
- v8::CpuProfile* profile = m_isolate->GetCpuProfiler()->StopProfiling(toV8String(m_isolate, title));
+ v8::CpuProfile* profile = profiler()->StopProfiling(toV8String(m_isolate, title));
if (!profile)
return nullptr;
std::unique_ptr<protocol::Profiler::CPUProfile> result;
@@ -291,4 +304,13 @@ bool V8ProfilerAgentImpl::isRecording() const
return m_recordingCPUProfile || !m_startedProfiles.empty();
}
+v8::CpuProfiler* V8ProfilerAgentImpl::profiler()
+{
+#if V8_MAJOR_VERSION * 100 + V8_MINOR_VERSION >= 504
+ return m_profiler;
+#else
+ return m_isolate->GetCpuProfiler();
+#endif
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698