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..f867b1e0944df5a823d5641ab607576600d2239d |
| --- /dev/null |
| +++ b/base/test/histogram_recorder.h |
| @@ -0,0 +1,44 @@ |
| +// 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/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#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 recorded as they should be. |
|
ppi
2013/12/23 16:37:48
I suggest:
"This class acts as a differential rea
|
| +class HistogramRecorder { |
|
ppi
2013/12/23 16:37:48
Let's rename it to HistogramDeltaReader ?
|
| + public: |
| + // Initializes the HistogramRecorder system. |
| + static void Initialize(); |
|
ppi
2013/12/23 16:37:48
Clients can call StatisticsRecorder::Initialize()
|
| + HistogramRecorder(); |
| + virtual ~HistogramRecorder(); |
| + |
| + // Returns whether the HistogramRecorder has been initialized. |
| + static bool IsActive(); |
|
ppi
2013/12/23 16:37:48
What do we need that for? See also the comment abo
|
| + |
| + // Returns the histogram data accumulated since this instance was created. |
| + // Returns NULL if no samples are available. |
| + scoped_ptr<HistogramSamples> GetHistogramSamplesSinceCreation( |
| + const std::string& histogram_name); |
| + |
| + private: |
| + // Used to determine the histogram changes made during this instance's |
| + // lifecycle. This isntance takes ownership of the samples, which are deleted |
| + // when the instance is destroyed. |
| + std::map<std::string, HistogramSamples*> original_samples_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HistogramRecorder); |
| +}; |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_TEST_HISTOGRAM_RECORDER_H_ |