Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: base/test/histogram_recorder.h

Issue 18337014: Add a HistogramRecorder class and use cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..85139bd8b05f9e45aa6c95f2691b512f7be3e790
--- /dev/null
+++ b/base/test/histogram_recorder.h
@@ -0,0 +1,35 @@
+// 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/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 sent as they should be.
+class HistogramRecorder {
+ public:
+ HistogramRecorder();
+ virtual ~HistogramRecorder();
+
+ // 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.
+ std::map<std::string, HistogramSamples*> original_samples_;
+};
+
+} // namespace base
+
+#endif // BASE_TEST_HISTOGRAM_RECORDER_H_

Powered by Google App Engine
This is Rietveld 408576698