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

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

Issue 1485763002: Merge multiple histogram snapshots into single one for reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: Change 'inconsistencies' from int to unsigned. Created 4 years, 10 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 base::AutoLock auto_lock(*lock_); 385 base::AutoLock auto_lock(*lock_);
386 histograms_ = new HistogramMap; 386 histograms_ = new HistogramMap;
387 callbacks_ = new CallbackMap; 387 callbacks_ = new CallbackMap;
388 ranges_ = new RangesMap; 388 ranges_ = new RangesMap;
389 389
390 if (VLOG_IS_ON(1)) 390 if (VLOG_IS_ON(1))
391 AtExitManager::RegisterCallback(&DumpHistogramsToVlog, this); 391 AtExitManager::RegisterCallback(&DumpHistogramsToVlog, this);
392 } 392 }
393 393
394 // static 394 // static
395 void StatisticsRecorder::ResetForTesting() {
Alexei Svitkine (slow) 2016/02/17 16:21:12 Please order this same as in the .h file - i.e. ab
bcwhite 2016/02/17 17:58:20 This is being moved into another CL.
Alexei Svitkine (slow) 2016/02/17 18:15:16 So should it be deleted from this CL? Or are you p
bcwhite 2016/02/17 19:39:50 The latter. I think the other one is ready to lan
396 if (histograms_) {
397 STLDeleteValues(histograms_);
398 delete histograms_;
399 histograms_= nullptr;
400 }
401 if (ranges_) {
402 for (auto& iter : *ranges_) {
403 STLDeleteElements(iter.second);
404 delete iter.second;
405 }
406 delete ranges_;
407 ranges_ = nullptr;
408 }
409 delete callbacks_;
410 callbacks_ = nullptr;
Alexei Svitkine (slow) 2016/02/17 16:21:12 A lot of this code is similar to what's done in th
bcwhite 2016/02/17 17:58:20 This is being moved into another CL. It turns out
411 }
412
413 // static
395 void StatisticsRecorder::DumpHistogramsToVlog(void* instance) { 414 void StatisticsRecorder::DumpHistogramsToVlog(void* instance) {
396 std::string output; 415 std::string output;
397 StatisticsRecorder::WriteGraph(std::string(), &output); 416 StatisticsRecorder::WriteGraph(std::string(), &output);
398 VLOG(1) << output; 417 VLOG(1) << output;
399 } 418 }
400 419
401 StatisticsRecorder::~StatisticsRecorder() { 420 StatisticsRecorder::~StatisticsRecorder() {
402 DCHECK(histograms_ && ranges_ && lock_); 421 DCHECK(histograms_ && ranges_ && lock_);
403 422
404 // Clean up. 423 // Clean up.
(...skipping 18 matching lines...) Expand all
423 // static 442 // static
424 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; 443 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
425 // static 444 // static
426 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL; 445 StatisticsRecorder::CallbackMap* StatisticsRecorder::callbacks_ = NULL;
427 // static 446 // static
428 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL; 447 StatisticsRecorder::RangesMap* StatisticsRecorder::ranges_ = NULL;
429 // static 448 // static
430 base::Lock* StatisticsRecorder::lock_ = NULL; 449 base::Lock* StatisticsRecorder::lock_ = NULL;
431 450
432 } // namespace base 451 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698