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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 void HistogramSender::TransmitHistogram(const Histogram& histogram) { | 527 void HistogramSender::TransmitHistogram(const Histogram& histogram) { |
528 // Get up-to-date snapshot of sample stats. | 528 // Get up-to-date snapshot of sample stats. |
529 Histogram::SampleSet snapshot; | 529 Histogram::SampleSet snapshot; |
530 histogram.SnapshotSample(&snapshot); | 530 histogram.SnapshotSample(&snapshot); |
531 const std::string& histogram_name = histogram.histogram_name(); | 531 const std::string& histogram_name = histogram.histogram_name(); |
532 | 532 |
533 int corruption = histogram.FindCorruption(snapshot); | 533 int corruption = histogram.FindCorruption(snapshot); |
| 534 |
| 535 // Crash if we detect that our histograms have been overwritten. This may be |
| 536 // a fair distance from the memory smasher, but we hope to correlate these |
| 537 // crashes with other events, such as plugins, or usage patterns, etc. |
| 538 if (Histogram::BUCKET_ORDER_ERROR & corruption) { |
| 539 // The checksum should have caught this, so crash separately if it didn't. |
| 540 CHECK_NE(0, Histogram::RANGE_CHECKSUM_ERROR & corruption); |
| 541 CHECK(false); // Crash for the bucket order corruption. |
| 542 } |
| 543 // Checksum corruption might not have caused order corruption. |
| 544 CHECK_EQ(0, Histogram::RANGE_CHECKSUM_ERROR & corruption); |
| 545 |
534 if (corruption) { | 546 if (corruption) { |
535 NOTREACHED(); | 547 NOTREACHED(); |
536 InconsistencyDetected(corruption); | 548 InconsistencyDetected(corruption); |
537 // Don't send corrupt data to metrics survices. | 549 // Don't send corrupt data to metrics survices. |
538 if (NULL == inconsistencies_.get()) | 550 if (NULL == inconsistencies_.get()) |
539 inconsistencies_.reset(new ProblemMap); | 551 inconsistencies_.reset(new ProblemMap); |
540 int old_corruption = (*inconsistencies_)[histogram_name]; | 552 int old_corruption = (*inconsistencies_)[histogram_name]; |
541 if (old_corruption == (corruption | old_corruption)) | 553 if (old_corruption == (corruption | old_corruption)) |
542 return; // We've already seen this corruption for this histogram. | 554 return; // We've already seen this corruption for this histogram. |
543 (*inconsistencies_)[histogram_name] |= corruption; | 555 (*inconsistencies_)[histogram_name] |= corruption; |
(...skipping 28 matching lines...) Expand all Loading... |
572 snapshot.Subtract(*already_logged); | 584 snapshot.Subtract(*already_logged); |
573 } | 585 } |
574 | 586 |
575 // Snapshot now contains only a delta to what we've already_logged. | 587 // Snapshot now contains only a delta to what we've already_logged. |
576 if (snapshot.redundant_count() > 0) { | 588 if (snapshot.redundant_count() > 0) { |
577 TransmitHistogramDelta(histogram, snapshot); | 589 TransmitHistogramDelta(histogram, snapshot); |
578 // Add new data into our running total. | 590 // Add new data into our running total. |
579 already_logged->Add(snapshot); | 591 already_logged->Add(snapshot); |
580 } | 592 } |
581 } | 593 } |
OLD | NEW |