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

Unified Diff: ipc/ipc_mojo_bootstrap.cc

Issue 2147493006: Adds Channel-associated interface support on ChannelProxy's thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« ipc/ipc_channel_proxy.cc ('K') | « ipc/ipc_mojo_bootstrap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« ipc/ipc_channel_proxy.cc ('K') | « ipc/ipc_mojo_bootstrap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698