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

Unified Diff: chrome/browser/metrics/leak_detector_controller.cc

Issue 1868193003: Store alloc history data in memory leak report protobuf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@leak-history
Patch Set: Call MergeFrom(); Update comment about repeated fields; Use braces for single-line for loops Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/metrics/leak_detector_controller.cc
diff --git a/chrome/browser/metrics/leak_detector_controller.cc b/chrome/browser/metrics/leak_detector_controller.cc
index 06762ea035777b276d120c7f8b9b130795750397..8c4fff8846900ccbc32036dfd1f507d843182d5e 100644
--- a/chrome/browser/metrics/leak_detector_controller.cc
+++ b/chrome/browser/metrics/leak_detector_controller.cc
@@ -105,20 +105,19 @@ LeakDetectorController::~LeakDetectorController() {
LeakDetector::GetInstance()->RemoveObserver(this);
}
-void LeakDetectorController::OnLeakFound(
- const LeakDetector::LeakReport& report) {
+void LeakDetectorController::OnLeaksFound(
+ const std::vector<MemoryLeakReportProto>& reports) {
DCHECK(thread_checker_.CalledOnValidThread());
- // Initialize the new report with the protobuf template, which contains some
- // pre-filled data (parameter values).
- stored_reports_.push_back(leak_report_proto_template_);
- MemoryLeakReportProto* proto = &stored_reports_.back();
+ for (const auto& report : reports) {
+ // Initialize the new report with the protobuf template, which contains some
+ // pre-filled data (parameter values).
+ stored_reports_.push_back(leak_report_proto_template_);
+ MemoryLeakReportProto* proto = &stored_reports_.back();
- // Fill in the remaining fields of the protobuf with data from |report|.
- proto->set_size_bytes(report.alloc_size_bytes);
- proto->mutable_call_stack()->Reserve(report.call_stack.size());
- for (uintptr_t call_stack_entry : report.call_stack)
- proto->mutable_call_stack()->Add(call_stack_entry);
+ // Merge in the other fields.
+ proto->MergeFrom(report);
+ }
}
void LeakDetectorController::GetLeakReports(

Powered by Google App Engine
This is Rietveld 408576698