Index: content/common/associated_interface_provider_impl.cc |
diff --git a/content/common/associated_interface_provider_impl.cc b/content/common/associated_interface_provider_impl.cc |
index c42ff3f15e090f5ca7a33a7ddeb66f68118a0a29..6c6c6fbd123e94991c1240abe319ae736f137816 100644 |
--- a/content/common/associated_interface_provider_impl.cc |
+++ b/content/common/associated_interface_provider_impl.cc |
@@ -6,11 +6,46 @@ |
namespace content { |
+AssociatedInterfaceProviderImpl::LocalProvider::LocalProvider( |
+ mojom::AssociatedInterfaceProviderAssociatedPtr* proxy) |
+ : route_provider_binding_(this), |
+ associated_interface_provider_binding_(this) { |
+ route_provider_binding_.Bind(mojo::GetProxy(&route_provider_ptr_)); |
+ route_provider_ptr_->GetRoute( |
+ 0, mojo::GetProxy(proxy, route_provider_ptr_.associated_group())); |
+} |
+AssociatedInterfaceProviderImpl::LocalProvider::~LocalProvider() {} |
+ |
+void AssociatedInterfaceProviderImpl::LocalProvider::SetBinderForName( |
+ const std::string& name, |
+ const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& binder) { |
+ binders_[name] = binder; |
+} |
+ |
+void AssociatedInterfaceProviderImpl::LocalProvider::GetRoute( |
+ int32_t routing_id, |
+ mojom::AssociatedInterfaceProviderAssociatedRequest request) { |
+ DCHECK(request.is_pending()); |
+ associated_interface_provider_binding_.Bind(std::move(request)); |
+} |
+ |
+void AssociatedInterfaceProviderImpl::LocalProvider::GetAssociatedInterface( |
+ const std::string& name, |
+ mojom::AssociatedInterfaceAssociatedRequest request) { |
+ auto it = binders_.find(name); |
+ if (it != binders_.end()) |
+ it->second.Run(request.PassHandle()); |
+} |
+ |
AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl( |
mojom::AssociatedInterfaceProviderAssociatedPtr proxy) |
: proxy_(std::move(proxy)) { |
+ DCHECK(proxy_.is_bound()); |
} |
+AssociatedInterfaceProviderImpl::AssociatedInterfaceProviderImpl() |
+ : local_provider_(new LocalProvider(&proxy_)) {} |
+ |
AssociatedInterfaceProviderImpl::~AssociatedInterfaceProviderImpl() {} |
void AssociatedInterfaceProviderImpl::GetInterface( |
@@ -25,4 +60,11 @@ mojo::AssociatedGroup* AssociatedInterfaceProviderImpl::GetAssociatedGroup() { |
return proxy_.associated_group(); |
} |
+void AssociatedInterfaceProviderImpl::OverrideBinderForTesting( |
+ const std::string& name, |
+ const base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>& binder) { |
+ DCHECK(local_provider_); |
+ local_provider_->SetBinderForName(name, binder); |
+} |
+ |
} // namespace content |