Chromium Code Reviews| 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/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 Loading... | |
| 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 bool build_id_read = | |
| 96 leak_detector::gnu_build_id_reader::ReadBuildID(&build_id_); | |
| 97 DCHECK(build_id_read); | |
|
Simon Que
2016/07/25 21:25:26
Unit tests are failing this DCHECK because the uni
| |
| 98 | |
| 93 LeakDetector* detector = LeakDetector::GetInstance(); | 99 LeakDetector* detector = LeakDetector::GetInstance(); |
| 94 detector->AddObserver(this); | 100 detector->AddObserver(this); |
| 95 | 101 |
| 96 // Leak detector parameters are stored in |params_|. | 102 // Leak detector parameters are stored in |params_|. |
| 97 detector->Init(params_, content::BrowserThread::GetTaskRunnerForThread( | 103 detector->Init(params_, content::BrowserThread::GetTaskRunnerForThread( |
| 98 content::BrowserThread::UI)); | 104 content::BrowserThread::UI)); |
| 99 } | 105 } |
| 100 | 106 |
| 101 LeakDetectorController::~LeakDetectorController() { | 107 LeakDetectorController::~LeakDetectorController() { |
| 102 DCHECK(thread_checker_.CalledOnValidThread()); | 108 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 131 void LeakDetectorController::StoreLeakReports( | 137 void LeakDetectorController::StoreLeakReports( |
| 132 const std::vector<MemoryLeakReportProto>& reports, | 138 const std::vector<MemoryLeakReportProto>& reports, |
| 133 MemoryLeakReportProto::ProcessType process_type) { | 139 MemoryLeakReportProto::ProcessType process_type) { |
| 134 DCHECK(thread_checker_.CalledOnValidThread()); | 140 DCHECK(thread_checker_.CalledOnValidThread()); |
| 135 | 141 |
| 136 for (const auto& report : reports) { | 142 for (const auto& report : reports) { |
| 137 // Store the report and insert stored parameters. | 143 // Store the report and insert stored parameters. |
| 138 stored_reports_.push_back(report); | 144 stored_reports_.push_back(report); |
| 139 stored_reports_.back().mutable_params()->CopyFrom(params_); | 145 stored_reports_.back().mutable_params()->CopyFrom(params_); |
| 140 stored_reports_.back().set_source_process(process_type); | 146 stored_reports_.back().set_source_process(process_type); |
| 147 stored_reports_.back().mutable_build_id()->assign(build_id_.begin(), | |
| 148 build_id_.end()); | |
| 141 } | 149 } |
| 142 } | 150 } |
| 143 | 151 |
| 144 } // namespace metrics | 152 } // namespace metrics |
| OLD | NEW |