Commit 0e666505 authored by rockot's avatar rockot Committed by Commit bot

Use a binding set for BrowserAssociatedInterface

This allows multiple client proxies in a render process to connect
to a single BrowserAssociatedInterface at the same time.

BUG=612500

Review-Url: https://codereview.chromium.org/2400663003
Cr-Commit-Position: refs/heads/master@{#423721}
parent e9fd952d
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_channel_proxy.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding_set.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
namespace content { namespace content {
...@@ -76,7 +76,7 @@ class BrowserAssociatedInterface { ...@@ -76,7 +76,7 @@ class BrowserAssociatedInterface {
base::Bind(&InternalState::Initialize, this)); base::Bind(&InternalState::Initialize, this));
return; return;
} }
binding_.reset(new mojo::AssociatedBinding<Interface>(impl_)); bindings_.reset(new mojo::AssociatedBindingSet<Interface>);
} }
void ShutDown() { void ShutDown() {
...@@ -85,19 +85,16 @@ class BrowserAssociatedInterface { ...@@ -85,19 +85,16 @@ class BrowserAssociatedInterface {
base::Bind(&InternalState::ShutDown, this)); base::Bind(&InternalState::ShutDown, this));
return; return;
} }
binding_.reset(); bindings_.reset();
} }
void BindRequest(mojo::ScopedInterfaceEndpointHandle handle) { void BindRequest(mojo::ScopedInterfaceEndpointHandle handle) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
// If this interface has already been shut down or is already bound, we // If this interface has already been shut down we drop the request.
// drop the request. if (!bindings_)
if (!binding_ || binding_->is_bound())
return; return;
bindings_->AddBinding(
binding_->Bind(mojo::MakeAssociatedRequest<Interface>(std::move(handle))); impl_, mojo::MakeAssociatedRequest<Interface>(std::move(handle)));
binding_->set_connection_error_handler(
base::Bind(&InternalState::ShutDown, base::Unretained(this)));
} }
private: private:
...@@ -106,7 +103,7 @@ class BrowserAssociatedInterface { ...@@ -106,7 +103,7 @@ class BrowserAssociatedInterface {
~InternalState() {} ~InternalState() {}
Interface* impl_; Interface* impl_;
std::unique_ptr<mojo::AssociatedBinding<Interface>> binding_; std::unique_ptr<mojo::AssociatedBindingSet<Interface>> bindings_;
DISALLOW_COPY_AND_ASSIGN(InternalState); DISALLOW_COPY_AND_ASSIGN(InternalState);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment