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

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

Issue 1985093003: leak_detector: call transform() with back_inserter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/leak_detector.h" 5 #include "components/metrics/leak_detector/leak_detector.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 detector->last_analysis_alloc_size_ + analysis_interval_bytes) { 261 detector->last_analysis_alloc_size_ + analysis_interval_bytes) {
262 // Try to maintain regular intervals of size |analysis_interval_bytes_|. 262 // Try to maintain regular intervals of size |analysis_interval_bytes_|.
263 detector->last_analysis_alloc_size_ = 263 detector->last_analysis_alloc_size_ =
264 total_alloc_size - total_alloc_size % analysis_interval_bytes; 264 total_alloc_size - total_alloc_size % analysis_interval_bytes;
265 265
266 InternalVector<InternalLeakReport> leak_reports; 266 InternalVector<InternalLeakReport> leak_reports;
267 detector->impl_->TestForLeaks(&leak_reports); 267 detector->impl_->TestForLeaks(&leak_reports);
268 268
269 // Pass leak reports to observers. 269 // Pass leak reports to observers.
270 std::vector<MemoryLeakReportProto> leak_report_protos; 270 std::vector<MemoryLeakReportProto> leak_report_protos;
271 leak_report_protos.reserve(leak_reports.size());
271 std::transform(leak_reports.begin(), leak_reports.end(), 272 std::transform(leak_reports.begin(), leak_reports.end(),
272 leak_report_protos.begin(), &ConvertLeakReportToProto); 273 std::back_inserter(leak_report_protos),
274 &ConvertLeakReportToProto);
273 detector->NotifyObservers(leak_report_protos); 275 detector->NotifyObservers(leak_report_protos);
274 } 276 }
275 } 277 }
276 278
277 { 279 {
278 // The internal memory of |stack| should be freed before setting 280 // The internal memory of |stack| should be freed before setting
279 // |entered_hook| to false at the end of this function. Free it here by 281 // |entered_hook| to false at the end of this function. Free it here by
280 // moving the internal memory to a temporary variable that will go out of 282 // moving the internal memory to a temporary variable that will go out of
281 // scope. 283 // scope.
282 std::vector<void*> dummy_stack; 284 std::vector<void*> dummy_stack;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 return; 328 return;
327 } 329 }
328 330
329 { 331 {
330 base::AutoLock lock(observers_lock_); 332 base::AutoLock lock(observers_lock_);
331 FOR_EACH_OBSERVER(Observer, observers_, OnLeaksFound(reports)); 333 FOR_EACH_OBSERVER(Observer, observers_, OnLeaksFound(reports));
332 } 334 }
333 } 335 }
334 336
335 } // namespace metrics 337 } // namespace metrics
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698