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

Unified Diff: mojo/shell/public/cpp/lib/shell_connection.cc

Issue 1761113002: Monitor the ShellClient binding for pipe closure as a signal to shut down the ShellConnection, rath… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@28lifecycle2
Patch Set: Created 4 years, 10 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 | « mojo/shell/public/cpp/lib/shell_client.cc ('k') | mojo/shell/public/cpp/shell_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/public/cpp/lib/shell_connection.cc
diff --git a/mojo/shell/public/cpp/lib/shell_connection.cc b/mojo/shell/public/cpp/lib/shell_connection.cc
index 5649a1844fc836d4c76caf1acd368d04c11a0440..ca7dd1f2f5234ad8589d570c384746a29b90eca4 100644
--- a/mojo/shell/public/cpp/lib/shell_connection.cc
+++ b/mojo/shell/public/cpp/lib/shell_connection.cc
@@ -38,10 +38,10 @@ void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector,
const mojo::String& name,
uint32_t id,
uint32_t user_id) {
- connector_.reset(new ConnectorImpl(
- std::move(connector),
+ connector_.reset(new ConnectorImpl(std::move(connector)));
+ binding_.set_connection_error_handler(
base::Bind(&ShellConnection::OnConnectionError,
- weak_factory_.GetWeakPtr())));
+ weak_factory_.GetWeakPtr()));
client_->Initialize(connector_.get(), name, id, user_id);
}
@@ -69,12 +69,12 @@ void ShellConnection::AcceptConnection(
// ShellConnection, private:
void ShellConnection::OnConnectionError() {
- // We give the client notice first, since it might want to do something on
- // shell connection errors other than immediate termination of the run
- // loop. The application might want to continue servicing connections other
- // than the one to the shell.
- if (client_->ShellConnectionLost())
- connector_.reset();
+ // Note that the ShellClient doesn't technically have to quit now, it may live
+ // on to service existing connections. All existing Connectors however are
+ // invalid.
+ client_->ShellConnectionLost();
+ // We don't reset the connector as clients may have taken a raw pointer to it.
+ // Connect() will return nullptr if they try to connect to anything.
}
} // namespace mojo
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_client.cc ('k') | mojo/shell/public/cpp/shell_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698