| Index: chrome/browser/performance_monitor/performance_monitor_browsertest.cc
|
| diff --git a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc
|
| index a343e042f3f93c9dcd7a79d785cac69603640b8a..58b4cac6c714ba620cfaf5551fa6be85fc010918 100644
|
| --- a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc
|
| +++ b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc
|
| @@ -161,25 +161,24 @@ class PerformanceMonitorBrowserTest : public ExtensionBrowserTest {
|
| chrome::NOTIFICATION_PERFORMANCE_MONITOR_INITIALIZED,
|
| content::NotificationService::AllSources());
|
|
|
| + // We stop the timer in charge of doing timed collections so that we can
|
| + // enforce when, and how many times, we do these collections.
|
| + performance_monitor_->DisableTimerAutostartForTesting();
|
| + performance_monitor_->EnableDatabaseLoggingForTesting();
|
| +
|
| performance_monitor_->Start();
|
|
|
| windowed_observer.Wait();
|
| -
|
| - // We stop the timer in charge of doing timed collections so that we can
|
| - // enforce when, and how many times, we do these collections.
|
| - performance_monitor_->timer_.Stop();
|
| }
|
|
|
| // A handle for gathering statistics from the database, which must be done on
|
| // the background thread. Since we are testing, we can mock synchronicity with
|
| // FlushForTesting().
|
| void GatherStatistics() {
|
| - content::BrowserThread::PostBlockingPoolSequencedTask(
|
| - Database::kDatabaseSequenceToken,
|
| - FROM_HERE,
|
| - base::Bind(&PerformanceMonitor::GatherStatisticsOnBackgroundThread,
|
| - base::Unretained(performance_monitor())));
|
| + performance_monitor_->ResetCollectionTimeForTesting();
|
| + performance_monitor_->DoTimedCollections();
|
|
|
| + RunAllPendingInMessageLoop(content::BrowserThread::IO);
|
| content::BrowserThread::GetBlockingPool()->FlushForTesting();
|
| }
|
|
|
| @@ -772,11 +771,7 @@ IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, NetworkBytesRead) {
|
| browser(),
|
| test_server()->GetURL(std::string("files/").append("title1.html")));
|
|
|
| - performance_monitor()->DoTimedCollections();
|
| -
|
| - // Since network bytes are read and set on the IO thread, we must flush this
|
| - // additional thread to be sure that all messages are run.
|
| - RunAllPendingInMessageLoop(content::BrowserThread::IO);
|
| + GatherStatistics();
|
|
|
| Database::MetricVector metrics = GetStats(METRIC_NETWORK_BYTES_READ);
|
| ASSERT_EQ(1u, metrics.size());
|
| @@ -789,7 +784,7 @@ IN_PROC_BROWSER_TEST_F(PerformanceMonitorBrowserTest, NetworkBytesRead) {
|
| browser(),
|
| test_server()->GetURL(std::string("files/").append("title2.html")));
|
|
|
| - performance_monitor()->DoTimedCollections();
|
| + GatherStatistics();
|
|
|
| metrics = GetStats(METRIC_NETWORK_BYTES_READ);
|
| ASSERT_EQ(2u, metrics.size());
|
|
|