OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_helpers.h" | 5 #include "chrome/common/metrics_helpers.h" |
6 | 6 |
7 #if defined(USE_SYSTEM_LIBBZ2) | 7 #if defined(USE_SYSTEM_LIBBZ2) |
8 #include <bzlib.h> | 8 #include <bzlib.h> |
9 #else | 9 #else |
10 #include "third_party/bzip2/bzlib.h" | 10 #include "third_party/bzip2/bzlib.h" |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 ++it) { | 477 ++it) { |
478 if ((*it)->flags() & Histogram::kUmaTargetedHistogramFlag) | 478 if ((*it)->flags() & Histogram::kUmaTargetedHistogramFlag) |
479 RecordHistogram(**it); | 479 RecordHistogram(**it); |
480 } | 480 } |
481 } | 481 } |
482 | 482 |
483 void MetricsServiceBase::RecordHistogram(const Histogram& histogram) { | 483 void MetricsServiceBase::RecordHistogram(const Histogram& histogram) { |
484 // Get up-to-date snapshot of sample stats. | 484 // Get up-to-date snapshot of sample stats. |
485 Histogram::SampleSet snapshot; | 485 Histogram::SampleSet snapshot; |
486 histogram.SnapshotSample(&snapshot); | 486 histogram.SnapshotSample(&snapshot); |
| 487 const std::string& histogram_name = histogram.histogram_name(); |
487 | 488 |
488 const std::string& histogram_name = histogram.histogram_name(); | 489 int corruption = histogram.FindCorruption(snapshot); |
| 490 if (corruption) { |
| 491 NOTREACHED(); |
| 492 // Don't send corrupt data to metrics survices. |
| 493 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser", |
| 494 corruption, Histogram::NEVER_EXCEEDED_VALUE); |
| 495 typedef std::map<std::string, int> ProblemMap; |
| 496 static ProblemMap* inconsistencies = new ProblemMap; |
| 497 int old_corruption = (*inconsistencies)[histogram_name]; |
| 498 if (old_corruption == (corruption | old_corruption)) |
| 499 return; // We've already seen this corruption for this histogram. |
| 500 (*inconsistencies)[histogram_name] |= corruption; |
| 501 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique", |
| 502 corruption, Histogram::NEVER_EXCEEDED_VALUE); |
| 503 return; |
| 504 } |
489 | 505 |
490 // Find the already sent stats, or create an empty set. | 506 // Find the already sent stats, or create an empty set. |
491 LoggedSampleMap::iterator it = logged_samples_.find(histogram_name); | 507 LoggedSampleMap::iterator it = logged_samples_.find(histogram_name); |
492 Histogram::SampleSet* already_logged; | 508 Histogram::SampleSet* already_logged; |
493 if (logged_samples_.end() == it) { | 509 if (logged_samples_.end() == it) { |
494 // Add new entry | 510 // Add new entry |
495 already_logged = &logged_samples_[histogram.histogram_name()]; | 511 already_logged = &logged_samples_[histogram.histogram_name()]; |
496 already_logged->Resize(histogram); // Complete initialization. | 512 already_logged->Resize(histogram); // Complete initialization. |
497 } else { | 513 } else { |
498 already_logged = &(it->second); | 514 already_logged = &(it->second); |
(...skipping 10 matching lines...) Expand all Loading... |
509 } | 525 } |
510 } | 526 } |
511 | 527 |
512 void MetricsServiceBase::DiscardPendingLog() { | 528 void MetricsServiceBase::DiscardPendingLog() { |
513 if (pending_log_) { // Shutdown might have deleted it! | 529 if (pending_log_) { // Shutdown might have deleted it! |
514 delete pending_log_; | 530 delete pending_log_; |
515 pending_log_ = NULL; | 531 pending_log_ = NULL; |
516 } | 532 } |
517 compressed_log_.clear(); | 533 compressed_log_.clear(); |
518 } | 534 } |
OLD | NEW |