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

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: Addressed more feedback Created 4 years, 11 months 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
« no previous file with comments | « components/arc/arc_bridge_service_impl.h ('k') | components/arc/arc_bridge_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4bc20c092578043132b34b189d00193cf70b8680 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();
}
@@ -95,6 +98,8 @@ void ArcBridgeServiceImpl::OnConnectionEstablished(
}
instance_ptr_ = std::move(instance);
+ instance_ptr_.set_connection_error_handler(base::Bind(
+ &ArcBridgeServiceImpl::OnChannelClosed, weak_factory_.GetWeakPtr()));
ArcBridgeHostPtr host;
binding_.Bind(GetProxy(&host));
@@ -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() {
+ 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
« no previous file with comments | « components/arc/arc_bridge_service_impl.h ('k') | components/arc/arc_bridge_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698