Commit fb4e32fc authored by fdoray's avatar fdoray Committed by Commit bot

Remove call to MessageLoop::QuitWhenIdle() in auto_thread.cc.

MessageLoop::QuitWhenIdle() is deprecated. RunLoop should be used
instead.

BUG=616447

Review-Url: https://codereview.chromium.org/2373033002
Cr-Commit-Position: refs/heads/master@{#421313}
parent 70d9edc4
......@@ -5,7 +5,9 @@
#include "remoting/base/auto_thread.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
......@@ -99,6 +101,7 @@ AutoThread::AutoThread(const char* name)
thread_(),
name_(name),
was_quit_properly_(false) {
thread_checker_.DetachFromThread();
}
AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner)
......@@ -110,6 +113,7 @@ AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner)
name_(name),
was_quit_properly_(false),
joiner_(joiner) {
thread_checker_.DetachFromThread();
}
AutoThread::~AutoThread() {
......@@ -159,16 +163,10 @@ void AutoThread::SetComInitType(ComInitType com_init_type) {
}
#endif
void AutoThread::QuitThread(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
if (!task_runner->BelongsToCurrentThread()) {
task_runner->PostTask(FROM_HERE, base::Bind(&AutoThread::QuitThread,
base::Unretained(this),
task_runner));
return;
}
void AutoThread::QuitThread(const base::Closure& quit_when_idle_closure) {
DCHECK(thread_checker_.CalledOnValidThread());
base::MessageLoop::current()->QuitWhenIdle();
quit_when_idle_closure.Run();
was_quit_properly_ = true;
if (joiner_.get()) {
......@@ -183,8 +181,11 @@ void AutoThread::JoinAndDeleteThread() {
}
void AutoThread::ThreadMain() {
// The message loop for this thread.
// Bind |thread_checker_| to the current thread.
DCHECK(thread_checker_.CalledOnValidThread());
base::MessageLoop message_loop(startup_data_->loop_type);
base::RunLoop run_loop;
// Complete the initialization of our AutoThread object.
base::PlatformThread::SetName(name_);
......@@ -192,11 +193,10 @@ void AutoThread::ThreadMain() {
// Return an AutoThreadTaskRunner that will cleanly quit this thread when
// no more references to it remain.
startup_data_->task_runner =
new AutoThreadTaskRunner(message_loop.task_runner(),
base::Bind(&AutoThread::QuitThread,
base::Unretained(this),
message_loop.task_runner()));
startup_data_->task_runner = new AutoThreadTaskRunner(
message_loop.task_runner(),
base::Bind(&AutoThread::QuitThread, base::Unretained(this),
run_loop.QuitWhenIdleClosure()));
startup_data_->event.Signal();
// startup_data_ can't be touched anymore since the starting thread is now
......@@ -208,7 +208,7 @@ void AutoThread::ThreadMain() {
CreateComInitializer(com_init_type_));
#endif
base::RunLoop().Run();
run_loop.Run();
// Assert that MessageLoop::QuitWhenIdle was called by AutoThread::QuitThread.
DCHECK(was_quit_properly_);
......
......@@ -7,9 +7,11 @@
#include <string>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_checker.h"
#include "build/build_config.h"
#include "remoting/base/auto_thread_task_runner.h"
......@@ -81,7 +83,7 @@ class AutoThread : base::PlatformThread::Delegate {
private:
AutoThread(const char* name, AutoThreadTaskRunner* joiner);
void QuitThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
void QuitThread(const base::Closure& quit_when_idle_closure);
void JoinAndDeleteThread();
// base::PlatformThread::Delegate methods:
......@@ -109,6 +111,9 @@ class AutoThread : base::PlatformThread::Delegate {
// AutoThreadTaskRunner to post a task to to join & delete this thread.
scoped_refptr<AutoThreadTaskRunner> joiner_;
// Verifies that QuitThread() is called on the same thread as ThreadMain().
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(AutoThread);
};
......
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