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

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

Issue 2150803002: [DevTools] Add callFrame to CPUProfileNode & SamplingHeapProfileNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/V8HeapProfilerAgentImpl.h" 5 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h"
6 6
7 #include "platform/v8_inspector/InjectedScript.h" 7 #include "platform/v8_inspector/InjectedScript.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/V8StringUtil.h" 10 #include "platform/v8_inspector/V8StringUtil.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 #if V8_MAJOR_VERSION >= 5 354 #if V8_MAJOR_VERSION >= 5
355 namespace { 355 namespace {
356 std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> buildSampingHea pProfileNode(const v8::AllocationProfile::Node* node) 356 std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> buildSampingHea pProfileNode(const v8::AllocationProfile::Node* node)
357 { 357 {
358 auto children = protocol::Array<protocol::HeapProfiler::SamplingHeapProfileN ode>::create(); 358 auto children = protocol::Array<protocol::HeapProfiler::SamplingHeapProfileN ode>::create();
359 for (const auto* child : node->children) 359 for (const auto* child : node->children)
360 children->addItem(buildSampingHeapProfileNode(child)); 360 children->addItem(buildSampingHeapProfileNode(child));
361 size_t selfSize = 0; 361 size_t selfSize = 0;
362 for (const auto& allocation : node->allocations) 362 for (const auto& allocation : node->allocations)
363 selfSize += allocation.size * allocation.count; 363 selfSize += allocation.size * allocation.count;
364 std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> result = pr otocol::HeapProfiler::SamplingHeapProfileNode::create() 364 std::unique_ptr<protocol::Runtime::CallFrame> callFrame = protocol::Runtime: :CallFrame::create()
365 .setFunctionName(toProtocolString(node->name)) 365 .setFunctionName(toProtocolString(node->name))
366 .setScriptId(String16::fromInteger(node->script_id)) 366 .setScriptId(String16::fromInteger(node->script_id))
367 .setUrl(toProtocolString(node->script_name)) 367 .setUrl(toProtocolString(node->script_name))
368 .setLineNumber(node->line_number) 368 .setLineNumber(node->line_number - 1)
369 .setColumnNumber(node->column_number) 369 .setColumnNumber(node->column_number - 1)
370 .build();
371 std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode> result = pr otocol::HeapProfiler::SamplingHeapProfileNode::create()
372 .setCallFrame(std::move(callFrame))
370 .setSelfSize(selfSize) 373 .setSelfSize(selfSize)
371 .setChildren(std::move(children)).build(); 374 .setChildren(std::move(children)).build();
372 return result; 375 return result;
373 } 376 }
374 } // namespace 377 } // namespace
375 #endif 378 #endif
376 379
377 void V8HeapProfilerAgentImpl::stopSampling(ErrorString* errorString, std::unique _ptr<protocol::HeapProfiler::SamplingHeapProfile>* profile) 380 void V8HeapProfilerAgentImpl::stopSampling(ErrorString* errorString, std::unique _ptr<protocol::HeapProfiler::SamplingHeapProfile>* profile)
378 { 381 {
379 #if V8_MAJOR_VERSION >= 5 382 #if V8_MAJOR_VERSION >= 5
(...skipping 10 matching lines...) Expand all
390 *errorString = "Cannot access v8 sampled heap profile."; 393 *errorString = "Cannot access v8 sampled heap profile.";
391 return; 394 return;
392 } 395 }
393 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); 396 v8::AllocationProfile::Node* root = v8Profile->GetRootNode();
394 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() 397 *profile = protocol::HeapProfiler::SamplingHeapProfile::create()
395 .setHead(buildSampingHeapProfileNode(root)).build(); 398 .setHead(buildSampingHeapProfileNode(root)).build();
396 #endif 399 #endif
397 } 400 }
398 401
399 } // namespace blink 402 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698