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

Side by Side Diff: chrome/browser/metrics/leak_detector/leak_detector_controller.cc

Issue 2159013002: Read Chrome build ID and store it in leak reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace GNUBuildIDReader class with namespace Created 4 years, 5 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 "chrome/browser/metrics/leak_detector/leak_detector_controller.h" 5 #include "chrome/browser/metrics/leak_detector/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"
11 #include "components/metrics/leak_detector/gnu_build_id_reader.h"
11 #include "components/variations/variations_associated_data.h" 12 #include "components/variations/variations_associated_data.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 14
14 namespace metrics { 15 namespace metrics {
15 16
16 namespace { 17 namespace {
17 18
18 // Reads parameters for the field trial variation. Any parameters not present in 19 // Reads parameters for the field trial variation. Any parameters not present in
19 // the variation info or that cannot be parsed will be filled in with default 20 // the variation info or that cannot be parsed will be filled in with default
20 // values. Returns a MemoryLeakReportProto with the parameter fields filled in. 21 // values. Returns a MemoryLeakReportProto with the parameter fields filled in.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 result.set_analysis_interval_bytes(analysis_interval_kb * 1024); 84 result.set_analysis_interval_bytes(analysis_interval_kb * 1024);
84 result.set_size_suspicion_threshold(size_suspicion_threshold); 85 result.set_size_suspicion_threshold(size_suspicion_threshold);
85 result.set_call_stack_suspicion_threshold(call_stack_suspicion_threshold); 86 result.set_call_stack_suspicion_threshold(call_stack_suspicion_threshold);
86 return result; 87 return result;
87 } 88 }
88 89
89 } // namespace 90 } // namespace
90 91
91 LeakDetectorController::LeakDetectorController() 92 LeakDetectorController::LeakDetectorController()
92 : params_(GetVariationParameters()) { 93 : params_(GetVariationParameters()) {
94 // Read the build ID once and store it.
95 DCHECK(leak_detector::gnu_build_id_reader::ReadBuildID(&build_id_));
rickyz (no longer on Chrome) 2016/07/19 04:58:22 If you rely on side effects of a function, don't p
Simon Que 2016/07/22 01:40:06 Done.
96
93 LeakDetector* detector = LeakDetector::GetInstance(); 97 LeakDetector* detector = LeakDetector::GetInstance();
94 detector->AddObserver(this); 98 detector->AddObserver(this);
95 99
96 // Leak detector parameters are stored in |params_|. 100 // Leak detector parameters are stored in |params_|.
97 detector->Init(params_, content::BrowserThread::GetTaskRunnerForThread( 101 detector->Init(params_, content::BrowserThread::GetTaskRunnerForThread(
98 content::BrowserThread::UI)); 102 content::BrowserThread::UI));
99 } 103 }
100 104
101 LeakDetectorController::~LeakDetectorController() { 105 LeakDetectorController::~LeakDetectorController() {
102 DCHECK(thread_checker_.CalledOnValidThread()); 106 DCHECK(thread_checker_.CalledOnValidThread());
103 LeakDetector::GetInstance()->RemoveObserver(this); 107 LeakDetector::GetInstance()->RemoveObserver(this);
104 } 108 }
105 109
106 void LeakDetectorController::OnLeaksFound( 110 void LeakDetectorController::OnLeaksFound(
107 const std::vector<MemoryLeakReportProto>& reports) { 111 const std::vector<MemoryLeakReportProto>& reports) {
108 DCHECK(thread_checker_.CalledOnValidThread()); 112 DCHECK(thread_checker_.CalledOnValidThread());
109 113
110 for (const auto& report : reports) { 114 for (const auto& report : reports) {
111 // Store the report and insert stored parameters. 115 // Store the report and insert stored parameters.
112 stored_reports_.push_back(report); 116 stored_reports_.push_back(report);
113 stored_reports_.back().mutable_params()->CopyFrom(params_); 117 stored_reports_.back().mutable_params()->CopyFrom(params_);
118 stored_reports_.back().mutable_build_id()->assign(build_id_.begin(),
119 build_id_.end());
114 } 120 }
115 } 121 }
116 122
117 void LeakDetectorController::GetLeakReports( 123 void LeakDetectorController::GetLeakReports(
118 std::vector<MemoryLeakReportProto>* reports) { 124 std::vector<MemoryLeakReportProto>* reports) {
119 DCHECK(thread_checker_.CalledOnValidThread()); 125 DCHECK(thread_checker_.CalledOnValidThread());
120 *reports = std::move(stored_reports_); 126 *reports = std::move(stored_reports_);
121 } 127 }
122 128
123 } // namespace metrics 129 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698