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 7b8a11edc690d059690070b1817503759c0ae4f0..6afc3e3028c431ce98f26b3dc482948587451b2e 100644 |
| --- a/components/arc/arc_bridge_service_impl.cc |
| +++ b/components/arc/arc_bridge_service_impl.cc |
| @@ -18,7 +18,6 @@ |
| #include "chromeos/chromeos_switches.h" |
| #include "chromeos/dbus/dbus_method_call_status.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| -#include "chromeos/dbus/session_manager_client.h" |
| #include "components/arc/arc_bridge_host_impl.h" |
| #include "components/prefs/pref_registry_simple.h" |
| #include "components/prefs/pref_service.h" |
| @@ -31,14 +30,12 @@ namespace { |
| constexpr int64_t kReconnectDelayInSeconds = 5; |
| } // namespace |
| -ArcBridgeServiceImpl::ArcBridgeServiceImpl( |
| - std::unique_ptr<ArcBridgeBootstrap> bootstrap) |
| - : bootstrap_(std::move(bootstrap)), |
| - session_started_(false), |
| +ArcBridgeServiceImpl::ArcBridgeServiceImpl() |
| + : session_started_(false), |
| + factory_(base::Bind(ArcBridgeBootstrap::Create)), |
| weak_factory_(this) { |
| DCHECK(!g_arc_bridge_service); |
| g_arc_bridge_service = this; |
| - bootstrap_->set_delegate(this); |
| } |
| ArcBridgeServiceImpl::~ArcBridgeServiceImpl() { |
| @@ -78,7 +75,10 @@ void ArcBridgeServiceImpl::PrerequisitesChanged() { |
| return; |
| VLOG(0) << "Prerequisites met, starting ARC"; |
| SetStopReason(StopReason::SHUTDOWN); |
| + |
| SetState(State::CONNECTING); |
| + bootstrap_ = factory_.Run(); |
| + bootstrap_->set_delegate(this); |
| bootstrap_->Start(); |
| } else { |
| if (session_started_) |
| @@ -95,13 +95,16 @@ void ArcBridgeServiceImpl::StopInstance() { |
| return; |
| } |
| + // We were explicitly asked to stop, so do not reconnect. |
| + reconnect_ = false; |
| + |
| VLOG(1) << "Stopping ARC"; |
| + DCHECK(bootstrap_.get()); |
| SetState(State::STOPPING); |
| arc_bridge_host_.reset(); |
| - bootstrap_->Stop(); |
| - // We were explicitly asked to stop, so do not reconnect. |
| - reconnect_ = false; |
| + // Note: this can call OnStopped() internally as a callback. |
| + bootstrap_->Stop(); |
| } |
| void ArcBridgeServiceImpl::OnConnectionEstablished( |
| @@ -123,10 +126,11 @@ void ArcBridgeServiceImpl::OnConnectionEstablished( |
| void ArcBridgeServiceImpl::OnStopped(StopReason stop_reason) { |
| DCHECK(CalledOnValidThread()); |
| + VLOG(0) << "ARC stopped: " << static_cast<int>(stop_reason); |
|
Luis Héctor Chávez
2016/09/15 23:08:49
Can we have an operator<< for StopReason? That'll
hidehiko
2016/09/20 13:35:19
Done.
|
| arc_bridge_host_.reset(); |
| + bootstrap_.reset(); |
| SetStopReason(stop_reason); |
| SetState(State::STOPPED); |
| - VLOG(0) << "ARC stopped"; |
| if (reconnect_) { |
| // There was a previous invocation and it crashed for some reason. Try |