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

Unified Diff: components/scheduler/base/task_queue_manager_unittest.cc

Issue 1468443002: Reduce the number of delayed tasks on chromium run loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Weak pointer Created 5 years, 1 month 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
« no previous file with comments | « components/scheduler/base/task_queue_manager.cc ('k') | components/scheduler/base/time_domain.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/base/task_queue_manager_unittest.cc
diff --git a/components/scheduler/base/task_queue_manager_unittest.cc b/components/scheduler/base/task_queue_manager_unittest.cc
index d5ad8e5a0650bedfd21cbb5b06c59e82898be773..251ac56523ae93077f53192525332fa6f95d4c9c 100644
--- a/components/scheduler/base/task_queue_manager_unittest.cc
+++ b/components/scheduler/base/task_queue_manager_unittest.cc
@@ -1458,4 +1458,28 @@ TEST_F(TaskQueueManagerTest, TimeDomainMigration) {
manager_->UnregisterTimeDomain(domain_b);
}
+namespace {
+void ChromiumRunloopInspectionTask(
+ scoped_refptr<cc::OrderedSimpleTaskRunner> test_task_runner) {
+ EXPECT_EQ(1u, test_task_runner->NumPendingTasks());
+}
+} // namespace
+
+TEST_F(TaskQueueManagerTest, NumberOfPendingTasksOnChromiumRunLoop) {
+ Initialize(1u);
+
+ // NOTE because tasks posted to the chromiumrun loop are not cancellable, we
+ // will end up with a lot more tasks posted if the delayed tasks were posted
+ // in the reverse order.
+ // TODO(alexclarke): Consider talking to the message pump directly.
+ test_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
+ for (int i = 1; i < 100; i++) {
+ runners_[0]->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ChromiumRunloopInspectionTask, test_task_runner_),
+ base::TimeDelta::FromMilliseconds(i));
+ }
+ test_task_runner_->RunUntilIdle();
+}
+
} // namespace scheduler
« no previous file with comments | « components/scheduler/base/task_queue_manager.cc ('k') | components/scheduler/base/time_domain.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698