| Index: ipc/ipc_channel_proxy.cc
|
| diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
|
| index 5fea5548f82a5257eb6481961c14b51cb1f235e0..25229acc5afde66acedcf3c352d7ef0e29c6baa9 100644
|
| --- a/ipc/ipc_channel_proxy.cc
|
| +++ b/ipc/ipc_channel_proxy.cc
|
| @@ -79,17 +79,6 @@
|
| channel_ = factory->BuildChannel(this);
|
| channel_send_thread_safe_ = channel_->IsSendThreadSafe();
|
| channel_->SetAttachmentBrokerEndpoint(attachment_broker_endpoint_);
|
| -
|
| - Channel::AssociatedInterfaceSupport* support =
|
| - channel_->GetAssociatedInterfaceSupport();
|
| - if (support) {
|
| - associated_group_ = *support->GetAssociatedGroup();
|
| -
|
| - DCHECK(listener_task_runner_->RunsTasksOnCurrentThread());
|
| - for (auto& entry : pending_interfaces_)
|
| - support->AddGenericAssociatedInterface(entry.first, entry.second);
|
| - pending_interfaces_.clear();
|
| - }
|
| }
|
|
|
| bool ChannelProxy::Context::TryFilters(const Message& message) {
|
| @@ -173,6 +162,23 @@
|
|
|
| for (size_t i = 0; i < filters_.size(); ++i)
|
| filters_[i]->OnFilterAdded(channel_.get());
|
| +
|
| + Channel::AssociatedInterfaceSupport* support =
|
| + channel_->GetAssociatedInterfaceSupport();
|
| + if (support) {
|
| + support->SetProxyTaskRunner(listener_task_runner_);
|
| + for (auto& entry : io_thread_interfaces_)
|
| + support->AddGenericAssociatedInterface(entry.first, entry.second);
|
| + for (auto& entry : proxy_thread_interfaces_) {
|
| + support->AddGenericAssociatedInterface(
|
| + entry.first, base::Bind(&BindAssociatedInterfaceOnTaskRunner,
|
| + listener_task_runner_, entry.second));
|
| + }
|
| + } else {
|
| + // Sanity check to ensure nobody's expecting to use associated interfaces on
|
| + // a Channel that doesn't support them.
|
| + DCHECK(io_thread_interfaces_.empty() && proxy_thread_interfaces_.empty());
|
| + }
|
| }
|
|
|
| // Called on the IPC::Channel thread
|
| @@ -326,6 +332,18 @@
|
| if (channel_connected_called_)
|
| return;
|
|
|
| + {
|
| + base::AutoLock l(channel_lifetime_lock_);
|
| + if (channel_) {
|
| + Channel::AssociatedInterfaceSupport* associated_interface_support =
|
| + channel_->GetAssociatedInterfaceSupport();
|
| + if (associated_interface_support) {
|
| + channel_associated_group_.reset(new mojo::AssociatedGroup(
|
| + *associated_interface_support->GetAssociatedGroup()));
|
| + }
|
| + }
|
| + }
|
| +
|
| base::ProcessId peer_pid;
|
| {
|
| base::AutoLock l(peer_pid_lock_);
|
| @@ -351,30 +369,6 @@
|
| void ChannelProxy::Context::ClearChannel() {
|
| base::AutoLock l(channel_lifetime_lock_);
|
| channel_.reset();
|
| - associated_group_ = mojo::AssociatedGroup();
|
| -}
|
| -
|
| -void ChannelProxy::Context::AddGenericAssociatedInterface(
|
| - const std::string& name,
|
| - const GenericAssociatedInterfaceFactory& factory) {
|
| - AddGenericAssociatedInterfaceForIOThread(
|
| - name, base::Bind(&BindAssociatedInterfaceOnTaskRunner,
|
| - listener_task_runner_, factory));
|
| -}
|
| -
|
| -void ChannelProxy::Context::AddGenericAssociatedInterfaceForIOThread(
|
| - const std::string& name,
|
| - const GenericAssociatedInterfaceFactory& factory) {
|
| - base::AutoLock l(channel_lifetime_lock_);
|
| - if (!channel_) {
|
| - DCHECK(listener_task_runner_->RunsTasksOnCurrentThread());
|
| - pending_interfaces_.emplace_back(name, factory);
|
| - return;
|
| - }
|
| - Channel::AssociatedInterfaceSupport* support =
|
| - channel_->GetAssociatedInterfaceSupport();
|
| - DCHECK(support);
|
| - support->AddGenericAssociatedInterface(name, factory);
|
| }
|
|
|
| void ChannelProxy::Context::SendFromThisThread(Message* message) {
|
| @@ -552,20 +546,24 @@
|
| base::RetainedRef(filter)));
|
| }
|
|
|
| +void ChannelProxy::AddGenericAssociatedInterfaceForIOThread(
|
| + const std::string& name,
|
| + const GenericAssociatedInterfaceFactory& factory) {
|
| + DCHECK(CalledOnValidThread());
|
| + DCHECK(!did_init_);
|
| + context_->io_thread_interfaces_.insert({ name, factory });
|
| +}
|
| +
|
| void ChannelProxy::AddGenericAssociatedInterface(
|
| const std::string& name,
|
| const GenericAssociatedInterfaceFactory& factory) {
|
| - context()->AddGenericAssociatedInterface(name, factory);
|
| -}
|
| -
|
| -void ChannelProxy::AddGenericAssociatedInterfaceForIOThread(
|
| - const std::string& name,
|
| - const GenericAssociatedInterfaceFactory& factory) {
|
| - context()->AddGenericAssociatedInterfaceForIOThread(name, factory);
|
| + DCHECK(CalledOnValidThread());
|
| + DCHECK(!did_init_);
|
| + context_->proxy_thread_interfaces_.insert({ name, factory });
|
| }
|
|
|
| mojo::AssociatedGroup* ChannelProxy::GetAssociatedGroup() {
|
| - return context()->associated_group();
|
| + return context_->channel_associated_group_.get();
|
| }
|
|
|
| void ChannelProxy::GetGenericRemoteAssociatedInterface(
|
|
|