OLD | NEW |
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 "base/trace_event/heap_profiler_stack_frame_deduplicator.h" | 5 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 std::string stringify_buffer; | 70 std::string stringify_buffer; |
71 | 71 |
72 while (frame_node != it_end) { | 72 while (frame_node != it_end) { |
73 // The |stackFrames| format is a dictionary, not an array, so the | 73 // The |stackFrames| format is a dictionary, not an array, so the |
74 // keys are stringified indices. Write the index manually, then use | 74 // keys are stringified indices. Write the index manually, then use |
75 // |TracedValue| to format the object. This is to avoid building the | 75 // |TracedValue| to format the object. This is to avoid building the |
76 // entire dictionary as a |TracedValue| in memory. | 76 // entire dictionary as a |TracedValue| in memory. |
77 SStringPrintf(&stringify_buffer, "\"%d\":", i); | 77 SStringPrintf(&stringify_buffer, "\"%d\":", i); |
78 out->append(stringify_buffer); | 78 out->append(stringify_buffer); |
79 | 79 |
80 scoped_ptr<TracedValue> frame_node_value(new TracedValue); | 80 std::unique_ptr<TracedValue> frame_node_value(new TracedValue); |
81 frame_node_value->SetString("name", frame_node->frame); | 81 frame_node_value->SetString("name", frame_node->frame); |
82 if (frame_node->parent_frame_index >= 0) { | 82 if (frame_node->parent_frame_index >= 0) { |
83 SStringPrintf(&stringify_buffer, "%d", frame_node->parent_frame_index); | 83 SStringPrintf(&stringify_buffer, "%d", frame_node->parent_frame_index); |
84 frame_node_value->SetString("parent", stringify_buffer); | 84 frame_node_value->SetString("parent", stringify_buffer); |
85 } | 85 } |
86 frame_node_value->AppendAsTraceFormat(out); | 86 frame_node_value->AppendAsTraceFormat(out); |
87 | 87 |
88 i++; | 88 i++; |
89 frame_node++; | 89 frame_node++; |
90 | 90 |
(...skipping 16 matching lines...) Expand all Loading... |
107 for (const FrameNode& node : frames_) | 107 for (const FrameNode& node : frames_) |
108 maps_size += node.children.size() * sizeof(std::pair<StackFrame, int>); | 108 maps_size += node.children.size() * sizeof(std::pair<StackFrame, int>); |
109 | 109 |
110 overhead->Add("StackFrameDeduplicator", | 110 overhead->Add("StackFrameDeduplicator", |
111 sizeof(StackFrameDeduplicator) + maps_size + frames_allocated, | 111 sizeof(StackFrameDeduplicator) + maps_size + frames_allocated, |
112 sizeof(StackFrameDeduplicator) + maps_size + frames_resident); | 112 sizeof(StackFrameDeduplicator) + maps_size + frames_resident); |
113 } | 113 } |
114 | 114 |
115 } // namespace trace_event | 115 } // namespace trace_event |
116 } // namespace base | 116 } // namespace base |
OLD | NEW |