Chromium Code Reviews| Index: chrome/test/base/uma_histogram_helper.h |
| diff --git a/chrome/test/base/uma_histogram_helper.h b/chrome/test/base/uma_histogram_helper.h |
| index 76e841fcfd3651266eb709273d8a9b20d44ff400..850d9053707381c793e157f0ad5755d317fcc7d9 100644 |
| --- a/chrome/test/base/uma_histogram_helper.h |
| +++ b/chrome/test/base/uma_histogram_helper.h |
| @@ -14,25 +14,36 @@ |
| // intended. |
| class UMAHistogramHelper { |
| public: |
| + // UMAHistogramHelper should be created before the execution of the test case. |
| UMAHistogramHelper(); |
| + ~UMAHistogramHelper(); |
| + |
| + // Parameters should be string literals of all histograms to snapshot. |
| + // Call this before executing the test code. |
| + void PrepareSnapshot(const char* histogram_names[], int num_histograms); |
|
Ilya Sherman
2014/06/13 19:58:12
nit: "int" -> "size_t"
Ilya Sherman
2014/06/13 19:58:12
Actually, is this function needed at all? Why not
Ilya Sherman
2014/06/13 19:58:12
nit: "const char*" -> "const char* const"
Mike Lerman
2014/06/16 14:59:13
Done.
Mike Lerman
2014/06/16 14:59:14
Efficiency's sake? There can be dozens if not hund
Mike Lerman
2014/06/16 14:59:14
Done.
Ilya Sherman
2014/06/16 18:11:29
I'm not convinced that the small bit of efficiency
|
| + |
| // Each child process may have its own histogram data, make sure this data |
| // gets accumulated into the browser process before we examine the histograms. |
| void Fetch(); |
| // We know the exact number of samples in a bucket, and that no other bucket |
| - // should have samples. |
| + // should have samples. If |PrepareSnapshot| was called for |name| histogram, |
|
Ilya Sherman
2014/06/13 19:58:12
nit: "for |name| histogram" -> "for the histogram
Mike Lerman
2014/06/16 14:59:14
Done.
|
| + // then the |expected_count| is the diff from the snapshot. |
|
Ilya Sherman
2014/06/13 19:58:12
Is it worth documenting what happens if PrepareSna
Mike Lerman
2014/06/16 14:59:14
Yes. I wrote wordy text, but would almost rather r
|
| void ExpectUniqueSample(const std::string& name, |
| base::HistogramBase::Sample sample, |
| base::HistogramBase::Count expected_count); |
| // We know the exact number of samples in a bucket, but other buckets may |
| - // have samples as well. |
| + // have samples as well. If |PrepareSnapshot| was called for |name| histogram, |
| + // then the |expected_count| is the diff from the snapshot. |
| void ExpectBucketCount(const std::string& name, |
| base::HistogramBase::Sample sample, |
| base::HistogramBase::Count expected_count); |
| - // We don't know the values of the samples, but we know how many there are. |
| + // We don't know the values of the samples, but we know how many there are. If |
| + // |PrepareSnapshot| was called for |name| histogram, then the |
| + // |count| is the diff from the snapshot. |
| void ExpectTotalCount(const std::string& name, |
| base::HistogramBase::Count count); |
| @@ -49,6 +60,10 @@ class UMAHistogramHelper { |
| base::HistogramSamples& samples); |
| DISALLOW_COPY_AND_ASSIGN(UMAHistogramHelper); |
| + |
| + // The map from histogram names to their snapshots |
| + std::map<std::string, scoped_ptr<base::HistogramSamples> > |
|
Ilya Sherman
2014/06/13 19:58:12
Hmm, I'm like 99% sure that scoped_ptrs aren't saf
Mike Lerman
2014/06/16 14:59:14
Good to know. I'll go with a linked_ptr. Since I'm
|
| + histogram_snapshots; |
| }; |
| #endif // CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ |