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_heap_dump_writer.h" | 5 #include "base/trace_event/heap_profiler_heap_dump_writer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 241 } |
242 | 242 |
243 AddEntryForBucket(root_bucket); | 243 AddEntryForBucket(root_bucket); |
244 | 244 |
245 // Recursively break down the heap and fill |entries_| with entries to dump. | 245 // Recursively break down the heap and fill |entries_| with entries to dump. |
246 BreakDown(root_bucket); | 246 BreakDown(root_bucket); |
247 | 247 |
248 return entries_; | 248 return entries_; |
249 } | 249 } |
250 | 250 |
251 scoped_ptr<TracedValue> Serialize(const std::set<Entry>& entries) { | 251 std::unique_ptr<TracedValue> Serialize(const std::set<Entry>& entries) { |
252 std::string buffer; | 252 std::string buffer; |
253 scoped_ptr<TracedValue> traced_value(new TracedValue); | 253 std::unique_ptr<TracedValue> traced_value(new TracedValue); |
254 | 254 |
255 traced_value->BeginArray("entries"); | 255 traced_value->BeginArray("entries"); |
256 | 256 |
257 for (const Entry& entry : entries) { | 257 for (const Entry& entry : entries) { |
258 traced_value->BeginDictionary(); | 258 traced_value->BeginDictionary(); |
259 | 259 |
260 // Format size as hexadecimal string into |buffer|. | 260 // Format size as hexadecimal string into |buffer|. |
261 SStringPrintf(&buffer, "%" PRIx64, static_cast<uint64_t>(entry.size)); | 261 SStringPrintf(&buffer, "%" PRIx64, static_cast<uint64_t>(entry.size)); |
262 traced_value->SetString("size", buffer); | 262 traced_value->SetString("size", buffer); |
263 | 263 |
(...skipping 18 matching lines...) Expand all Loading... |
282 | 282 |
283 traced_value->EndDictionary(); | 283 traced_value->EndDictionary(); |
284 } | 284 } |
285 | 285 |
286 traced_value->EndArray(); // "entries" | 286 traced_value->EndArray(); // "entries" |
287 return traced_value; | 287 return traced_value; |
288 } | 288 } |
289 | 289 |
290 } // namespace internal | 290 } // namespace internal |
291 | 291 |
292 scoped_ptr<TracedValue> ExportHeapDump( | 292 std::unique_ptr<TracedValue> ExportHeapDump( |
293 const hash_map<AllocationContext, size_t>& bytes_by_size, | 293 const hash_map<AllocationContext, size_t>& bytes_by_size, |
294 StackFrameDeduplicator* stack_frame_deduplicator, | 294 StackFrameDeduplicator* stack_frame_deduplicator, |
295 TypeNameDeduplicator* type_name_deduplicator) { | 295 TypeNameDeduplicator* type_name_deduplicator) { |
296 internal::HeapDumpWriter writer(stack_frame_deduplicator, | 296 internal::HeapDumpWriter writer(stack_frame_deduplicator, |
297 type_name_deduplicator); | 297 type_name_deduplicator); |
298 return Serialize(writer.Summarize(bytes_by_size)); | 298 return Serialize(writer.Summarize(bytes_by_size)); |
299 } | 299 } |
300 | 300 |
301 } // namespace trace_event | 301 } // namespace trace_event |
302 } // namespace base | 302 } // namespace base |
OLD | NEW |