OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ipc/mojo/ipc_mojo_bootstrap.h" | 5 #include "ipc/mojo/ipc_mojo_bootstrap.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 }; | 41 }; |
42 | 42 |
43 MojoServerBootstrap::MojoServerBootstrap() = default; | 43 MojoServerBootstrap::MojoServerBootstrap() = default; |
44 | 44 |
45 void MojoServerBootstrap::Connect() { | 45 void MojoServerBootstrap::Connect() { |
46 DCHECK_EQ(state(), STATE_INITIALIZED); | 46 DCHECK_EQ(state(), STATE_INITIALIZED); |
47 | 47 |
48 bootstrap_.Bind(mojom::BootstrapPtrInfo(TakeHandle(), 0)); | 48 bootstrap_.Bind(mojom::BootstrapPtrInfo(TakeHandle(), 0)); |
49 bootstrap_.set_connection_error_handler( | 49 bootstrap_.set_connection_error_handler( |
50 base::Bind(&MojoServerBootstrap::Fail, base::Unretained(this))); | 50 base::Bind(&MojoServerBootstrap::Fail, base::Unretained(this))); |
| 51 bootstrap_.SetAllowSyncDispatch(true); |
51 | 52 |
52 IPC::mojom::ChannelAssociatedRequest send_channel_request; | 53 IPC::mojom::ChannelAssociatedRequest send_channel_request; |
53 IPC::mojom::ChannelAssociatedPtrInfo receive_channel; | 54 IPC::mojom::ChannelAssociatedPtrInfo receive_channel; |
54 | 55 |
55 bootstrap_.associated_group()->CreateAssociatedInterface( | 56 bootstrap_.associated_group()->CreateAssociatedInterface( |
56 mojo::AssociatedGroup::WILL_PASS_REQUEST, &send_channel_, | 57 mojo::AssociatedGroup::WILL_PASS_REQUEST, &send_channel_, |
57 &send_channel_request); | 58 &send_channel_request); |
58 bootstrap_.associated_group()->CreateAssociatedInterface( | 59 bootstrap_.associated_group()->CreateAssociatedInterface( |
59 mojo::AssociatedGroup::WILL_PASS_PTR, &receive_channel, | 60 mojo::AssociatedGroup::WILL_PASS_PTR, &receive_channel, |
60 &receive_channel_request_); | 61 &receive_channel_request_); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 101 |
101 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); | 102 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); |
102 }; | 103 }; |
103 | 104 |
104 MojoClientBootstrap::MojoClientBootstrap() : binding_(this) {} | 105 MojoClientBootstrap::MojoClientBootstrap() : binding_(this) {} |
105 | 106 |
106 void MojoClientBootstrap::Connect() { | 107 void MojoClientBootstrap::Connect() { |
107 binding_.Bind(TakeHandle()); | 108 binding_.Bind(TakeHandle()); |
108 binding_.set_connection_error_handler( | 109 binding_.set_connection_error_handler( |
109 base::Bind(&MojoClientBootstrap::Fail, base::Unretained(this))); | 110 base::Bind(&MojoClientBootstrap::Fail, base::Unretained(this))); |
| 111 binding_.SetAllowSyncDispatch(true); |
110 } | 112 } |
111 | 113 |
112 void MojoClientBootstrap::Init(mojom::ChannelAssociatedRequest receive_channel, | 114 void MojoClientBootstrap::Init(mojom::ChannelAssociatedRequest receive_channel, |
113 mojom::ChannelAssociatedPtrInfo send_channel, | 115 mojom::ChannelAssociatedPtrInfo send_channel, |
114 int32_t peer_pid, | 116 int32_t peer_pid, |
115 const mojo::Callback<void(int32_t)>& callback) { | 117 const mojo::Callback<void(int32_t)>& callback) { |
116 callback.Run(GetSelfPID()); | 118 callback.Run(GetSelfPID()); |
117 set_state(STATE_READY); | 119 set_state(STATE_READY); |
118 binding_.set_connection_error_handler(mojo::Closure()); | 120 binding_.set_connection_error_handler(mojo::Closure()); |
119 delegate()->OnPipesAvailable(std::move(send_channel), | 121 delegate()->OnPipesAvailable(std::move(send_channel), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 167 |
166 bool MojoBootstrap::HasFailed() const { | 168 bool MojoBootstrap::HasFailed() const { |
167 return state() == STATE_ERROR; | 169 return state() == STATE_ERROR; |
168 } | 170 } |
169 | 171 |
170 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() { | 172 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() { |
171 return std::move(handle_); | 173 return std::move(handle_); |
172 } | 174 } |
173 | 175 |
174 } // namespace IPC | 176 } // namespace IPC |
OLD | NEW |