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

Side by Side Diff: base/metrics/statistics_recorder.cc

Issue 10779040: Initialize StatisticsRecorder in Child Process to hold (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
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/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 12
13 namespace {
14 // Initialize histogram statistics gathering system.
15 base::LazyInstance<base::StatisticsRecorder>::Leaky
16 g_statistics_recorder_ = LAZY_INSTANCE_INITIALIZER;
17 } // namespace
18
13 namespace base { 19 namespace base {
14 20
15 // Collect the number of histograms created. 21 // Collect the number of histograms created.
16 static uint32 number_of_histograms_ = 0; 22 static uint32 number_of_histograms_ = 0;
17 // Collect the number of vectors saved because of caching ranges. 23 // Collect the number of vectors saved because of caching ranges.
18 static uint32 number_of_vectors_saved_ = 0; 24 static uint32 number_of_vectors_saved_ = 0;
19 // Collect the number of ranges_ elements saved because of caching ranges. 25 // Collect the number of ranges_ elements saved because of caching ranges.
20 static size_t saved_ranges_size_ = 0; 26 static size_t saved_ranges_size_ = 0;
21 27
22 // This singleton instance should be started during the single threaded portion 28 // This singleton instance should be started during the single threaded portion
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ranges_ = NULL; 66 ranges_ = NULL;
61 } 67 }
62 // We are going to leak the histograms and the ranges. 68 // We are going to leak the histograms and the ranges.
63 delete histograms; 69 delete histograms;
64 delete ranges; 70 delete ranges;
65 // We don't delete lock_ on purpose to avoid having to properly protect 71 // We don't delete lock_ on purpose to avoid having to properly protect
66 // against it going away after we checked for NULL in the static methods. 72 // against it going away after we checked for NULL in the static methods.
67 } 73 }
68 74
69 // static 75 // static
76 void StatisticsRecorder::Initialize() {
77 // Ensure that an instance of the StatisticsRecorder object is created.
78 g_statistics_recorder_.Get();
79 }
80
81
82 // static
70 bool StatisticsRecorder::IsActive() { 83 bool StatisticsRecorder::IsActive() {
71 if (lock_ == NULL) 84 if (lock_ == NULL)
72 return false; 85 return false;
73 base::AutoLock auto_lock(*lock_); 86 base::AutoLock auto_lock(*lock_);
74 return NULL != histograms_; 87 return NULL != histograms_;
75 } 88 }
76 89
77 Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) { 90 Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
78 // As per crbug.com/79322 the histograms are intentionally leaked, so we need 91 // As per crbug.com/79322 the histograms are intentionally leaked, so we need
79 // to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once 92 // to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // static 289 // static
277 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; 290 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
278 // static 291 // static
279 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; 292 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL;
280 // static 293 // static
281 base::Lock* StatisticsRecorder::lock_ = NULL; 294 base::Lock* StatisticsRecorder::lock_ = NULL;
282 // static 295 // static
283 bool StatisticsRecorder::dump_on_exit_ = false; 296 bool StatisticsRecorder::dump_on_exit_ = false;
284 297
285 } // namespace base 298 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/statistics_recorder.h ('k') | chrome/browser/chrome_browser_application_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698