Index: chrome/test/base/chrome_histogram_tester.cc |
diff --git a/chrome/test/base/chrome_histogram_tester.cc b/chrome/test/base/chrome_histogram_tester.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..58434d16f1bca86eeb9cfa1ae466adf3a05db58c |
--- /dev/null |
+++ b/chrome/test/base/chrome_histogram_tester.cc |
@@ -0,0 +1,40 @@ |
+// Copyright (c) 2012 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. |
+ |
+#include "chrome/test/base/chrome_histogram_tester.h" |
+ |
+#include "base/bind.h" |
+#include "base/metrics/statistics_recorder.h" |
+#include "base/test/test_timeouts.h" |
+#include "chrome/test/base/ui_test_utils.h" |
+#include "content/public/browser/histogram_fetcher.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
Ilya Sherman
2014/07/15 03:56:35
nit: Is this include needed?
Mike Lerman
2014/07/16 17:29:04
Nope!
|
+ |
+ChromeHistogramTester::ChromeHistogramTester() { |
+ base::StatisticsRecorder::Initialize(); |
Ilya Sherman
2014/07/15 03:56:35
This is already called by the base class's constru
Mike Lerman
2014/07/16 17:29:04
Done.
|
+} |
+ |
+ChromeHistogramTester::~ChromeHistogramTester() { |
+} |
+ |
+ |
+void ChromeHistogramTester::FetchTestingSnapshot() { |
+ base::Closure callback = base::Bind(&ChromeHistogramTester::FetchCallback, |
+ base::Unretained(this)); |
+ |
+ content::FetchHistogramsAsynchronously( |
+ base::MessageLoop::current(), |
+ callback, |
+ // If this call times out, it means that a child process is not |
+ // responding, which is something we should not ignore. The timeout is |
+ // set to be longer than the normal browser test timeout so that it will |
+ // be prempted by the normal timeout. |
+ TestTimeouts::action_max_timeout() * 2); |
+ content::RunMessageLoop(); |
Ilya Sherman
2014/07/15 03:56:35
Is it possible for content::FetchHistogramsAsynchr
Mike Lerman
2014/07/16 17:29:04
I don't think there's a way for it to be run synch
|
+} |
+ |
+ |
+void ChromeHistogramTester::FetchCallback() { |
+ base::MessageLoopForUI::current()->Quit(); |
+} |