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

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

Issue 2166553003: Revert of Mojo interface/service for Leak Detector on remote process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Leak detector parameters are stored in |params_|. 96 // Leak detector parameters are stored in |params_|.
97 detector->Init(params_, content::BrowserThread::GetTaskRunnerForThread( 97 detector->Init(params_, content::BrowserThread::GetTaskRunnerForThread(
98 content::BrowserThread::UI)); 98 content::BrowserThread::UI));
99 } 99 }
100 100
101 LeakDetectorController::~LeakDetectorController() { 101 LeakDetectorController::~LeakDetectorController() {
102 DCHECK(thread_checker_.CalledOnValidThread()); 102 DCHECK(thread_checker_.CalledOnValidThread());
103 LeakDetector::GetInstance()->RemoveObserver(this); 103 LeakDetector::GetInstance()->RemoveObserver(this);
104 } 104 }
105 105
106 void LeakDetectorController::GetLeakReports(
107 std::vector<MemoryLeakReportProto>* reports) {
108 DCHECK(thread_checker_.CalledOnValidThread());
109 reports->swap(stored_reports_);
110 stored_reports_.clear();
111 }
112
113 void LeakDetectorController::OnLeaksFound( 106 void LeakDetectorController::OnLeaksFound(
114 const std::vector<MemoryLeakReportProto>& reports) { 107 const std::vector<MemoryLeakReportProto>& reports) {
115 StoreLeakReports(reports, MemoryLeakReportProto::BROWSER_PROCESS);
116 }
117
118 MemoryLeakReportProto_Params LeakDetectorController::GetParams() const {
119 return params_;
120 }
121
122 void LeakDetectorController::SendLeakReports(
123 const std::vector<MemoryLeakReportProto>& reports) {
124 StoreLeakReports(reports, MemoryLeakReportProto::RENDERER_PROCESS);
125 }
126
127 void LeakDetectorController::OnRemoteProcessShutdown() {
128 // TODO(sque): Handle remote process shutdown.
129 }
130
131 void LeakDetectorController::StoreLeakReports(
132 const std::vector<MemoryLeakReportProto>& reports,
133 MemoryLeakReportProto::ProcessType process_type) {
134 DCHECK(thread_checker_.CalledOnValidThread()); 108 DCHECK(thread_checker_.CalledOnValidThread());
135 109
136 for (const auto& report : reports) { 110 for (const auto& report : reports) {
137 // Store the report and insert stored parameters. 111 // Store the report and insert stored parameters.
138 stored_reports_.push_back(report); 112 stored_reports_.push_back(report);
139 stored_reports_.back().mutable_params()->CopyFrom(params_); 113 stored_reports_.back().mutable_params()->CopyFrom(params_);
140 stored_reports_.back().set_source_process(process_type);
141 } 114 }
142 } 115 }
143 116
117 void LeakDetectorController::GetLeakReports(
118 std::vector<MemoryLeakReportProto>* reports) {
119 DCHECK(thread_checker_.CalledOnValidThread());
120 *reports = std::move(stored_reports_);
121 }
122
144 } // namespace metrics 123 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698