| 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..0aabf5526553909425b06ef97d9cce58fe03f64d 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,10 @@ namespace {
|
| constexpr int64_t kReconnectDelayInSeconds = 5;
|
| } // namespace
|
|
|
| -ArcBridgeServiceImpl::ArcBridgeServiceImpl(
|
| - std::unique_ptr<ArcBridgeBootstrap> bootstrap)
|
| - : bootstrap_(std::move(bootstrap)),
|
| - session_started_(false),
|
| - weak_factory_(this) {
|
| +ArcBridgeServiceImpl::ArcBridgeServiceImpl()
|
| + : session_started_(false), weak_factory_(this) {
|
| DCHECK(!g_arc_bridge_service);
|
| g_arc_bridge_service = this;
|
| - bootstrap_->set_delegate(this);
|
| }
|
|
|
| ArcBridgeServiceImpl::~ArcBridgeServiceImpl() {
|
| @@ -78,7 +73,11 @@ void ArcBridgeServiceImpl::PrerequisitesChanged() {
|
| return;
|
| VLOG(0) << "Prerequisites met, starting ARC";
|
| SetStopReason(StopReason::SHUTDOWN);
|
| +
|
| SetState(State::CONNECTING);
|
| + bootstrap_ =
|
| + delegate_ ? delegate_->CreateBootstrap() : ArcBridgeBootstrap::Create();
|
| + bootstrap_->set_delegate(this);
|
| bootstrap_->Start();
|
| } else {
|
| if (session_started_)
|
| @@ -95,13 +94,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 +125,11 @@ void ArcBridgeServiceImpl::OnConnectionEstablished(
|
|
|
| void ArcBridgeServiceImpl::OnStopped(StopReason stop_reason) {
|
| DCHECK(CalledOnValidThread());
|
| + VLOG(0) << "ARC stopped: " << static_cast<int>(stop_reason);
|
| 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
|
|
|