Commit 50b3e1fd authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

[base] Remove implicit-destination PostTask

No TaskTraits implcitly meant base::ThreadPool. The migration away
from this paradigm is complete (task APIs v3 is bringing explicit
API-as-destination). Remove this right away before we're ready to
completely remove post_task.h to avoid the addition of new callers
without an explicit destination.

Bug: 968047, 1026641
Change-Id: I54d04872498d340cfd8ec02aa88b3e9cba1a7547
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225541
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774758}
parent 3f24544d
...@@ -62,19 +62,6 @@ TaskExecutor* GetTaskExecutorForTraits(const TaskTraits& traits) { ...@@ -62,19 +62,6 @@ TaskExecutor* GetTaskExecutorForTraits(const TaskTraits& traits) {
} // namespace } // namespace
bool PostTask(const Location& from_here, OnceClosure task) {
// TODO(skyostil): Make task traits required here too.
return PostDelayedTask(from_here, {ThreadPool()}, std::move(task),
TimeDelta());
}
bool PostTaskAndReply(const Location& from_here,
OnceClosure task,
OnceClosure reply) {
return PostTaskAndReply(from_here, {ThreadPool()}, std::move(task),
std::move(reply));
}
bool PostTask(const Location& from_here, bool PostTask(const Location& from_here,
const TaskTraits& traits, const TaskTraits& traits,
OnceClosure task) { OnceClosure task) {
......
...@@ -99,27 +99,6 @@ namespace base { ...@@ -99,27 +99,6 @@ namespace base {
// have to worry about this. You will encounter DCHECKs or nullptr dereferences // have to worry about this. You will encounter DCHECKs or nullptr dereferences
// if this is violated. For tests, prefer base::test::TaskEnvironment. // if this is violated. For tests, prefer base::test::TaskEnvironment.
// Equivalent to calling PostTask with default TaskTraits.
BASE_EXPORT bool PostTask(const Location& from_here, OnceClosure task);
inline bool PostTask(OnceClosure task,
const Location& from_here = Location::Current()) {
return PostTask(from_here, std::move(task));
}
// Equivalent to calling PostTaskAndReply with default TaskTraits.
BASE_EXPORT bool PostTaskAndReply(const Location& from_here,
OnceClosure task,
OnceClosure reply);
// Equivalent to calling PostTaskAndReplyWithResult with default TaskTraits.
template <typename TaskReturnType, typename ReplyArgType>
bool PostTaskAndReplyWithResult(const Location& from_here,
OnceCallback<TaskReturnType()> task,
OnceCallback<void(ReplyArgType)> reply) {
return PostTaskAndReplyWithResult(from_here, {ThreadPool()}, std::move(task),
std::move(reply));
}
// Posts |task| with specific |traits|. Returns false if the task definitely // Posts |task| with specific |traits|. Returns false if the task definitely
// won't run because of current shutdown state. // won't run because of current shutdown state.
BASE_EXPORT bool PostTask(const Location& from_here, BASE_EXPORT bool PostTask(const Location& from_here,
......
...@@ -99,10 +99,6 @@ class PostTaskTestWithExecutor : public ::testing::Test { ...@@ -99,10 +99,6 @@ class PostTaskTestWithExecutor : public ::testing::Test {
}; };
TEST_F(PostTaskTestWithExecutor, PostTaskToThreadPool) { TEST_F(PostTaskTestWithExecutor, PostTaskToThreadPool) {
// Tasks without extension should not go to the TestTaskExecutor.
EXPECT_TRUE(PostTask(FROM_HERE, DoNothing()));
EXPECT_FALSE(executor_.runner()->HasPendingTask());
EXPECT_TRUE(PostTask(FROM_HERE, {ThreadPool(), MayBlock()}, DoNothing())); EXPECT_TRUE(PostTask(FROM_HERE, {ThreadPool(), MayBlock()}, DoNothing()));
EXPECT_FALSE(executor_.runner()->HasPendingTask()); EXPECT_FALSE(executor_.runner()->HasPendingTask());
......
...@@ -67,7 +67,7 @@ TEST_F(SequencedTaskRunnerHandleTest, FromThreadPoolSequencedTask) { ...@@ -67,7 +67,7 @@ TEST_F(SequencedTaskRunnerHandleTest, FromThreadPoolSequencedTask) {
} }
TEST_F(SequencedTaskRunnerHandleTest, NoHandleFromUnsequencedTask) { TEST_F(SequencedTaskRunnerHandleTest, NoHandleFromUnsequencedTask) {
base::PostTask(base::BindOnce( base::ThreadPool::PostTask(base::BindOnce(
[]() { EXPECT_FALSE(SequencedTaskRunnerHandle::IsSet()); })); []() { EXPECT_FALSE(SequencedTaskRunnerHandle::IsSet()); }));
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
} }
......
...@@ -151,12 +151,12 @@ TEST(BrowserTaskEnvironmentTest, TraitsConstructor) { ...@@ -151,12 +151,12 @@ TEST(BrowserTaskEnvironmentTest, TraitsConstructor) {
signaled_on_real_io_thread.TimedWait(base::TimeDelta::FromSeconds(5)); signaled_on_real_io_thread.TimedWait(base::TimeDelta::FromSeconds(5));
EXPECT_TRUE(signaled_on_real_io_thread.IsSignaled()); EXPECT_TRUE(signaled_on_real_io_thread.IsSignaled());
// Tasks posted via PostTask don't run in ThreadPoolExecutionMode::QUEUED // Tasks posted via ThreadPool::PostTask don't run in
// until RunUntilIdle is called. // ThreadPoolExecutionMode::QUEUED until RunUntilIdle is called.
base::AtomicFlag task_ran; base::AtomicFlag task_ran;
PostTask(FROM_HERE, base::ThreadPool::PostTask(
BindOnce([](base::AtomicFlag* task_ran) { task_ran->Set(); }, FROM_HERE, BindOnce([](base::AtomicFlag* task_ran) { task_ran->Set(); },
Unretained(&task_ran))); Unretained(&task_ran)));
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
EXPECT_FALSE(task_ran.IsSet()); EXPECT_FALSE(task_ran.IsSet());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment