| 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/dispatcher.h" | 5 #include "mojo/edk/system/dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/edk/system/configuration.h" | 8 #include "mojo/edk/system/configuration.h" |
| 9 #include "mojo/edk/system/message_pipe_dispatcher.h" | 9 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 10 #include "mojo/edk/system/platform_handle_dispatcher.h" | 10 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 base::AutoLock locker(lock_); | 239 base::AutoLock locker(lock_); |
| 240 if (is_closed_) { | 240 if (is_closed_) { |
| 241 if (handle_signals_state) | 241 if (handle_signals_state) |
| 242 *handle_signals_state = HandleSignalsState(); | 242 *handle_signals_state = HandleSignalsState(); |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 | 245 |
| 246 RemoveAwakableImplNoLock(awakable, handle_signals_state); | 246 RemoveAwakableImplNoLock(awakable, handle_signals_state); |
| 247 } | 247 } |
| 248 | 248 |
| 249 MojoResult Dispatcher::SetAsyncMessageCallback( |
| 250 const AsyncMessageCallback& callback) { |
| 251 base::AutoLock locker(lock_); |
| 252 return SetAsyncMessageCallbackImplNoLock(callback); |
| 253 } |
| 254 |
| 249 Dispatcher::Dispatcher() : is_closed_(false) { | 255 Dispatcher::Dispatcher() : is_closed_(false) { |
| 250 } | 256 } |
| 251 | 257 |
| 252 Dispatcher::~Dispatcher() { | 258 Dispatcher::~Dispatcher() { |
| 253 // Make sure that |Close()| was called. | 259 // Make sure that |Close()| was called. |
| 254 DCHECK(is_closed_); | 260 DCHECK(is_closed_); |
| 255 } | 261 } |
| 256 | 262 |
| 257 void Dispatcher::CancelAllAwakablesNoLock() { | 263 void Dispatcher::CancelAllAwakablesNoLock() { |
| 258 lock_.AssertAcquired(); | 264 lock_.AssertAcquired(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 void Dispatcher::RemoveAwakableImplNoLock(Awakable* /*awakable*/, | 394 void Dispatcher::RemoveAwakableImplNoLock(Awakable* /*awakable*/, |
| 389 HandleSignalsState* signals_state) { | 395 HandleSignalsState* signals_state) { |
| 390 lock_.AssertAcquired(); | 396 lock_.AssertAcquired(); |
| 391 DCHECK(!is_closed_); | 397 DCHECK(!is_closed_); |
| 392 // By default, waiting isn't supported. Only dispatchers that can be waited on | 398 // By default, waiting isn't supported. Only dispatchers that can be waited on |
| 393 // will do something nontrivial. | 399 // will do something nontrivial. |
| 394 if (signals_state) | 400 if (signals_state) |
| 395 *signals_state = HandleSignalsState(); | 401 *signals_state = HandleSignalsState(); |
| 396 } | 402 } |
| 397 | 403 |
| 404 MojoResult Dispatcher::SetAsyncMessageCallbackImplNoLock( |
| 405 const AsyncMessageCallback& callback) { |
| 406 lock_.AssertAcquired(); |
| 407 NOTREACHED(); |
| 408 return MOJO_RESULT_INTERNAL; |
| 409 } |
| 410 |
| 398 void Dispatcher::StartSerializeImplNoLock(Channel* /*channel*/, | 411 void Dispatcher::StartSerializeImplNoLock(Channel* /*channel*/, |
| 399 size_t* max_size, | 412 size_t* max_size, |
| 400 size_t* max_platform_handles) { | 413 size_t* max_platform_handles) { |
| 401 DCHECK(HasOneRef()); // Only one ref => no need to take the lock. | 414 DCHECK(HasOneRef()); // Only one ref => no need to take the lock. |
| 402 DCHECK(!is_closed_); | 415 DCHECK(!is_closed_); |
| 403 *max_size = 0; | 416 *max_size = 0; |
| 404 *max_platform_handles = 0; | 417 *max_platform_handles = 0; |
| 405 } | 418 } |
| 406 | 419 |
| 407 bool Dispatcher::EndSerializeAndCloseImplNoLock( | 420 bool Dispatcher::EndSerializeAndCloseImplNoLock( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // DispatcherTransport --------------------------------------------------------- | 496 // DispatcherTransport --------------------------------------------------------- |
| 484 | 497 |
| 485 void DispatcherTransport::End() { | 498 void DispatcherTransport::End() { |
| 486 DCHECK(dispatcher_); | 499 DCHECK(dispatcher_); |
| 487 dispatcher_->lock_.Release(); | 500 dispatcher_->lock_.Release(); |
| 488 dispatcher_ = nullptr; | 501 dispatcher_ = nullptr; |
| 489 } | 502 } |
| 490 | 503 |
| 491 } // namespace system | 504 } // namespace system |
| 492 } // namespace mojo | 505 } // namespace mojo |
| OLD | NEW |