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

Unified Diff: services/service_manager/public/cpp/lib/interface_registry.cc

Issue 2478653003: Clean up dead InterfaceRegistry instances in ServiceContext (Closed)
Patch Set: . Created 4 years, 1 month 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: services/service_manager/public/cpp/lib/interface_registry.cc
diff --git a/services/service_manager/public/cpp/lib/interface_registry.cc b/services/service_manager/public/cpp/lib/interface_registry.cc
index 0e1059e25ccb50c7be2476418e7a7071f5e8df1a..0eff1e9545fba79dd65e2dfcae2dde2e7a2154a4 100644
--- a/services/service_manager/public/cpp/lib/interface_registry.cc
+++ b/services/service_manager/public/cpp/lib/interface_registry.cc
@@ -99,6 +99,8 @@ void InterfaceRegistry::Bind(
remote_interface_provider_spec_ = remote_interface_provider_spec;
RebuildExposedInterfaces();
binding_.Bind(std::move(local_interfaces_request));
+ binding_.set_connection_error_handler(base::Bind(
+ &InterfaceRegistry::OnConnectionError, base::Unretained(this)));
}
void InterfaceRegistry::Serialize(std::stringstream* stream) {
@@ -177,9 +179,9 @@ void InterfaceRegistry::GetInterfaceNames(
interface_names->insert(entry.first);
}
-void InterfaceRegistry::SetConnectionLostClosure(
+void InterfaceRegistry::AddConnectionLostClosure(
const base::Closure& connection_lost_closure) {
- binding_.set_connection_error_handler(connection_lost_closure);
+ connection_lost_closures_.push_back(connection_lost_closure);
}
// mojom::InterfaceProvider:
@@ -247,4 +249,9 @@ void InterfaceRegistry::RebuildExposedInterfaces() {
exposed_interfaces_.size() == 1 && exposed_interfaces_.count("*") == 1;
}
+void InterfaceRegistry::OnConnectionError() {
+ for (const auto& closure : connection_lost_closures_)
+ closure.Run();
+}
+
} // namespace service_manager
« no previous file with comments | « services/service_manager/public/cpp/interface_registry.h ('k') | services/service_manager/public/cpp/lib/service_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698