Chromium Code Reviews| Index: base/test/histogram_recorder.h |
| diff --git a/base/test/histogram_recorder.h b/base/test/histogram_recorder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9edd982134f0783dd0f414dd954eb1b458733531 |
| --- /dev/null |
| +++ b/base/test/histogram_recorder.h |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_TEST_HISTOGRAM_RECORDER_H_ |
| +#define BASE_TEST_HISTOGRAM_RECORDER_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/metrics/histogram_samples.h" |
| + |
| +namespace base { |
| + |
| +// This class acts as a differential reader for histogram samples, enabling |
| +// tests to check that metrics were sent as they should be. |
| +class HistogramRecorder { |
| + public: |
| + // Constructor takes a histogram prefix. |
|
blundell
2013/07/10 14:35:36
Instead of this comment, have a comment explaining
lpromero
2013/07/10 17:08:33
Done.
|
| + explicit HistogramRecorder(const std::string& prefix); |
| + virtual ~HistogramRecorder(); |
| + |
| + // Returns the histogram data accumulated since this instance was created. |
| + // The returned pointer is owned by the HistogramRecorder instance and cannot |
| + // be used after that instance is destroyed. |
| + // Returns NULL if no samples are available. |
| + HistogramSamples* GetHistogramSamples(const std::string& histogram_name); |
|
blundell
2013/07/10 14:35:36
I think this would be more clear as GetHistogramSa
lpromero
2013/07/10 17:08:33
Done.
|
| + |
| + private: |
| + // Used to determine the histogram changes made during this instance's |
| + // lifecycle. |
| + std::map<std::string, HistogramSamples*> original_samples_; |
| + std::map<std::string, HistogramSamples*> samples_; |
| +}; |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_TEST_HISTOGRAM_RECORDER_H_ |