OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/edk/system/message_pipe_dispatcher.h" | 5 #include "mojo/edk/system/message_pipe_dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/edk/system/channel.h" | 8 #include "mojo/edk/system/channel.h" |
9 #include "mojo/edk/system/channel_endpoint.h" | 9 #include "mojo/edk/system/channel_endpoint.h" |
10 #include "mojo/edk/system/channel_endpoint_id.h" | 10 #include "mojo/edk/system/channel_endpoint_id.h" |
11 #include "mojo/edk/system/configuration.h" | 11 #include "mojo/edk/system/constants.h" |
12 #include "mojo/edk/system/local_message_pipe_endpoint.h" | 12 #include "mojo/edk/system/local_message_pipe_endpoint.h" |
13 #include "mojo/edk/system/memory.h" | 13 #include "mojo/edk/system/memory.h" |
14 #include "mojo/edk/system/message_pipe.h" | 14 #include "mojo/edk/system/message_pipe.h" |
15 #include "mojo/edk/system/options_validation.h" | 15 #include "mojo/edk/system/options_validation.h" |
16 #include "mojo/edk/system/proxy_message_pipe_endpoint.h" | 16 #include "mojo/edk/system/proxy_message_pipe_endpoint.h" |
17 | 17 |
18 namespace mojo { | 18 namespace mojo { |
19 namespace system { | 19 namespace system { |
20 | 20 |
21 namespace { | 21 namespace { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 message_pipe_ = nullptr; | 166 message_pipe_ = nullptr; |
167 port_ = kInvalidPort; | 167 port_ = kInvalidPort; |
168 return scoped_refptr<Dispatcher>(rv.get()); | 168 return scoped_refptr<Dispatcher>(rv.get()); |
169 } | 169 } |
170 | 170 |
171 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( | 171 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( |
172 UserPointer<const void> bytes, | 172 UserPointer<const void> bytes, |
173 uint32_t num_bytes, | 173 uint32_t num_bytes, |
174 std::vector<DispatcherTransport>* transports, | 174 std::vector<DispatcherTransport>* transports, |
175 MojoWriteMessageFlags flags) { | 175 MojoWriteMessageFlags flags) { |
176 DCHECK(!transports || | 176 DCHECK(!transports || (transports->size() > 0 && |
177 (transports->size() > 0 && | 177 transports->size() <= kMaxMessageNumHandles)); |
178 transports->size() <= GetConfiguration().max_message_num_handles)); | |
179 | 178 |
180 lock().AssertAcquired(); | 179 lock().AssertAcquired(); |
181 | 180 |
182 if (num_bytes > GetConfiguration().max_message_num_bytes) | 181 if (num_bytes > kMaxMessageNumBytes) |
183 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 182 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
184 | 183 |
185 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, | 184 return message_pipe_->WriteMessage( |
186 flags); | 185 port_, bytes, num_bytes, transports, flags); |
187 } | 186 } |
188 | 187 |
189 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( | 188 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( |
190 UserPointer<void> bytes, | 189 UserPointer<void> bytes, |
191 UserPointer<uint32_t> num_bytes, | 190 UserPointer<uint32_t> num_bytes, |
192 DispatcherVector* dispatchers, | 191 DispatcherVector* dispatchers, |
193 uint32_t* num_dispatchers, | 192 uint32_t* num_dispatchers, |
194 MojoReadMessageFlags flags) { | 193 MojoReadMessageFlags flags) { |
195 lock().AssertAcquired(); | 194 lock().AssertAcquired(); |
196 return message_pipe_->ReadMessage(port_, bytes, num_bytes, dispatchers, | 195 return message_pipe_->ReadMessage( |
197 num_dispatchers, flags); | 196 port_, bytes, num_bytes, dispatchers, num_dispatchers, flags); |
198 } | 197 } |
199 | 198 |
200 HandleSignalsState MessagePipeDispatcher::GetHandleSignalsStateImplNoLock() | 199 HandleSignalsState MessagePipeDispatcher::GetHandleSignalsStateImplNoLock() |
201 const { | 200 const { |
202 lock().AssertAcquired(); | 201 lock().AssertAcquired(); |
203 return message_pipe_->GetHandleSignalsState(port_); | 202 return message_pipe_->GetHandleSignalsState(port_); |
204 } | 203 } |
205 | 204 |
206 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock( | 205 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock( |
207 Waiter* waiter, | 206 Waiter* waiter, |
208 MojoHandleSignals signals, | 207 MojoHandleSignals signals, |
209 uint32_t context, | 208 uint32_t context, |
210 HandleSignalsState* signals_state) { | 209 HandleSignalsState* signals_state) { |
211 lock().AssertAcquired(); | 210 lock().AssertAcquired(); |
212 return message_pipe_->AddWaiter(port_, waiter, signals, context, | 211 return message_pipe_->AddWaiter( |
213 signals_state); | 212 port_, waiter, signals, context, signals_state); |
214 } | 213 } |
215 | 214 |
216 void MessagePipeDispatcher::RemoveWaiterImplNoLock( | 215 void MessagePipeDispatcher::RemoveWaiterImplNoLock( |
217 Waiter* waiter, | 216 Waiter* waiter, |
218 HandleSignalsState* signals_state) { | 217 HandleSignalsState* signals_state) { |
219 lock().AssertAcquired(); | 218 lock().AssertAcquired(); |
220 message_pipe_->RemoveWaiter(port_, waiter, signals_state); | 219 message_pipe_->RemoveWaiter(port_, waiter, signals_state); |
221 } | 220 } |
222 | 221 |
223 void MessagePipeDispatcher::StartSerializeImplNoLock( | 222 void MessagePipeDispatcher::StartSerializeImplNoLock( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // MessagePipeDispatcherTransport ---------------------------------------------- | 255 // MessagePipeDispatcherTransport ---------------------------------------------- |
257 | 256 |
258 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( | 257 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( |
259 DispatcherTransport transport) | 258 DispatcherTransport transport) |
260 : DispatcherTransport(transport) { | 259 : DispatcherTransport(transport) { |
261 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); | 260 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); |
262 } | 261 } |
263 | 262 |
264 } // namespace system | 263 } // namespace system |
265 } // namespace mojo | 264 } // namespace mojo |
OLD | NEW |