| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/arc/standalone/arc_standalone_bridge_runner.h" | 5 #include "components/arc/standalone/arc_standalone_bridge_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 9 | 10 |
| 10 namespace arc { | 11 namespace arc { |
| 11 | 12 |
| 12 ArcStandaloneBridgeRunner::ArcStandaloneBridgeRunner() : exit_code_(0) { | 13 ArcStandaloneBridgeRunner::ArcStandaloneBridgeRunner() : exit_code_(0) { |
| 13 } | 14 } |
| 14 | 15 |
| 15 ArcStandaloneBridgeRunner::~ArcStandaloneBridgeRunner() { | 16 ArcStandaloneBridgeRunner::~ArcStandaloneBridgeRunner() { |
| 16 } | 17 } |
| 17 | 18 |
| 18 int ArcStandaloneBridgeRunner::Run() { | 19 int ArcStandaloneBridgeRunner::Run() { |
| 19 DCHECK(thread_checker_.CalledOnValidThread()); | 20 DCHECK(thread_checker_.CalledOnValidThread()); |
| 20 run_loop_.reset(new base::RunLoop()); | 21 run_loop_.reset(new base::RunLoop()); |
| 21 run_loop_->Run(); | 22 run_loop_->Run(); |
| 22 run_loop_.reset(nullptr); | 23 run_loop_.reset(nullptr); |
| 23 | 24 |
| 24 return exit_code_; | 25 return exit_code_; |
| 25 } | 26 } |
| 26 | 27 |
| 27 void ArcStandaloneBridgeRunner::Stop(int exit_code) { | 28 void ArcStandaloneBridgeRunner::Stop(int exit_code) { |
| 28 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
| 29 exit_code_ = exit_code; | 30 exit_code_ = exit_code; |
| 30 CHECK(run_loop_); | 31 CHECK(run_loop_); |
| 31 message_loop_.PostTask(FROM_HERE, run_loop_->QuitClosure()); | 32 message_loop_.task_runner()->PostTask(FROM_HERE, run_loop_->QuitClosure()); |
| 32 } | 33 } |
| 33 | 34 |
| 34 } // namespace arc | 35 } // namespace arc |
| OLD | NEW |