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

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

Issue 1726873002: Report histogram creation results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some 'git cl format' changes 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/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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 base::AutoLock auto_lock(*lock_); 362 base::AutoLock auto_lock(*lock_);
363 if (histograms_ == NULL) 363 if (histograms_ == NULL)
364 return OnSampleCallback(); 364 return OnSampleCallback();
365 365
366 auto callback_iterator = callbacks_->find(name); 366 auto callback_iterator = callbacks_->find(name);
367 return callback_iterator != callbacks_->end() ? callback_iterator->second 367 return callback_iterator != callbacks_->end() ? callback_iterator->second
368 : OnSampleCallback(); 368 : OnSampleCallback();
369 } 369 }
370 370
371 // static 371 // static
372 size_t StatisticsRecorder::NumberOfHistograms() {
Alexei Svitkine (slow) 2016/03/01 16:41:34 Nit: GetHistogramCount()
bcwhite 2016/03/02 19:14:19 Done.
373 if (!lock_)
374 return 0;
375
376 base::AutoLock auto_lock(*lock_);
377 if (!histograms_)
378 return 0;
379 return histograms_->size();
380 }
381
382 // static
372 void StatisticsRecorder::ResetForTesting() { 383 void StatisticsRecorder::ResetForTesting() {
373 // Just call the private version that is used also by the destructor. 384 // Just call the private version that is used also by the destructor.
374 Reset(); 385 Reset();
375 } 386 }
376 387
377 // static 388 // static
378 void StatisticsRecorder::ForgetHistogramForTesting(base::StringPiece name) { 389 void StatisticsRecorder::ForgetHistogramForTesting(base::StringPiece name) {
379 if (histograms_) 390 if (histograms_)
380 histograms_->erase(HashMetricName(name.as_string())); 391 histograms_->erase(HashMetricName(name.as_string()));
381 } 392 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // static 455 // static
445 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; 456 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
446 // static 457 // static
447 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL; 458 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL;
448 // static 459 // static
449 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; 460 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL;
450 // static 461 // static
451 base::Lock* StatisticsRecorder::lock_ = NULL; 462 base::Lock* StatisticsRecorder::lock_ = NULL;
452 463
453 } // namespace base 464 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698