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 2572579948830a73169b6681a7c8deab24be05df..4c12660a4721d40f4fd7d24a4a7f36e22783e248 100644 |
--- a/components/arc/arc_bridge_service_impl.cc |
+++ b/components/arc/arc_bridge_service_impl.cc |
@@ -75,6 +75,9 @@ void ArcBridgeServiceImpl::StopInstance() { |
} |
SetState(State::STOPPING); |
+ instance_ptr_.reset(); |
+ if (binding_.is_bound()) |
+ binding_.Close(); |
bootstrap_->Stop(); |
} |
@@ -99,6 +102,8 @@ void ArcBridgeServiceImpl::OnConnectionEstablished( |
ArcBridgeHostPtr host; |
binding_.Bind(GetProxy(&host)); |
instance_ptr_->Init(std::move(host)); |
+ instance_ptr_.set_connection_error_handler(base::Bind( |
hidehiko
2015/12/29 13:27:12
This should be called before Init() invocation? (I
Luis Héctor Chávez
2015/12/29 17:17:36
Done.
|
+ &ArcBridgeServiceImpl::OnChannelClosed, weak_factory_.GetWeakPtr())); |
SetState(State::READY); |
} |
@@ -106,6 +111,24 @@ void ArcBridgeServiceImpl::OnConnectionEstablished( |
void ArcBridgeServiceImpl::OnStopped() { |
DCHECK(CalledOnValidThread()); |
SetState(State::STOPPED); |
+ if (reconnect_) { |
+ // There was a previous invocation and it crashed for some reason. Try |
+ // starting the container again. |
+ reconnect_ = false; |
+ PrerequisitesChanged(); |
+ } |
+} |
+ |
+void ArcBridgeServiceImpl::OnChannelClosed() { |
hidehiko
2015/12/29 13:27:12
In the following scenario:
- the channel is accid
Luis Héctor Chávez
2015/12/29 17:17:36
In those cases StopInstance() is not called direct
|
+ DCHECK(CalledOnValidThread()); |
+ if (state() == State::STOPPED || state() == State::STOPPING) { |
+ // This will happen when the instance is shut down. Ignore that case. |
+ return; |
+ } |
+ VLOG(1) << "Mojo connection lost"; |
+ CloseAllChannels(); |
+ reconnect_ = true; |
+ StopInstance(); |
} |
} // namespace arc |