OLD | NEW |
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 "chrome/browser/metrics/leak_detector_controller.h" | 5 #include "chrome/browser/metrics/leak_detector_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Initialize the new report with the protobuf template, which contains some | 112 // Initialize the new report with the protobuf template, which contains some |
113 // pre-filled data (parameter values). | 113 // pre-filled data (parameter values). |
114 stored_reports_.push_back(leak_report_proto_template_); | 114 stored_reports_.push_back(leak_report_proto_template_); |
115 MemoryLeakReportProto* proto = &stored_reports_.back(); | 115 MemoryLeakReportProto* proto = &stored_reports_.back(); |
116 | 116 |
117 // Fill in the remaining fields of the protobuf with data from |report|. | 117 // Fill in the remaining fields of the protobuf with data from |report|. |
118 proto->set_size_bytes(report.alloc_size_bytes); | 118 proto->set_size_bytes(report.alloc_size_bytes); |
119 proto->mutable_call_stack()->Reserve(report.call_stack.size()); | 119 proto->mutable_call_stack()->Reserve(report.call_stack.size()); |
120 for (uintptr_t call_stack_entry : report.call_stack) | 120 for (uintptr_t call_stack_entry : report.call_stack) |
121 proto->mutable_call_stack()->Add(call_stack_entry); | 121 proto->mutable_call_stack()->Add(call_stack_entry); |
| 122 |
| 123 for (const auto& entry : report.alloc_breakdown_history) { |
| 124 auto* breakdown_proto = proto->add_alloc_breakdown_history(); |
| 125 for (const uint32_t count : entry.counts_by_size) |
| 126 breakdown_proto->add_counts_by_size(count); |
| 127 breakdown_proto->set_count_for_call_stack(entry.count_for_call_stack); |
| 128 } |
122 } | 129 } |
123 | 130 |
124 void LeakDetectorController::GetLeakReports( | 131 void LeakDetectorController::GetLeakReports( |
125 std::vector<MemoryLeakReportProto>* reports) { | 132 std::vector<MemoryLeakReportProto>* reports) { |
126 DCHECK(thread_checker_.CalledOnValidThread()); | 133 DCHECK(thread_checker_.CalledOnValidThread()); |
127 *reports = std::move(stored_reports_); | 134 *reports = std::move(stored_reports_); |
128 } | 135 } |
129 | 136 |
130 } // namespace metrics | 137 } // namespace metrics |
OLD | NEW |