Commit e58234cc authored by kaiwang@chromium.org's avatar kaiwang@chromium.org

Add comments to HistogramFlatterner interface and rename a function

Review URL: https://chromiumcodereview.appspot.com/10857067

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152434 0039d316-1c4b-4281-b951-d872f2087c98
parent 33ca7f66
...@@ -14,18 +14,28 @@ ...@@ -14,18 +14,28 @@
namespace base { namespace base {
// HistogramFlattener is an interface for the logistics of gathering up // HistogramFlattener is an interface used by HistogramSnapshotManager, which
// available histograms for recording. The implementors handle the exact lower // handles the logistics of gathering up available histograms for recording.
// level recording mechanism, or error report mechanism. // The implementors handle the exact lower level recording mechanism, or
// error report mechanism.
class BASE_EXPORT HistogramFlattener { class BASE_EXPORT HistogramFlattener {
public: public:
virtual void RecordDelta(const base::Histogram& histogram, virtual void RecordDelta(const base::Histogram& histogram,
const base::Histogram::SampleSet& snapshot) = 0; const base::Histogram::SampleSet& snapshot) = 0;
// Record various errors found during attempts to record histograms. // Will be called each time a type of Inconsistenies is seen on a histogram,
virtual void InconsistencyDetected(int problem) = 0; // during inspections done internally in HistogramSnapshotManager class.
virtual void UniqueInconsistencyDetected(int problem) = 0; virtual void InconsistencyDetected(Histogram::Inconsistencies problem) = 0;
virtual void SnapshotProblemResolved(int amount) = 0;
// Will be called when a type of Inconsistenies is seen for the first time
// on a histogram.
virtual void UniqueInconsistencyDetected(
Histogram::Inconsistencies problem) = 0;
// Will be called when the total logged sample count of a histogram
// differs from the sum of logged sample count in all the buckets. The
// argument |amount| is the non-zero discrepancy.
virtual void InconsistencyDetectedInLoggedCount(int amount) = 0;
protected: protected:
HistogramFlattener() {} HistogramFlattener() {}
......
...@@ -55,9 +55,13 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) { ...@@ -55,9 +55,13 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
// Checksum corruption might not have caused order corruption. // Checksum corruption might not have caused order corruption.
CHECK_EQ(0, Histogram::RANGE_CHECKSUM_ERROR & corruption); CHECK_EQ(0, Histogram::RANGE_CHECKSUM_ERROR & corruption);
// Note, at this point corruption can only be COUNT_HIGH_ERROR or
// COUNT_LOW_ERROR and they never arise together, so we don't need to extract
// bits from corruption.
if (corruption) { if (corruption) {
NOTREACHED(); NOTREACHED();
histogram_flattener_->InconsistencyDetected(corruption); histogram_flattener_->InconsistencyDetected(
static_cast<Histogram::Inconsistencies>(corruption));
// Don't record corrupt data to metrics survices. // Don't record corrupt data to metrics survices.
if (NULL == inconsistencies_.get()) if (NULL == inconsistencies_.get())
inconsistencies_.reset(new ProblemMap); inconsistencies_.reset(new ProblemMap);
...@@ -65,7 +69,8 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) { ...@@ -65,7 +69,8 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
if (old_corruption == (corruption | old_corruption)) if (old_corruption == (corruption | old_corruption))
return; // We've already seen this corruption for this histogram. return; // We've already seen this corruption for this histogram.
(*inconsistencies_)[histogram_name] |= corruption; (*inconsistencies_)[histogram_name] |= corruption;
histogram_flattener_->UniqueInconsistencyDetected(corruption); histogram_flattener_->UniqueInconsistencyDetected(
static_cast<Histogram::Inconsistencies>(corruption));
return; return;
} }
...@@ -87,7 +92,7 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) { ...@@ -87,7 +92,7 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
int problem = static_cast<int>(discrepancy); int problem = static_cast<int>(discrepancy);
if (problem != discrepancy) if (problem != discrepancy)
problem = INT_MAX; problem = INT_MAX;
histogram_flattener_->SnapshotProblemResolved(problem); histogram_flattener_->InconsistencyDetectedInLoggedCount(problem);
// With no valid baseline, we'll act like we've recorded everything in our // With no valid baseline, we'll act like we've recorded everything in our
// snapshot. // snapshot.
already_logged->Subtract(*already_logged); already_logged->Subtract(*already_logged);
......
...@@ -41,17 +41,19 @@ void MetricsServiceBase::RecordDelta( ...@@ -41,17 +41,19 @@ void MetricsServiceBase::RecordDelta(
log_manager_.current_log()->RecordHistogramDelta(histogram, snapshot); log_manager_.current_log()->RecordHistogramDelta(histogram, snapshot);
} }
void MetricsServiceBase::InconsistencyDetected(int problem) { void MetricsServiceBase::InconsistencyDetected(
Histogram::Inconsistencies problem) {
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser", UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser",
problem, Histogram::NEVER_EXCEEDED_VALUE); problem, Histogram::NEVER_EXCEEDED_VALUE);
} }
void MetricsServiceBase::UniqueInconsistencyDetected(int problem) { void MetricsServiceBase::UniqueInconsistencyDetected(
Histogram::Inconsistencies problem) {
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique", UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique",
problem, Histogram::NEVER_EXCEEDED_VALUE); problem, Histogram::NEVER_EXCEEDED_VALUE);
} }
void MetricsServiceBase::SnapshotProblemResolved(int amount) { void MetricsServiceBase::InconsistencyDetectedInLoggedCount(int amount) {
UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser", UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser",
std::abs(amount)); std::abs(amount));
} }
...@@ -19,9 +19,11 @@ class MetricsServiceBase : public base::HistogramFlattener { ...@@ -19,9 +19,11 @@ class MetricsServiceBase : public base::HistogramFlattener {
// HistogramFlattener interface (override) methods. // HistogramFlattener interface (override) methods.
virtual void RecordDelta(const base::Histogram& histogram, virtual void RecordDelta(const base::Histogram& histogram,
const base::Histogram::SampleSet& snapshot) OVERRIDE; const base::Histogram::SampleSet& snapshot) OVERRIDE;
virtual void InconsistencyDetected(int problem) OVERRIDE; virtual void InconsistencyDetected(
virtual void UniqueInconsistencyDetected(int problem) OVERRIDE; base::Histogram::Inconsistencies problem) OVERRIDE;
virtual void SnapshotProblemResolved(int amount) OVERRIDE; virtual void UniqueInconsistencyDetected(
base::Histogram::Inconsistencies problem) OVERRIDE;
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
protected: protected:
MetricsServiceBase(); MetricsServiceBase();
......
...@@ -81,17 +81,20 @@ void ChildHistogramMessageFilter::RecordDelta( ...@@ -81,17 +81,20 @@ void ChildHistogramMessageFilter::RecordDelta(
pickled_histograms_.push_back(histogram_info); pickled_histograms_.push_back(histogram_info);
} }
void ChildHistogramMessageFilter::InconsistencyDetected(int problem) { void ChildHistogramMessageFilter::InconsistencyDetected(
base::Histogram::Inconsistencies problem) {
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcess", UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcess",
problem, base::Histogram::NEVER_EXCEEDED_VALUE); problem, base::Histogram::NEVER_EXCEEDED_VALUE);
} }
void ChildHistogramMessageFilter::UniqueInconsistencyDetected(int problem) { void ChildHistogramMessageFilter::UniqueInconsistencyDetected(
base::Histogram::Inconsistencies problem) {
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcessUnique", UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcessUnique",
problem, base::Histogram::NEVER_EXCEEDED_VALUE); problem, base::Histogram::NEVER_EXCEEDED_VALUE);
} }
void ChildHistogramMessageFilter::SnapshotProblemResolved(int amount) { void ChildHistogramMessageFilter::InconsistencyDetectedInLoggedCount(
int amount) {
UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotChildProcess", UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotChildProcess",
std::abs(amount)); std::abs(amount));
} }
......
...@@ -33,9 +33,11 @@ class ChildHistogramMessageFilter : public base::HistogramFlattener, ...@@ -33,9 +33,11 @@ class ChildHistogramMessageFilter : public base::HistogramFlattener,
// HistogramFlattener interface (override) methods. // HistogramFlattener interface (override) methods.
virtual void RecordDelta(const base::Histogram& histogram, virtual void RecordDelta(const base::Histogram& histogram,
const base::Histogram::SampleSet& snapshot) OVERRIDE; const base::Histogram::SampleSet& snapshot) OVERRIDE;
virtual void InconsistencyDetected(int problem) OVERRIDE; virtual void InconsistencyDetected(
virtual void UniqueInconsistencyDetected(int problem) OVERRIDE; base::Histogram::Inconsistencies problem) OVERRIDE;
virtual void SnapshotProblemResolved(int amount) OVERRIDE; virtual void UniqueInconsistencyDetected(
base::Histogram::Inconsistencies problem) OVERRIDE;
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
private: private:
typedef std::vector<std::string> HistogramPickledList; typedef std::vector<std::string> HistogramPickledList;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment