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

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

Issue 1825143002: Revert of Collect information about failing histogram factory calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 (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/alias.h"
9 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
10 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
13 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
14 #include "base/metrics/metrics_hashes.h" 13 #include "base/metrics/metrics_hashes.h"
15 #include "base/stl_util.h" 14 #include "base/stl_util.h"
16 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
17 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
18 #include "base/values.h" 17 #include "base/values.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 histogram->SetFlags(HistogramBase::kCallbackExists); 125 histogram->SetFlags(HistogramBase::kCallbackExists);
127 else 126 else
128 histogram->ClearFlags(HistogramBase::kCallbackExists); 127 histogram->ClearFlags(HistogramBase::kCallbackExists);
129 } 128 }
130 histogram_to_return = histogram; 129 histogram_to_return = histogram;
131 } else if (histogram == it->second) { 130 } else if (histogram == it->second) {
132 // The histogram was registered before. 131 // The histogram was registered before.
133 histogram_to_return = histogram; 132 histogram_to_return = histogram;
134 } else { 133 } else {
135 // We already have one histogram with this name. 134 // We already have one histogram with this name.
136 CHECK_EQ(histogram->histogram_name(), 135 DCHECK_EQ(histogram->histogram_name(),
137 it->second->histogram_name()) << "hash collision"; 136 it->second->histogram_name()) << "hash collision";
138 histogram_to_return = it->second; 137 histogram_to_return = it->second;
139 histogram_to_delete = histogram; 138 histogram_to_delete = histogram;
140 } 139 }
141 base::debug::Alias(&it);
142 base::debug::Alias(&name);
143 base::debug::Alias(&name_hash);
144 } 140 }
145 } 141 }
146 base::debug::Alias(&histogram);
147 delete histogram_to_delete; 142 delete histogram_to_delete;
148 return histogram_to_return; 143 return histogram_to_return;
149 } 144 }
150 145
151 // static 146 // static
152 const BucketRanges* StatisticsRecorder::RegisterOrDeleteDuplicateRanges( 147 const BucketRanges* StatisticsRecorder::RegisterOrDeleteDuplicateRanges(
153 const BucketRanges* ranges) { 148 const BucketRanges* ranges) {
154 DCHECK(ranges->HasValidChecksum()); 149 DCHECK(ranges->HasValidChecksum());
155 scoped_ptr<const BucketRanges> ranges_deleter; 150 scoped_ptr<const BucketRanges> ranges_deleter;
156 151
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 281 }
287 282
288 // static 283 // static
289 HistogramBase* StatisticsRecorder::FindHistogram(base::StringPiece name) { 284 HistogramBase* StatisticsRecorder::FindHistogram(base::StringPiece name) {
290 if (lock_ == NULL) 285 if (lock_ == NULL)
291 return NULL; 286 return NULL;
292 base::AutoLock auto_lock(*lock_); 287 base::AutoLock auto_lock(*lock_);
293 if (histograms_ == NULL) 288 if (histograms_ == NULL)
294 return NULL; 289 return NULL;
295 290
296 const uint64_t lookup_hash = HashMetricName(name); 291 HistogramMap::iterator it = histograms_->find(HashMetricName(name));
297 HistogramMap::iterator it = histograms_->find(lookup_hash);
298 if (histograms_->end() == it) 292 if (histograms_->end() == it)
299 return NULL; 293 return NULL;
300 294 DCHECK_EQ(name, it->second->histogram_name()) << "hash collision";
301 const uint64_t existing_hash = it->first;
302 const char* existing_name = it->second->histogram_name().c_str();
303 HistogramMap* histograms = histograms_;
304 CHECK_EQ(name, it->second->histogram_name()) << "hash collision";
305 base::debug::Alias(&lookup_hash);
306 base::debug::Alias(&existing_hash);
307 base::debug::Alias(&name);
308 base::debug::Alias(&existing_name);
309 base::debug::Alias(&it);
310 base::debug::Alias(&histograms);
311
312 return it->second; 295 return it->second;
313 } 296 }
314 297
315 // static 298 // static
316 StatisticsRecorder::HistogramIterator StatisticsRecorder::begin( 299 StatisticsRecorder::HistogramIterator StatisticsRecorder::begin(
317 bool include_persistent) { 300 bool include_persistent) {
318 return HistogramIterator(histograms_->begin(), include_persistent); 301 return HistogramIterator(histograms_->begin(), include_persistent);
319 } 302 }
320 303
321 // static 304 // static
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // static 457 // static
475 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; 458 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
476 // static 459 // static
477 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL; 460 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL;
478 // static 461 // static
479 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; 462 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL;
480 // static 463 // static
481 base::Lock* StatisticsRecorder::lock_ = NULL; 464 base::Lock* StatisticsRecorder::lock_ = NULL;
482 465
483 } // namespace base 466 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | chrome/browser/extensions/api/metrics_private/metrics_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698