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

Side by Side Diff: components/metrics/leak_detector/protobuf_to_mojo_converter.cc

Issue 2403223002: Leak reports collect information about the last uptrend (Closed)
Patch Set: Created 4 years, 2 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 "components/metrics/leak_detector/protobuf_to_mojo_converter.h" 5 #include "components/metrics/leak_detector/protobuf_to_mojo_converter.h"
6 6
7 namespace metrics { 7 namespace metrics {
8 namespace leak_detector { 8 namespace leak_detector {
9 namespace protobuf_to_mojo_converter { 9 namespace protobuf_to_mojo_converter {
10 10
(...skipping 13 matching lines...) Expand all
24 params->set_max_stack_depth(mojo_params.max_stack_depth); 24 params->set_max_stack_depth(mojo_params.max_stack_depth);
25 params->set_analysis_interval_bytes(mojo_params.analysis_interval_bytes); 25 params->set_analysis_interval_bytes(mojo_params.analysis_interval_bytes);
26 params->set_size_suspicion_threshold(mojo_params.size_suspicion_threshold); 26 params->set_size_suspicion_threshold(mojo_params.size_suspicion_threshold);
27 params->set_call_stack_suspicion_threshold( 27 params->set_call_stack_suspicion_threshold(
28 mojo_params.call_stack_suspicion_threshold); 28 mojo_params.call_stack_suspicion_threshold);
29 } 29 }
30 30
31 void ReportToMojo(const MemoryLeakReportProto& report, 31 void ReportToMojo(const MemoryLeakReportProto& report,
32 mojom::MemoryLeakReport* mojo_report) { 32 mojom::MemoryLeakReport* mojo_report) {
33 mojo_report->size_bytes = report.size_bytes(); 33 mojo_report->size_bytes = report.size_bytes();
34 mojo_report->num_rising_intervals = report.num_rising_intervals();
35 mojo_report->num_allocs_increase = report.num_allocs_increase();
34 for (auto call_stack_value : report.call_stack()) { 36 for (auto call_stack_value : report.call_stack()) {
35 mojo_report->call_stack.push_back(call_stack_value); 37 mojo_report->call_stack.push_back(call_stack_value);
36 } 38 }
37 39
38 for (const auto& history_entry : report.alloc_breakdown_history()) { 40 for (const auto& history_entry : report.alloc_breakdown_history()) {
39 metrics::mojom::AllocationBreakdownPtr mojo_entry = 41 metrics::mojom::AllocationBreakdownPtr mojo_entry =
40 metrics::mojom::AllocationBreakdown::New(); 42 metrics::mojom::AllocationBreakdown::New();
41 for (auto count : history_entry.counts_by_size()) { 43 for (auto count : history_entry.counts_by_size()) {
42 mojo_entry->counts_by_size.push_back(count); 44 mojo_entry->counts_by_size.push_back(count);
43 } 45 }
44 mojo_entry->count_for_call_stack = history_entry.count_for_call_stack(); 46 mojo_entry->count_for_call_stack = history_entry.count_for_call_stack();
45 47
46 mojo_report->alloc_breakdown_history.push_back(std::move(mojo_entry)); 48 mojo_report->alloc_breakdown_history.push_back(std::move(mojo_entry));
47 } 49 }
48 } 50 }
49 51
50 void MojoToReport(const mojom::MemoryLeakReport& mojo_report, 52 void MojoToReport(const mojom::MemoryLeakReport& mojo_report,
51 MemoryLeakReportProto* report) { 53 MemoryLeakReportProto* report) {
52 report->set_size_bytes(mojo_report.size_bytes); 54 report->set_size_bytes(mojo_report.size_bytes);
55 report->set_num_rising_intervals(mojo_report.num_rising_intervals);
56 report->set_num_allocs_increase(mojo_report.num_allocs_increase);
53 for (auto call_stack_addr : mojo_report.call_stack) 57 for (auto call_stack_addr : mojo_report.call_stack)
54 report->add_call_stack(call_stack_addr); 58 report->add_call_stack(call_stack_addr);
55 59
56 for (const auto& history_entry : mojo_report.alloc_breakdown_history) { 60 for (const auto& history_entry : mojo_report.alloc_breakdown_history) {
57 auto proto_entry = report->add_alloc_breakdown_history(); 61 auto proto_entry = report->add_alloc_breakdown_history();
58 for (auto count : history_entry->counts_by_size) { 62 for (auto count : history_entry->counts_by_size) {
59 proto_entry->add_counts_by_size(count); 63 proto_entry->add_counts_by_size(count);
60 } 64 }
61 proto_entry->set_count_for_call_stack(history_entry->count_for_call_stack); 65 proto_entry->set_count_for_call_stack(history_entry->count_for_call_stack);
62 } 66 }
63 } 67 }
64 68
65 } // namespace protobuf_to_mojo_converter 69 } // namespace protobuf_to_mojo_converter
66 } // namespace leak_detector 70 } // namespace leak_detector
67 } // namespace metrics 71 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698