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

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

Issue 2755813002: Begin to wean child processes off reliance on a persistent service_manager::Connection to the brows… (Closed)
Patch Set: . Created 3 years, 9 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/service_manager/public/cpp/lib/connector_impl.h ('k') | services/ui/public/cpp/gpu/gpu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/service_manager/public/cpp/lib/connector_impl.cc
diff --git a/services/service_manager/public/cpp/lib/connector_impl.cc b/services/service_manager/public/cpp/lib/connector_impl.cc
index b9c1811e03d126ef097e4d7680b6e8f9678ee4e5..a0b11df59d6ff5f39e9a7122e7c567e59750409f 100644
--- a/services/service_manager/public/cpp/lib/connector_impl.cc
+++ b/services/service_manager/public/cpp/lib/connector_impl.cc
@@ -15,12 +15,12 @@ void EmptyBindCallback(mojom::ConnectResult, const std::string&) {}
}
ConnectorImpl::ConnectorImpl(mojom::ConnectorPtrInfo unbound_state)
- : unbound_state_(std::move(unbound_state)) {
+ : unbound_state_(std::move(unbound_state)), weak_factory_(this) {
thread_checker_.DetachFromThread();
}
ConnectorImpl::ConnectorImpl(mojom::ConnectorPtr connector)
- : connector_(std::move(connector)) {
+ : connector_(std::move(connector)), weak_factory_(this) {
connector_.set_connection_error_handler(
base::Bind(&ConnectorImpl::OnConnectionError, base::Unretained(this)));
}
@@ -76,6 +76,12 @@ void ConnectorImpl::BindInterface(
if (!BindConnectorIfNecessary())
return;
+ if (!local_binder_overrides_.empty() &&
+ local_binder_overrides_.count(interface_name)) {
+ local_binder_overrides_[interface_name].Run(std::move(interface_pipe));
+ return;
+ }
+
connector_->BindInterface(target, interface_name, std::move(interface_pipe),
base::Bind(&EmptyBindCallback));
}
@@ -96,6 +102,19 @@ void ConnectorImpl::BindConnectorRequest(mojom::ConnectorRequest request) {
connector_->Clone(std::move(request));
}
+base::WeakPtr<Connector> ConnectorImpl::GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+}
+
+void ConnectorImpl::OverrideBinderForTesting(const std::string& interface_name,
+ const TestApi::Binder& binder) {
+ local_binder_overrides_[interface_name] = binder;
+}
+
+void ConnectorImpl::ClearBinderOverrides() {
+ local_binder_overrides_.clear();
+}
+
bool ConnectorImpl::BindConnectorIfNecessary() {
// Bind this object to the current thread the first time it is used to
// connect.
« no previous file with comments | « services/service_manager/public/cpp/lib/connector_impl.h ('k') | services/ui/public/cpp/gpu/gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698