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

Side by Side Diff: chrome/common/metrics/metrics_log_base.cc

Issue 10834011: Refactor of Histogram related code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 "chrome/common/metrics/metrics_log_base.h" 5 #include "chrome/common/metrics/metrics_log_base.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "base/perftimer.h" 10 #include "base/perftimer.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 445
446 // TODO(JAR): A The following should really be part of the histogram class. 446 // TODO(JAR): A The following should really be part of the histogram class.
447 // Internal state is being needlessly exposed, and it would be hard to reuse 447 // Internal state is being needlessly exposed, and it would be hard to reuse
448 // this code. If we moved this into the Histogram class, then we could use 448 // this code. If we moved this into the Histogram class, then we could use
449 // the same infrastructure for logging StatsCounters, RatesCounters, etc. 449 // the same infrastructure for logging StatsCounters, RatesCounters, etc.
450 void MetricsLogBase::RecordHistogramDelta( 450 void MetricsLogBase::RecordHistogramDelta(
451 const Histogram& histogram, 451 const Histogram& histogram,
452 const Histogram::SampleSet& snapshot) { 452 const Histogram::SampleSet& snapshot) {
453 DCHECK(!locked_); 453 DCHECK(!locked_);
454 DCHECK_NE(0, snapshot.TotalCount()); 454 DCHECK_NE(0, snapshot.TotalCount());
455 snapshot.CheckSize(histogram); 455 DCHECK_EQ(histogram.bucket_count(), snapshot.size());
456 456
457 // We will ignore the MAX_INT/infinite value in the last element of range[]. 457 // We will ignore the MAX_INT/infinite value in the last element of range[].
458 458
459 OPEN_ELEMENT_FOR_SCOPE("histogram"); 459 OPEN_ELEMENT_FOR_SCOPE("histogram");
460 460
461 std::string base64_name_hash; 461 std::string base64_name_hash;
462 uint64 numeric_name_hash; 462 uint64 numeric_name_hash;
463 CreateHashes(histogram.histogram_name(), 463 CreateHashes(histogram.histogram_name(),
464 &base64_name_hash, 464 &base64_name_hash,
465 &numeric_name_hash); 465 &numeric_name_hash);
(...skipping 22 matching lines...) Expand all
488 for (size_t i = 0; i < histogram.bucket_count(); ++i) { 488 for (size_t i = 0; i < histogram.bucket_count(); ++i) {
489 if (snapshot.counts(i)) { 489 if (snapshot.counts(i)) {
490 HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket(); 490 HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket();
491 bucket->set_min(histogram.ranges(i)); 491 bucket->set_min(histogram.ranges(i));
492 bucket->set_max(histogram.ranges(i + 1)); 492 bucket->set_max(histogram.ranges(i + 1));
493 bucket->set_bucket_index(i); 493 bucket->set_bucket_index(i);
494 bucket->set_count(snapshot.counts(i)); 494 bucket->set_count(snapshot.counts(i));
495 } 495 }
496 } 496 }
497 } 497 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698