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

Unified Diff: base/task_scheduler/task_scheduler_impl_unittest.cc

Issue 2829083002: Add constexpr TaskTraits constructor. (Closed)
Patch Set: fix-android-build-error Created 3 years, 8 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/task_scheduler/task_scheduler_impl_unittest.cc
diff --git a/base/task_scheduler/task_scheduler_impl_unittest.cc b/base/task_scheduler/task_scheduler_impl_unittest.cc
index b8d8fad8343808296bff8dd7acedba946bdf8e4e..2f6ba8198d2998f43cf99bd060fb2db2a870caad 100644
--- a/base/task_scheduler/task_scheduler_impl_unittest.cc
+++ b/base/task_scheduler/task_scheduler_impl_unittest.cc
@@ -141,7 +141,7 @@ class ThreadPostingTasks : public SimpleThread {
const size_t kNumTasksPerThread = 150;
for (size_t i = 0; i < kNumTasksPerThread; ++i) {
factory_.PostTask(test::TestTaskFactory::PostNestedTask::NO,
- Bind(&VerifyTaskEnvironment, traits_));
+ Bind(&VerifyTaskEnvironment, ConstRef(traits_)));
}
}
@@ -219,8 +219,8 @@ TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsNoDelay) {
WaitableEvent::InitialState::NOT_SIGNALED);
scheduler_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
- BindOnce(&VerifyTaskEnvironmentAndSignalEvent, GetParam().traits,
- Unretained(&task_ran)),
+ BindOnce(&VerifyTaskEnvironmentAndSignalEvent,
+ ConstRef(GetParam().traits), Unretained(&task_ran)),
TimeDelta());
task_ran.Wait();
}
@@ -235,7 +235,8 @@ TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsWithDelay) {
WaitableEvent::InitialState::NOT_SIGNALED);
scheduler_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
- BindOnce(&VerifyTimeAndTaskEnvironmentAndSignalEvent, GetParam().traits,
+ BindOnce(&VerifyTimeAndTaskEnvironmentAndSignalEvent,
+ ConstRef(GetParam().traits),
TimeTicks::Now() + TestTimeouts::tiny_timeout(),
Unretained(&task_ran)),
TestTimeouts::tiny_timeout());
@@ -256,7 +257,7 @@ TEST_P(TaskSchedulerImplTest, PostTasksViaTaskRunner) {
const size_t kNumTasksPerTest = 150;
for (size_t i = 0; i < kNumTasksPerTest; ++i) {
factory.PostTask(test::TestTaskFactory::PostNestedTask::NO,
- Bind(&VerifyTaskEnvironment, GetParam().traits));
+ Bind(&VerifyTaskEnvironment, ConstRef(GetParam().traits)));
}
factory.WaitForAllTasksToRun();
@@ -269,8 +270,8 @@ TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsNoDelayBeforeStart) {
WaitableEvent::InitialState::NOT_SIGNALED);
scheduler_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
- BindOnce(&VerifyTaskEnvironmentAndSignalEvent, GetParam().traits,
- Unretained(&task_running)),
+ BindOnce(&VerifyTaskEnvironmentAndSignalEvent,
+ ConstRef(GetParam().traits), Unretained(&task_running)),
TimeDelta());
// Wait a little bit to make sure that the task isn't scheduled before
@@ -291,7 +292,8 @@ TEST_P(TaskSchedulerImplTest, PostDelayedTaskWithTraitsWithDelayBeforeStart) {
WaitableEvent::InitialState::NOT_SIGNALED);
scheduler_.PostDelayedTaskWithTraits(
FROM_HERE, GetParam().traits,
- BindOnce(&VerifyTimeAndTaskEnvironmentAndSignalEvent, GetParam().traits,
+ BindOnce(&VerifyTimeAndTaskEnvironmentAndSignalEvent,
+ ConstRef(GetParam().traits),
TimeTicks::Now() + TestTimeouts::tiny_timeout(),
Unretained(&task_running)),
TestTimeouts::tiny_timeout());
@@ -314,9 +316,9 @@ TEST_P(TaskSchedulerImplTest, PostTaskViaTaskRunnerBeforeStart) {
WaitableEvent::InitialState::NOT_SIGNALED);
CreateTaskRunnerWithTraitsAndExecutionMode(&scheduler_, GetParam().traits,
GetParam().execution_mode)
- ->PostTask(FROM_HERE,
- BindOnce(&VerifyTaskEnvironmentAndSignalEvent,
- GetParam().traits, Unretained(&task_running)));
+ ->PostTask(FROM_HERE, BindOnce(&VerifyTaskEnvironmentAndSignalEvent,
+ ConstRef(GetParam().traits),
+ Unretained(&task_running)));
// Wait a little bit to make sure that the task isn't scheduled before
// Start(). Note: This test won't catch a case where the task runs just after

Powered by Google App Engine
This is Rietveld 408576698