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/system/dispatcher.h" | 5 #include "mojo/system/dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/system/constants.h" | 8 #include "mojo/system/constants.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 MojoResult Dispatcher::EndReadData(uint32_t num_bytes_read) { | 120 MojoResult Dispatcher::EndReadData(uint32_t num_bytes_read) { |
121 base::AutoLock locker(lock_); | 121 base::AutoLock locker(lock_); |
122 if (is_closed_) | 122 if (is_closed_) |
123 return MOJO_RESULT_INVALID_ARGUMENT; | 123 return MOJO_RESULT_INVALID_ARGUMENT; |
124 | 124 |
125 return EndReadDataImplNoLock(num_bytes_read); | 125 return EndReadDataImplNoLock(num_bytes_read); |
126 } | 126 } |
127 | 127 |
| 128 MojoResult Dispatcher::DuplicateBufferHandle( |
| 129 const MojoDuplicateBufferHandleOptions* options, |
| 130 scoped_refptr<Dispatcher>* new_dispatcher) { |
| 131 base::AutoLock locker(lock_); |
| 132 if (is_closed_) |
| 133 return MOJO_RESULT_INVALID_ARGUMENT; |
| 134 |
| 135 return DuplicateBufferHandleImplNoLock(options, new_dispatcher); |
| 136 } |
| 137 |
| 138 MojoResult Dispatcher::MapBuffer(uint64_t offset, |
| 139 uint64_t num_bytes, |
| 140 void** buffer, |
| 141 MojoMapBufferFlags flags) { |
| 142 base::AutoLock locker(lock_); |
| 143 if (is_closed_) |
| 144 return MOJO_RESULT_INVALID_ARGUMENT; |
| 145 |
| 146 return MapBufferImplNoLock(offset, num_bytes, buffer, flags); |
| 147 } |
| 148 |
128 MojoResult Dispatcher::AddWaiter(Waiter* waiter, | 149 MojoResult Dispatcher::AddWaiter(Waiter* waiter, |
129 MojoWaitFlags flags, | 150 MojoWaitFlags flags, |
130 MojoResult wake_result) { | 151 MojoResult wake_result) { |
131 DCHECK_GE(wake_result, 0); | 152 DCHECK_GE(wake_result, 0); |
132 | 153 |
133 base::AutoLock locker(lock_); | 154 base::AutoLock locker(lock_); |
134 if (is_closed_) | 155 if (is_closed_) |
135 return MOJO_RESULT_INVALID_ARGUMENT; | 156 return MOJO_RESULT_INVALID_ARGUMENT; |
136 | 157 |
137 return AddWaiterImplNoLock(waiter, flags, wake_result); | 158 return AddWaiterImplNoLock(waiter, flags, wake_result); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 return MOJO_RESULT_INVALID_ARGUMENT; | 254 return MOJO_RESULT_INVALID_ARGUMENT; |
234 } | 255 } |
235 | 256 |
236 MojoResult Dispatcher::EndReadDataImplNoLock(uint32_t /*num_bytes_read*/) { | 257 MojoResult Dispatcher::EndReadDataImplNoLock(uint32_t /*num_bytes_read*/) { |
237 lock_.AssertAcquired(); | 258 lock_.AssertAcquired(); |
238 DCHECK(!is_closed_); | 259 DCHECK(!is_closed_); |
239 // By default, not supported. Only needed for data pipe dispatchers. | 260 // By default, not supported. Only needed for data pipe dispatchers. |
240 return MOJO_RESULT_INVALID_ARGUMENT; | 261 return MOJO_RESULT_INVALID_ARGUMENT; |
241 } | 262 } |
242 | 263 |
| 264 MojoResult Dispatcher::DuplicateBufferHandleImplNoLock( |
| 265 const MojoDuplicateBufferHandleOptions* /*options*/, |
| 266 scoped_refptr<Dispatcher>* /*new_dispatcher*/) { |
| 267 lock_.AssertAcquired(); |
| 268 DCHECK(!is_closed_); |
| 269 // By default, not supported. Only needed for buffer dispatchers. |
| 270 return MOJO_RESULT_INVALID_ARGUMENT; |
| 271 } |
| 272 |
| 273 MojoResult Dispatcher::MapBufferImplNoLock(uint64_t /*offset*/, |
| 274 uint64_t /*num_bytes*/, |
| 275 void** /*buffer*/, |
| 276 MojoMapBufferFlags /*flags*/) { |
| 277 lock_.AssertAcquired(); |
| 278 DCHECK(!is_closed_); |
| 279 // By default, not supported. Only needed for buffer dispatchers. |
| 280 return MOJO_RESULT_INVALID_ARGUMENT; |
| 281 } |
| 282 |
243 MojoResult Dispatcher::AddWaiterImplNoLock(Waiter* /*waiter*/, | 283 MojoResult Dispatcher::AddWaiterImplNoLock(Waiter* /*waiter*/, |
244 MojoWaitFlags /*flags*/, | 284 MojoWaitFlags /*flags*/, |
245 MojoResult /*wake_result*/) { | 285 MojoResult /*wake_result*/) { |
246 lock_.AssertAcquired(); | 286 lock_.AssertAcquired(); |
247 DCHECK(!is_closed_); | 287 DCHECK(!is_closed_); |
248 // By default, waiting isn't supported. Only dispatchers that can be waited on | 288 // By default, waiting isn't supported. Only dispatchers that can be waited on |
249 // will do something nontrivial. | 289 // will do something nontrivial. |
250 return MOJO_RESULT_FAILED_PRECONDITION; | 290 return MOJO_RESULT_FAILED_PRECONDITION; |
251 } | 291 } |
252 | 292 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // DispatcherTransport --------------------------------------------------------- | 327 // DispatcherTransport --------------------------------------------------------- |
288 | 328 |
289 void DispatcherTransport::End() { | 329 void DispatcherTransport::End() { |
290 DCHECK(dispatcher_); | 330 DCHECK(dispatcher_); |
291 dispatcher_->lock_.Release(); | 331 dispatcher_->lock_.Release(); |
292 dispatcher_ = NULL; | 332 dispatcher_ = NULL; |
293 } | 333 } |
294 | 334 |
295 } // namespace system | 335 } // namespace system |
296 } // namespace mojo | 336 } // namespace mojo |
OLD | NEW |