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

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

Issue 1920033005: services/shell: Fix running the connection-lost callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 | « services/shell/public/cpp/lib/application_runner.cc ('k') | services/shell/public/cpp/shell_connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/public/cpp/lib/shell_connection.cc
diff --git a/services/shell/public/cpp/lib/shell_connection.cc b/services/shell/public/cpp/lib/shell_connection.cc
index d1131283a19a05d83a786091db508a0a19437b37..8b1ad3fbb6d60982dbfe56f6ac0867883ecc66dc 100644
--- a/services/shell/public/cpp/lib/shell_connection.cc
+++ b/services/shell/public/cpp/lib/shell_connection.cc
@@ -43,6 +43,13 @@ void ShellConnection::SetAppTestConnectorForTesting(
connector_.reset(new ConnectorImpl(std::move(connector)));
}
+void ShellConnection::SetConnectionLostClosure(const base::Closure& closure) {
+ connection_lost_closure_ = closure;
+ if (should_run_connection_lost_closure_ &&
+ !connection_lost_closure_.is_null())
+ connection_lost_closure_.Run();
+}
+
////////////////////////////////////////////////////////////////////////////////
// ShellConnection, mojom::ShellClient implementation:
@@ -87,7 +94,9 @@ void ShellConnection::OnConnectionError() {
// 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.
- if (client_->ShellConnectionLost() && !connection_lost_closure_.is_null())
+ should_run_connection_lost_closure_ = client_->ShellConnectionLost();
+ if (should_run_connection_lost_closure_ &&
+ !connection_lost_closure_.is_null())
connection_lost_closure_.Run();
// 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.
« no previous file with comments | « services/shell/public/cpp/lib/application_runner.cc ('k') | services/shell/public/cpp/shell_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698