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

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: rebaseline 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 0761f87e0d7a26b0fd933f4c0805a38ab1f8488e..719f98248fcba56dff12b24462a812fe6b434621 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp
@@ -13,6 +13,9 @@
#include <vector>
+#define ENSURE_V8_VERSION(major, minor) \
+ (V8_MAJOR_VERSION * 1000 + V8_MINOR_VERSION >= (major) * 1000 + (minor))
+
namespace blink {
namespace ProfilerAgentState {
@@ -128,6 +131,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)
@@ -137,6 +141,10 @@ V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protoc
V8ProfilerAgentImpl::~V8ProfilerAgentImpl()
{
+#if ENSURE_V8_VERSION(5, 4)
+ if (m_profiler)
+ m_profiler->Dispose();
+#endif
}
void V8ProfilerAgentImpl::consoleProfile(const String16& title)
@@ -186,6 +194,10 @@ void V8ProfilerAgentImpl::enable(ErrorString*)
if (m_enabled)
return;
m_enabled = true;
+#if ENSURE_V8_VERSION(5, 4)
+ DCHECK(!m_profiler);
+ m_profiler = v8::CpuProfiler::New(m_isolate);
+#endif
m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
}
@@ -197,6 +209,10 @@ void V8ProfilerAgentImpl::disable(ErrorString* errorString)
stopProfiling(m_startedProfiles[i - 1].m_id, false);
m_startedProfiles.clear();
stop(nullptr, nullptr);
+#if ENSURE_V8_VERSION(5, 4)
+ m_profiler->Dispose();
+ m_profiler = nullptr;
+#endif
m_enabled = false;
m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
}
@@ -208,7 +224,7 @@ void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval)
return;
}
m_state->setInteger(ProfilerAgentState::samplingInterval, interval);
- m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
+ profiler()->SetSamplingInterval(interval);
}
void V8ProfilerAgentImpl::restore()
@@ -217,10 +233,14 @@ void V8ProfilerAgentImpl::restore()
if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false))
return;
m_enabled = true;
+#if ENSURE_V8_VERSION(5, 4)
+ DCHECK(!m_profiler);
+ m_profiler = v8::CpuProfiler::New(m_isolate);
+#endif
int interval = 0;
m_state->getInteger(ProfilerAgentState::samplingInterval, &interval);
if (interval)
- m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
+ profiler()->SetSamplingInterval(interval);
if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, false)) {
ErrorString error;
start(&error);
@@ -269,13 +289,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;
@@ -290,4 +310,13 @@ bool V8ProfilerAgentImpl::isRecording() const
return m_recordingCPUProfile || !m_startedProfiles.empty();
}
+v8::CpuProfiler* V8ProfilerAgentImpl::profiler()
+{
+#if ENSURE_V8_VERSION(5, 4)
+ 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