Commit ea76f526 authored by Hidehiko Abe's avatar Hidehiko Abe Committed by Commit Bot

Handle Mojo connection error.

In ArcOemCryptoBridger and ArcMidisBridge, Mojo connection error
was not handled, so it caused a crash.
This CL handles the errors.

BUG=None
TEST=Ran on DUT.

Change-Id: Ib6fa54109ac4da03cf9d6e6386d038c92e22357b
Reviewed-on: https://chromium-review.googlesource.com/c/1286098Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601858}
parent 1633f13d
......@@ -127,9 +127,9 @@ void ArcOemCryptoBridge::Connect(mojom::OemCryptoServiceRequest request) {
mojo::InterfacePtrInfo<arc_oemcrypto::mojom::OemCryptoHostDaemon>(
std::move(server_pipe), 0u));
DVLOG(1) << "Bound remote OemCryptoHostDaemon interface to pipe";
oemcrypto_host_daemon_ptr_.set_connection_error_handler(base::BindOnce(
&mojo::InterfacePtr<arc_oemcrypto::mojom::OemCryptoHostDaemon>::reset,
base::Unretained(&oemcrypto_host_daemon_ptr_)));
&ArcOemCryptoBridge::OnMojoConnectionError, weak_factory_.GetWeakPtr()));
chromeos::DBusThreadManager::Get()
->GetArcOemCryptoClient()
->BootstrapMojoConnection(
......@@ -140,6 +140,11 @@ void ArcOemCryptoBridge::Connect(mojom::OemCryptoServiceRequest request) {
void ArcOemCryptoBridge::ConnectToDaemon(
mojom::OemCryptoServiceRequest request) {
if (!oemcrypto_host_daemon_ptr_) {
VLOG(1) << "Mojo connection is already lost.";
return;
}
// We need to get the GPU interface on the IO thread, then after that is
// done it will run the Mojo call on our thread.
base::PostTaskAndReplyWithResult(
......@@ -153,8 +158,18 @@ void ArcOemCryptoBridge::ConnectToDaemon(
void ArcOemCryptoBridge::FinishConnectingToDaemon(
mojom::OemCryptoServiceRequest request,
mojom::ProtectedBufferManagerPtr gpu_buffer_manager) {
if (!oemcrypto_host_daemon_ptr_) {
VLOG(1) << "Mojo connection is already lost.";
return;
}
oemcrypto_host_daemon_ptr_->Connect(std::move(request),
std::move(gpu_buffer_manager));
}
void ArcOemCryptoBridge::OnMojoConnectionError() {
LOG(ERROR) << "ArcOemCryptoBridge Mojo connection lost.";
oemcrypto_host_daemon_ptr_.reset();
}
} // namespace arc
......@@ -44,6 +44,7 @@ class ArcOemCryptoBridge : public KeyedService,
void FinishConnectingToDaemon(
mojom::OemCryptoServiceRequest request,
mojom::ProtectedBufferManagerPtr gpu_buffer_manager);
void OnMojoConnectionError();
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
arc_oemcrypto::mojom::OemCryptoHostDaemonPtr oemcrypto_host_daemon_ptr_;
......
......@@ -64,6 +64,10 @@ void ArcMidisBridge::OnBootstrapMojoConnection(
midis_host_ptr_.reset();
return;
}
if (!midis_host_ptr_) {
VLOG(1) << "ArcMidisBridge was already lost.";
return;
}
DVLOG(1) << "ArcMidisBridge succeeded with Mojo bootstrapping.";
midis_host_ptr_->Connect(std::move(request), std::move(client_ptr));
}
......@@ -87,9 +91,9 @@ void ArcMidisBridge::Connect(mojom::MidisServerRequest request,
midis_host_ptr_.Bind(
mojo::InterfacePtrInfo<mojom::MidisHost>(std::move(server_pipe), 0u));
DVLOG(1) << "Bound remote MidisHost interface to pipe.";
midis_host_ptr_.set_connection_error_handler(
base::BindOnce(&mojo::InterfacePtr<mojom::MidisHost>::reset,
base::Unretained(&midis_host_ptr_)));
midis_host_ptr_.set_connection_error_handler(base::BindOnce(
&ArcMidisBridge::OnMojoConnectionError, weak_factory_.GetWeakPtr()));
chromeos::DBusThreadManager::Get()
->GetArcMidisClient()
->BootstrapMojoConnection(
......@@ -99,4 +103,9 @@ void ArcMidisBridge::Connect(mojom::MidisServerRequest request,
std::move(client_ptr)));
}
void ArcMidisBridge::OnMojoConnectionError() {
LOG(ERROR) << "ArcMidisBridge Mojo connection lost.";
midis_host_ptr_.reset();
}
} // namespace arc
......@@ -40,6 +40,7 @@ class ArcMidisBridge : public KeyedService,
void OnBootstrapMojoConnection(mojom::MidisServerRequest request,
mojom::MidisClientPtr client_ptr,
bool result);
void OnMojoConnectionError();
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
mojom::MidisHostPtr midis_host_ptr_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment