Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/test/base/chrome_histogram_tester.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/metrics/statistics_recorder.h" | |
| 9 #include "base/test/test_timeouts.h" | |
| 10 #include "chrome/test/base/ui_test_utils.h" | |
| 11 #include "content/public/browser/histogram_fetcher.h" | |
| 12 #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!
| |
| 13 | |
| 14 ChromeHistogramTester::ChromeHistogramTester() { | |
| 15 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.
| |
| 16 } | |
| 17 | |
| 18 ChromeHistogramTester::~ChromeHistogramTester() { | |
| 19 } | |
| 20 | |
| 21 | |
| 22 void ChromeHistogramTester::FetchTestingSnapshot() { | |
| 23 base::Closure callback = base::Bind(&ChromeHistogramTester::FetchCallback, | |
| 24 base::Unretained(this)); | |
| 25 | |
| 26 content::FetchHistogramsAsynchronously( | |
| 27 base::MessageLoop::current(), | |
| 28 callback, | |
| 29 // If this call times out, it means that a child process is not | |
| 30 // responding, which is something we should not ignore. The timeout is | |
| 31 // set to be longer than the normal browser test timeout so that it will | |
| 32 // be prempted by the normal timeout. | |
| 33 TestTimeouts::action_max_timeout() * 2); | |
| 34 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
| |
| 35 } | |
| 36 | |
| 37 | |
| 38 void ChromeHistogramTester::FetchCallback() { | |
| 39 base::MessageLoopForUI::current()->Quit(); | |
| 40 } | |
| OLD | NEW |