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 93f42b183013e461537e5fed81525d28248ca6cf..2c413b99b6470ff59c499c5fa9c6b5c3c7e27777 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 "components/arc/arc_bridge_host_impl.h" |
#include "components/prefs/pref_registry_simple.h" |
#include "components/prefs/pref_service.h" |
@@ -39,6 +38,9 @@ ArcBridgeServiceImpl::ArcBridgeServiceImpl() |
} |
ArcBridgeServiceImpl::~ArcBridgeServiceImpl() { |
+ if (bootstrap_) |
+ bootstrap_->RemoveObserver(this); |
+ |
DCHECK(g_arc_bridge_service == this); |
g_arc_bridge_service = nullptr; |
} |
@@ -85,7 +87,7 @@ void ArcBridgeServiceImpl::PrerequisitesChanged() { |
SetState(State::CONNECTING); |
bootstrap_ = factory_.Run(); |
Luis Héctor Chávez
2016/10/03 18:05:32
Should you unregister the previous bootstrap here
hidehiko
2016/10/04 05:34:45
Added RemoveObserver, which is much safer.
|
- bootstrap_->set_delegate(this); |
+ bootstrap_->AddObserver(this); |
bootstrap_->Start(); |
} else { |
if (session_started_) |
@@ -108,22 +110,18 @@ void ArcBridgeServiceImpl::StopInstance() { |
VLOG(1) << "Stopping ARC"; |
DCHECK(bootstrap_.get()); |
SetState(State::STOPPING); |
- arc_bridge_host_.reset(); |
// Note: this can call OnStopped() internally as a callback. |
bootstrap_->Stop(); |
} |
-void ArcBridgeServiceImpl::OnConnectionEstablished( |
- mojom::ArcBridgeInstancePtr instance) { |
+void ArcBridgeServiceImpl::OnReady() { |
DCHECK(CalledOnValidThread()); |
if (state() != State::CONNECTING) { |
VLOG(1) << "StopInstance() called while connecting"; |
return; |
} |
- arc_bridge_host_.reset(new ArcBridgeHostImpl(std::move(instance))); |
- |
// The container can be considered to have been successfully launched, so |
// restart if the connection goes down without being requested. |
reconnect_ = true; |
@@ -134,7 +132,7 @@ void ArcBridgeServiceImpl::OnConnectionEstablished( |
void ArcBridgeServiceImpl::OnStopped(StopReason stop_reason) { |
DCHECK(CalledOnValidThread()); |
VLOG(0) << "ARC stopped: " << stop_reason; |
- arc_bridge_host_.reset(); |
+ bootstrap_->RemoveObserver(this); |
bootstrap_.reset(); |
SetStopReason(stop_reason); |
SetState(State::STOPPED); |