Chromium Code Reviews| Index: components/arc/arc_bridge_service_impl.cc |
| diff --git a/components/arc/arc_bridge_service_impl.cc b/components/arc/arc_bridge_service_impl.cc |
| index 2134af5bc64cd7395ebb3db89f24ae80fa49551d..5e80c76784697bfde51fcef4fc5ed2f32350fa1d 100644 |
| --- a/components/arc/arc_bridge_service_impl.cc |
| +++ b/components/arc/arc_bridge_service_impl.cc |
| @@ -9,10 +9,12 @@ |
| #include "base/command_line.h" |
| #include "base/json/json_writer.h" |
| +#include "base/message_loop/message_loop.h" |
| #include "base/sequenced_task_runner.h" |
| #include "base/sys_info.h" |
| #include "base/task_runner_util.h" |
| #include "base/thread_task_runner_handle.h" |
| +#include "base/time/time.h" |
| #include "chromeos/chromeos_switches.h" |
| #include "chromeos/dbus/dbus_method_call_status.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| @@ -31,16 +33,15 @@ ArcBridgeServiceImpl::ArcBridgeServiceImpl( |
| bootstrap_->set_delegate(this); |
| } |
| -ArcBridgeServiceImpl::~ArcBridgeServiceImpl() { |
| -} |
| - |
| void ArcBridgeServiceImpl::HandleStartup() { |
| + VLOG(1) << "Session started"; |
| DCHECK(CalledOnValidThread()); |
| session_started_ = true; |
| PrerequisitesChanged(); |
| } |
| void ArcBridgeServiceImpl::Shutdown() { |
| + VLOG(1) << "Session ended"; |
| DCHECK(CalledOnValidThread()); |
| session_started_ = false; |
| PrerequisitesChanged(); |
| @@ -51,11 +52,13 @@ void ArcBridgeServiceImpl::PrerequisitesChanged() { |
| if (state() == State::STOPPED) { |
| if (!available() || !session_started_) |
| return; |
| + VLOG(0) << "Prerequisites met, starting ARC"; |
| SetState(State::CONNECTING); |
| bootstrap_->Start(); |
| } else { |
| if (available() && session_started_) |
| return; |
| + VLOG(0) << "Prerequisites stopped being met, stopping ARC"; |
| StopInstance(); |
| } |
| } |
| @@ -67,6 +70,7 @@ void ArcBridgeServiceImpl::StopInstance() { |
| return; |
| } |
| + VLOG(1) << "Stopping ARC"; |
| SetState(State::STOPPING); |
| instance_ptr_.reset(); |
| if (binding_.is_bound()) |
| @@ -78,6 +82,7 @@ void ArcBridgeServiceImpl::SetDetectedAvailability(bool arc_available) { |
| DCHECK(CalledOnValidThread()); |
| if (available() == arc_available) |
| return; |
| + VLOG(1) << "ARC available: " << arc_available; |
| SetAvailable(arc_available); |
| PrerequisitesChanged(); |
| } |
| @@ -96,17 +101,23 @@ void ArcBridgeServiceImpl::OnConnectionEstablished( |
| instance_ptr_->Init(binding_.CreateInterfacePtrAndBind()); |
| + VLOG(0) << "ARC ready"; |
| SetState(State::READY); |
| } |
| void ArcBridgeServiceImpl::OnStopped() { |
| DCHECK(CalledOnValidThread()); |
| SetState(State::STOPPED); |
| + VLOG(0) << "ARC stopped"; |
| if (reconnect_) { |
| // There was a previous invocation and it crashed for some reason. Try |
| // starting the container again. |
| + VLOG(0) << "ARC reconnecting"; |
| reconnect_ = false; |
| - PrerequisitesChanged(); |
| + base::MessageLoop::current()->task_runner()->PostDelayedTask( |
|
Yusuke Sato
2016/04/29 00:28:41
What's the purpose of this change? Please mention
Luis Héctor Chávez
2016/04/29 20:23:15
Done, and added a comment.
|
| + FROM_HERE, base::Bind(&ArcBridgeServiceImpl::PrerequisitesChanged, |
| + weak_factory_.GetWeakPtr()), |
| + base::TimeDelta::FromSeconds(5)); |
|
Yusuke Sato
2016/04/29 00:28:41
Can you name the constant?
Luis Héctor Chávez
2016/04/29 20:23:15
Done.
|
| } |
| } |