Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: components/arc/arc_bridge_service_impl.cc

Issue 1548833002: arc-bridge: Restart ARC instance on crash (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698