Chromium Code Reviews| Index: ipc/ipc_mojo_bootstrap.cc |
| diff --git a/ipc/ipc_mojo_bootstrap.cc b/ipc/ipc_mojo_bootstrap.cc |
| index 425f794858f02732f6ccf5736f51c0fcfadfb84f..e84e4e528a5010d97548800680a6774c7ef64c0b 100644 |
| --- a/ipc/ipc_mojo_bootstrap.cc |
| +++ b/ipc/ipc_mojo_bootstrap.cc |
| @@ -442,7 +442,6 @@ class ChannelAssociatedGroupController |
| // If the client is not yet bound, it must be bound by the time this task |
| // runs or else it's programmer error. |
| DCHECK(proxy_task_runner_); |
| - CHECK(false); |
|
Ken Rockot(use gerrit already)
2016/07/13 22:56:25
Forgot to remove this on the last CL. :o
|
| std::unique_ptr<mojo::Message> passed_message(new mojo::Message); |
| message->MoveTo(passed_message.get()); |
| proxy_task_runner_->PostTask( |
| @@ -471,8 +470,34 @@ class ChannelAssociatedGroupController |
| void AcceptOnProxyThread(std::unique_ptr<mojo::Message> message) { |
| DCHECK(proxy_task_runner_->BelongsToCurrentThread()); |
| - // TODO(rockot): Implement this. |
| - NOTREACHED(); |
| + mojo::InterfaceId id = message->interface_id(); |
| + DCHECK(mojo::IsValidInterfaceId(id) && !mojo::IsMasterInterfaceId(id)); |
| + |
| + base::AutoLock locker(lock_); |
| + bool inserted = false; |
| + Endpoint* endpoint = FindOrInsertEndpoint(id, &inserted); |
| + |
| + // The endpoint must have already been inserted by Accept(), and if the |
|
yzshen1
2016/07/13 23:25:09
It seems to be possible that |inserted| is true. I
Ken Rockot(use gerrit already)
2016/07/14 00:39:09
Ah your right, I had convinced myself that #2 was
|
| + // system is behaving as intended and consumers are well-behaved, it should |
| + // be impossible for the endpoint to have been removed yet. |
| + DCHECK(!inserted); |
| + |
| + mojo::InterfaceEndpointClient* client = endpoint->client(); |
| + DCHECK(client); |
|
yzshen1
2016/07/13 23:25:09
The local endpoint could already be detached, righ
Ken Rockot(use gerrit already)
2016/07/14 00:39:09
Indeed. Done.
|
| + DCHECK(endpoint->task_runner()->BelongsToCurrentThread()); |
| + |
| + // TODO(rockot): Implement sync dispatch. For now, sync messages are |
| + // unsupported here. |
| + DCHECK(!message->has_flag(mojo::Message::kFlagIsSync)); |
| + |
| + bool result = false; |
| + { |
| + base::AutoUnlock unlocker(lock_); |
| + result = client->HandleIncomingMessage(message.get()); |
| + } |
| + |
| + if (!result) |
| + RaiseError(); |
| } |
| // mojo::PipeControlMessageHandlerDelegate: |
| @@ -561,6 +586,11 @@ class BootstrapMasterProxy { |
| return controller_->associated_group(); |
| } |
| + ChannelAssociatedGroupController* controller() { |
| + DCHECK(controller_); |
| + return controller_.get(); |
| + } |
| + |
| mojom::Bootstrap* operator->() { |
| DCHECK(proxy_); |
| return proxy_.get(); |
| @@ -596,6 +626,11 @@ class BootstrapMasterBinding { |
| return controller_->associated_group(); |
| } |
| + ChannelAssociatedGroupController* controller() { |
| + DCHECK(controller_); |
| + return controller_.get(); |
| + } |
| + |
| void Bind(mojo::ScopedMessagePipeHandle handle) { |
| DCHECK(!controller_); |
| controller_ = |
| @@ -626,10 +661,16 @@ class MojoServerBootstrap : public MojoBootstrap { |
| private: |
| // MojoBootstrap implementation. |
| void Connect() override; |
| + |
| mojo::AssociatedGroup* GetAssociatedGroup() override { |
| return bootstrap_.associated_group(); |
| } |
| + void SetProxyTaskRunner( |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner) override { |
| + bootstrap_.controller()->SetProxyTaskRunner(task_runner); |
| + } |
| + |
| void OnInitDone(int32_t peer_pid); |
| BootstrapMasterProxy bootstrap_; |
| @@ -688,10 +729,16 @@ class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap { |
| private: |
| // MojoBootstrap implementation. |
| void Connect() override; |
| + |
| mojo::AssociatedGroup* GetAssociatedGroup() override { |
| return binding_.associated_group(); |
| } |
| + void SetProxyTaskRunner( |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner) override { |
| + binding_.controller()->SetProxyTaskRunner(task_runner); |
| + } |
| + |
| // mojom::Bootstrap implementation. |
| void Init(mojom::ChannelAssociatedRequest receive_channel, |
| mojom::ChannelAssociatedPtrInfo send_channel, |