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/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/debug/leak_annotations.h" | 8 #include "base/debug/leak_annotations.h" |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 | 27 |
28 // static | 28 // static |
29 void StatisticsRecorder::Initialize() { | 29 void StatisticsRecorder::Initialize() { |
30 // Ensure that an instance of the StatisticsRecorder object is created. | 30 // Ensure that an instance of the StatisticsRecorder object is created. |
31 g_statistics_recorder_.Get(); | 31 g_statistics_recorder_.Get(); |
32 } | 32 } |
33 | 33 |
| 34 // static |
| 35 void StatisticsRecorder::InitializeForTest() { |
| 36 Initialize(); |
| 37 histograms_->clear(); |
| 38 ranges_->clear(); |
| 39 } |
34 | 40 |
35 // static | 41 // static |
36 bool StatisticsRecorder::IsActive() { | 42 bool StatisticsRecorder::IsActive() { |
37 if (lock_ == NULL) | 43 if (lock_ == NULL) |
38 return false; | 44 return false; |
39 base::AutoLock auto_lock(*lock_); | 45 base::AutoLock auto_lock(*lock_); |
40 return NULL != histograms_; | 46 return NULL != histograms_; |
41 } | 47 } |
42 | 48 |
43 // static | 49 // static |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 320 |
315 | 321 |
316 // static | 322 // static |
317 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; | 323 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; |
318 // static | 324 // static |
319 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; | 325 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; |
320 // static | 326 // static |
321 base::Lock* StatisticsRecorder::lock_ = NULL; | 327 base::Lock* StatisticsRecorder::lock_ = NULL; |
322 | 328 |
323 } // namespace base | 329 } // namespace base |
OLD | NEW |