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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.cpp

Issue 1967933002: [DevTools] Dispatch messages to V8InspectorSession directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1936593002
Patch Set: rebased Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" 5 #include "platform/v8_inspector/V8ProfilerAgentImpl.h"
6 6
7 #include "platform/v8_inspector/Atomics.h" 7 #include "platform/v8_inspector/Atomics.h"
8 #include "platform/v8_inspector/V8DebuggerImpl.h" 8 #include "platform/v8_inspector/V8DebuggerImpl.h"
9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
10 #include "platform/v8_inspector/V8StackTraceImpl.h" 10 #include "platform/v8_inspector/V8StackTraceImpl.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 class V8ProfilerAgentImpl::ProfileDescriptor { 115 class V8ProfilerAgentImpl::ProfileDescriptor {
116 public: 116 public:
117 ProfileDescriptor(const String16& id, const String16& title) 117 ProfileDescriptor(const String16& id, const String16& title)
118 : m_id(id) 118 : m_id(id)
119 , m_title(title) { } 119 , m_title(title) { }
120 String16 m_id; 120 String16 m_id;
121 String16 m_title; 121 String16 m_title;
122 }; 122 };
123 123
124 V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session) 124 V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protoc ol::Frontend::Profiler* frontend, protocol::DictionaryValue* state)
125 : m_session(session) 125 : m_session(session)
126 , m_isolate(m_session->debugger()->isolate()) 126 , m_isolate(m_session->debugger()->isolate())
127 , m_state(nullptr) 127 , m_state(state)
128 , m_frontend(nullptr) 128 , m_frontend(frontend)
129 , m_enabled(false) 129 , m_enabled(false)
130 , m_recordingCPUProfile(false) 130 , m_recordingCPUProfile(false)
131 { 131 {
132 } 132 }
133 133
134 V8ProfilerAgentImpl::~V8ProfilerAgentImpl() 134 V8ProfilerAgentImpl::~V8ProfilerAgentImpl()
135 { 135 {
136 } 136 }
137 137
138 void V8ProfilerAgentImpl::consoleProfile(const String16& title) 138 void V8ProfilerAgentImpl::consoleProfile(const String16& title)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval) 204 void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval)
205 { 205 {
206 if (m_recordingCPUProfile) { 206 if (m_recordingCPUProfile) {
207 *error = "Cannot change sampling interval when profiling."; 207 *error = "Cannot change sampling interval when profiling.";
208 return; 208 return;
209 } 209 }
210 m_state->setNumber(ProfilerAgentState::samplingInterval, interval); 210 m_state->setNumber(ProfilerAgentState::samplingInterval, interval);
211 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); 211 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
212 } 212 }
213 213
214 void V8ProfilerAgentImpl::clearFrontend()
215 {
216 ErrorString error;
217 disable(&error);
218 DCHECK(m_frontend);
219 m_frontend = nullptr;
220 }
221
222 void V8ProfilerAgentImpl::restore() 214 void V8ProfilerAgentImpl::restore()
223 { 215 {
224 DCHECK(!m_enabled); 216 DCHECK(!m_enabled);
225 if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false)) 217 if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false))
226 return; 218 return;
227 m_enabled = true; 219 m_enabled = true;
228 m_session->changeInstrumentationCounter(+1); 220 m_session->changeInstrumentationCounter(+1);
229 int interval = 0; 221 int interval = 0;
230 m_state->getNumber(ProfilerAgentState::samplingInterval, &interval); 222 m_state->getNumber(ProfilerAgentState::samplingInterval, &interval);
231 if (interval) 223 if (interval)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 profile->Delete(); 285 profile->Delete();
294 return result; 286 return result;
295 } 287 }
296 288
297 bool V8ProfilerAgentImpl::isRecording() const 289 bool V8ProfilerAgentImpl::isRecording() const
298 { 290 {
299 return m_recordingCPUProfile || !m_startedProfiles.isEmpty(); 291 return m_recordingCPUProfile || !m_startedProfiles.isEmpty();
300 } 292 }
301 293
302 } // namespace blink 294 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698