Revert of base: Make it possible to replace the MessageLoop's task runner (patchset #7 id:120001 of https://codereview.chromium.org/998063002/)
Reason for revert:
Reverting this CL because of https://crbug.com/508789
Please fix and test using the linux_chromium_tsan_rel_ng trybot.
Original issue's description:
> base: Make it possible to replace the MessageLoop's task runner
>
> This patch makes it possible to customize the task posting behavior
> of a MessageLoop. More specifically, a client can change the value
> returned by MessageLoop::task_runner() as well as
> ThreadTaskRunnerHandle::Get() on the target thread. The original task
> runner can still be used to post tasks to be run on the message loop.
>
> The Blink/renderer scheduler will use this functionality to manage task
> posting on the renderer main thread. This is needed to ensure consistent
> ordering of tasks posted through the MessageLoop w.r.t. tasks posted to
> the scheduler.
>
> Design doc: https://docs.google.com/a/chromium.org/document/d/1qxdh2I61_aB_Uzh1QgNqvdWFBCL_E65G2smoSySw7KU/edit#
>
> Alex Clarke <alexclarke@chromium.org> also contributed to this patch (https://codereview.chromium.org/1206893003/).
>
> BUG=465354
>
> Committed: https://crrev.com/698e77997894bf823c45ad1d6e0764fa93e2f3c1
> Cr-Commit-Position: refs/heads/master@{#337799}
TBR=jam@chromium.org,danakj@chromium.org,alexclarke@google.com,kinuko@chromium.org,skyostil@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=465354
Review URL: https://codereview.chromium.org/1223193004
Cr-Commit-Position: refs/heads/master@{#338484}
CrOS-Libchrome-Original-Commit: 3dd3cd58b7bcd8efe40552a1bb9a9cc2a3679405
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 4fecbc5..0eb24cf 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -170,7 +170,6 @@
// Tell the incoming queue that we are dying.
incoming_task_queue_->WillDestroyCurrentMessageLoop();
incoming_task_queue_ = NULL;
- unbound_task_runner_ = NULL;
task_runner_ = NULL;
// OK, now make it so that no one can find us.
@@ -368,7 +367,6 @@
//------------------------------------------------------------------------------
-// static
scoped_ptr<MessageLoop> MessageLoop::CreateUnbound(
Type type, MessagePumpFactoryCallback pump_factory) {
return make_scoped_ptr(new MessageLoop(type, pump_factory));
@@ -388,9 +386,7 @@
message_histogram_(NULL),
run_loop_(NULL),
incoming_task_queue_(new internal::IncomingTaskQueue(this)),
- unbound_task_runner_(
- new internal::MessageLoopTaskRunner(incoming_task_queue_)),
- task_runner_(unbound_task_runner_) {
+ task_runner_(new internal::MessageLoopTaskRunner(incoming_task_queue_)) {
// If type is TYPE_CUSTOM non-null pump_factory must be given.
DCHECK_EQ(type_ == TYPE_CUSTOM, !pump_factory_.is_null());
}
@@ -406,19 +402,7 @@
lazy_tls_ptr.Pointer()->Set(this);
incoming_task_queue_->StartScheduling();
- unbound_task_runner_->BindToCurrentThread();
- SetTaskRunner(unbound_task_runner_.Pass());
-}
-
-void MessageLoop::SetTaskRunner(
- scoped_refptr<SingleThreadTaskRunner> task_runner) {
- DCHECK_EQ(this, current());
- DCHECK(task_runner->BelongsToCurrentThread());
- DCHECK(!unbound_task_runner_);
- task_runner_ = task_runner.Pass();
- // Clear the previous thread task runner first because only one can exist at
- // a time.
- thread_task_runner_handle_.reset();
+ task_runner_->BindToCurrentThread();
thread_task_runner_handle_.reset(new ThreadTaskRunnerHandle(task_runner_));
}