OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/metrics/statistics_recorder.h" | 5 #include "base/metrics/statistics_recorder.h" |
6 | 6 |
7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 base::AutoLock auto_lock(*lock_); | 302 base::AutoLock auto_lock(*lock_); |
303 histograms_ = new HistogramMap; | 303 histograms_ = new HistogramMap; |
304 ranges_ = new RangesMap; | 304 ranges_ = new RangesMap; |
305 } | 305 } |
306 | 306 |
307 StatisticsRecorder::~StatisticsRecorder() { | 307 StatisticsRecorder::~StatisticsRecorder() { |
308 DCHECK(histograms_ && ranges_ && lock_); | 308 DCHECK(histograms_ && ranges_ && lock_); |
309 if (dump_on_exit_) { | 309 if (dump_on_exit_) { |
310 string output; | 310 string output; |
311 WriteGraph("", &output); | 311 WriteGraph(std::string(), &output); |
312 DLOG(INFO) << output; | 312 DLOG(INFO) << output; |
313 } | 313 } |
314 | 314 |
315 // Clean up. | 315 // Clean up. |
316 scoped_ptr<HistogramMap> histograms_deleter; | 316 scoped_ptr<HistogramMap> histograms_deleter; |
317 scoped_ptr<RangesMap> ranges_deleter; | 317 scoped_ptr<RangesMap> ranges_deleter; |
318 // We don't delete lock_ on purpose to avoid having to properly protect | 318 // We don't delete lock_ on purpose to avoid having to properly protect |
319 // against it going away after we checked for NULL in the static methods. | 319 // against it going away after we checked for NULL in the static methods. |
320 { | 320 { |
321 base::AutoLock auto_lock(*lock_); | 321 base::AutoLock auto_lock(*lock_); |
322 histograms_deleter.reset(histograms_); | 322 histograms_deleter.reset(histograms_); |
323 ranges_deleter.reset(ranges_); | 323 ranges_deleter.reset(ranges_); |
324 histograms_ = NULL; | 324 histograms_ = NULL; |
325 ranges_ = NULL; | 325 ranges_ = NULL; |
326 } | 326 } |
327 // We are going to leak the histograms and the ranges. | 327 // We are going to leak the histograms and the ranges. |
328 } | 328 } |
329 | 329 |
330 | 330 |
331 // static | 331 // static |
332 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; | 332 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; |
333 // static | 333 // static |
334 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; | 334 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; |
335 // static | 335 // static |
336 base::Lock* StatisticsRecorder::lock_ = NULL; | 336 base::Lock* StatisticsRecorder::lock_ = NULL; |
337 // static | 337 // static |
338 bool StatisticsRecorder::dump_on_exit_ = false; | 338 bool StatisticsRecorder::dump_on_exit_ = false; |
339 | 339 |
340 } // namespace base | 340 } // namespace base |
OLD | NEW |