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

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

Issue 2151083002: DevTools: explicitly differentiate ints vs doubles in the protocol bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean 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 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const int childrenCount = node->GetChildrenCount(); 51 const int childrenCount = node->GetChildrenCount();
52 for (int i = 0; i < childrenCount; i++) { 52 for (int i = 0; i < childrenCount; i++) {
53 const v8::CpuProfileNode* child = node->GetChild(i); 53 const v8::CpuProfileNode* child = node->GetChild(i);
54 children->addItem(buildInspectorObjectFor(isolate, child)); 54 children->addItem(buildInspectorObjectFor(isolate, child));
55 } 55 }
56 56
57 std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> posit ionTicks = buildInspectorObjectForPositionTicks(node); 57 std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>> posit ionTicks = buildInspectorObjectForPositionTicks(node);
58 58
59 std::unique_ptr<protocol::Profiler::CPUProfileNode> result = protocol::Profi ler::CPUProfileNode::create() 59 std::unique_ptr<protocol::Profiler::CPUProfileNode> result = protocol::Profi ler::CPUProfileNode::create()
60 .setFunctionName(toProtocolString(node->GetFunctionName())) 60 .setFunctionName(toProtocolString(node->GetFunctionName()))
61 .setScriptId(String16::number(node->GetScriptId())) 61 .setScriptId(String16::fromInteger(node->GetScriptId()))
62 .setUrl(toProtocolString(node->GetScriptResourceName())) 62 .setUrl(toProtocolString(node->GetScriptResourceName()))
63 .setLineNumber(node->GetLineNumber()) 63 .setLineNumber(node->GetLineNumber())
64 .setColumnNumber(node->GetColumnNumber()) 64 .setColumnNumber(node->GetColumnNumber())
65 .setHitCount(node->GetHitCount()) 65 .setHitCount(node->GetHitCount())
66 .setCallUID(node->GetCallUid()) 66 .setCallUID(node->GetCallUid())
67 .setChildren(std::move(children)) 67 .setChildren(std::move(children))
68 .setPositionTicks(std::move(positionTicks)) 68 .setPositionTicks(std::move(positionTicks))
69 .setDeoptReason(node->GetBailoutReason()) 69 .setDeoptReason(node->GetBailoutReason())
70 .setId(node->GetNodeId()).build(); 70 .setId(node->GetNodeId()).build();
71 return result; 71 return result;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 m_enabled = false; 198 m_enabled = false;
199 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false); 199 m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
200 } 200 }
201 201
202 void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval) 202 void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval)
203 { 203 {
204 if (m_recordingCPUProfile) { 204 if (m_recordingCPUProfile) {
205 *error = "Cannot change sampling interval when profiling."; 205 *error = "Cannot change sampling interval when profiling.";
206 return; 206 return;
207 } 207 }
208 m_state->setNumber(ProfilerAgentState::samplingInterval, interval); 208 m_state->setInteger(ProfilerAgentState::samplingInterval, interval);
209 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); 209 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
210 } 210 }
211 211
212 void V8ProfilerAgentImpl::restore() 212 void V8ProfilerAgentImpl::restore()
213 { 213 {
214 DCHECK(!m_enabled); 214 DCHECK(!m_enabled);
215 if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false)) 215 if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false))
216 return; 216 return;
217 m_enabled = true; 217 m_enabled = true;
218 int interval = 0; 218 int interval = 0;
219 m_state->getNumber(ProfilerAgentState::samplingInterval, &interval); 219 m_state->getInteger(ProfilerAgentState::samplingInterval, &interval);
220 if (interval) 220 if (interval)
221 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); 221 m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
222 if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, fal se)) { 222 if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, fal se)) {
223 ErrorString error; 223 ErrorString error;
224 start(&error); 224 start(&error);
225 } 225 }
226 } 226 }
227 227
228 void V8ProfilerAgentImpl::start(ErrorString* error) 228 void V8ProfilerAgentImpl::start(ErrorString* error)
229 { 229 {
(...skipping 24 matching lines...) Expand all
254 if (!profile->get() && errorString) 254 if (!profile->get() && errorString)
255 *errorString = "Profile is not found"; 255 *errorString = "Profile is not found";
256 } 256 }
257 m_frontendInitiatedProfileId = String16(); 257 m_frontendInitiatedProfileId = String16();
258 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); 258 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
259 m_session->client()->profilingStopped(); 259 m_session->client()->profilingStopped();
260 } 260 }
261 261
262 String16 V8ProfilerAgentImpl::nextProfileId() 262 String16 V8ProfilerAgentImpl::nextProfileId()
263 { 263 {
264 return String16::number(atomicIncrement(&s_lastProfileId)); 264 return String16::fromInteger(atomicIncrement(&s_lastProfileId));
265 } 265 }
266 266
267 void V8ProfilerAgentImpl::startProfiling(const String16& title) 267 void V8ProfilerAgentImpl::startProfiling(const String16& title)
268 { 268 {
269 v8::HandleScope handleScope(m_isolate); 269 v8::HandleScope handleScope(m_isolate);
270 m_isolate->GetCpuProfiler()->StartProfiling(toV8String(m_isolate, title), tr ue); 270 m_isolate->GetCpuProfiler()->StartProfiling(toV8String(m_isolate, title), tr ue);
271 } 271 }
272 272
273 std::unique_ptr<protocol::Profiler::CPUProfile> V8ProfilerAgentImpl::stopProfili ng(const String16& title, bool serialize) 273 std::unique_ptr<protocol::Profiler::CPUProfile> V8ProfilerAgentImpl::stopProfili ng(const String16& title, bool serialize)
274 { 274 {
275 v8::HandleScope handleScope(m_isolate); 275 v8::HandleScope handleScope(m_isolate);
276 v8::CpuProfile* profile = m_isolate->GetCpuProfiler()->StopProfiling(toV8Str ing(m_isolate, title)); 276 v8::CpuProfile* profile = m_isolate->GetCpuProfiler()->StopProfiling(toV8Str ing(m_isolate, title));
277 if (!profile) 277 if (!profile)
278 return nullptr; 278 return nullptr;
279 std::unique_ptr<protocol::Profiler::CPUProfile> result; 279 std::unique_ptr<protocol::Profiler::CPUProfile> result;
280 if (serialize) 280 if (serialize)
281 result = createCPUProfile(m_isolate, profile); 281 result = createCPUProfile(m_isolate, profile);
282 profile->Delete(); 282 profile->Delete();
283 return result; 283 return result;
284 } 284 }
285 285
286 bool V8ProfilerAgentImpl::isRecording() const 286 bool V8ProfilerAgentImpl::isRecording() const
287 { 287 {
288 return m_recordingCPUProfile || !m_startedProfiles.empty(); 288 return m_recordingCPUProfile || !m_startedProfiles.empty();
289 } 289 }
290 290
291 } // namespace blink 291 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698