| 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/data_pipe_consumer_dispatcher.h" | 9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
| 10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 if (is_closed_) { | 330 if (is_closed_) { |
| 331 if (signals_state) | 331 if (signals_state) |
| 332 *signals_state = HandleSignalsState(); | 332 *signals_state = HandleSignalsState(); |
| 333 return MOJO_RESULT_INVALID_ARGUMENT; | 333 return MOJO_RESULT_INVALID_ARGUMENT; |
| 334 } | 334 } |
| 335 | 335 |
| 336 return AddAwakableImplNoLock(awakable, signals, true, context, signals_state); | 336 return AddAwakableImplNoLock(awakable, signals, true, context, signals_state); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void Dispatcher::RemoveAwakable(Awakable* awakable, | 339 void Dispatcher::RemoveAwakable(Awakable* awakable, |
| 340 HandleSignalsState* handle_signals_state) { | 340 HandleSignalsState* signals_state) { |
| 341 MutexLocker locker(&mutex_); | 341 MutexLocker locker(&mutex_); |
| 342 if (is_closed_) { | 342 if (is_closed_) { |
| 343 if (handle_signals_state) | 343 if (signals_state) |
| 344 *handle_signals_state = HandleSignalsState(); | 344 *signals_state = HandleSignalsState(); |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 | 347 |
| 348 RemoveAwakableImplNoLock(awakable, handle_signals_state); | 348 RemoveAwakableImplNoLock(awakable, signals_state); |
| 349 } |
| 350 |
| 351 void Dispatcher::RemoveAwakableWithContext(Awakable* awakable, |
| 352 uint64_t context, |
| 353 HandleSignalsState* signals_state) { |
| 354 MutexLocker locker(&mutex_); |
| 355 if (is_closed_) { |
| 356 if (signals_state) |
| 357 *signals_state = HandleSignalsState(); |
| 358 return; |
| 359 } |
| 360 |
| 361 RemoveAwakableWithContextImplNoLock(awakable, context, signals_state); |
| 349 } | 362 } |
| 350 | 363 |
| 351 Dispatcher::Dispatcher() : is_closed_(false) {} | 364 Dispatcher::Dispatcher() : is_closed_(false) {} |
| 352 | 365 |
| 353 Dispatcher::~Dispatcher() { | 366 Dispatcher::~Dispatcher() { |
| 354 // Make sure that |Close()| was called. | 367 // Make sure that |Close()| was called. |
| 355 DCHECK(is_closed_); | 368 DCHECK(is_closed_); |
| 356 } | 369 } |
| 357 | 370 |
| 358 void Dispatcher::CancelAllStateNoLock() { | 371 void Dispatcher::CancelAllStateNoLock() { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 void Dispatcher::RemoveAwakableImplNoLock(Awakable* /*awakable*/, | 585 void Dispatcher::RemoveAwakableImplNoLock(Awakable* /*awakable*/, |
| 573 HandleSignalsState* signals_state) { | 586 HandleSignalsState* signals_state) { |
| 574 mutex_.AssertHeld(); | 587 mutex_.AssertHeld(); |
| 575 DCHECK(!is_closed_); | 588 DCHECK(!is_closed_); |
| 576 // By default, waiting isn't supported. Only dispatchers that can be waited on | 589 // By default, waiting isn't supported. Only dispatchers that can be waited on |
| 577 // will do something nontrivial. | 590 // will do something nontrivial. |
| 578 if (signals_state) | 591 if (signals_state) |
| 579 *signals_state = HandleSignalsState(); | 592 *signals_state = HandleSignalsState(); |
| 580 } | 593 } |
| 581 | 594 |
| 595 void Dispatcher::RemoveAwakableWithContextImplNoLock( |
| 596 Awakable* /*awakable*/, |
| 597 uint64_t /*context*/, |
| 598 HandleSignalsState* signals_state) { |
| 599 mutex_.AssertHeld(); |
| 600 DCHECK(!is_closed_); |
| 601 // By default, waiting isn't supported. Only dispatchers that can be waited on |
| 602 // will do something nontrivial. |
| 603 if (signals_state) |
| 604 *signals_state = HandleSignalsState(); |
| 605 } |
| 606 |
| 582 void Dispatcher::StartSerializeImplNoLock(Channel* /*channel*/, | 607 void Dispatcher::StartSerializeImplNoLock(Channel* /*channel*/, |
| 583 size_t* max_size, | 608 size_t* max_size, |
| 584 size_t* max_platform_handles) { | 609 size_t* max_platform_handles) { |
| 585 AssertHasOneRef(); // Only one ref => no need to take the lock. | 610 AssertHasOneRef(); // Only one ref => no need to take the lock. |
| 586 DCHECK(!is_closed_); | 611 DCHECK(!is_closed_); |
| 587 *max_size = 0; | 612 *max_size = 0; |
| 588 *max_platform_handles = 0; | 613 *max_platform_handles = 0; |
| 589 } | 614 } |
| 590 | 615 |
| 591 bool Dispatcher::EndSerializeAndCloseImplNoLock( | 616 bool Dispatcher::EndSerializeAndCloseImplNoLock( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 // want to remove or weaken). | 676 // want to remove or weaken). |
| 652 MutexLocker locker(&mutex_); | 677 MutexLocker locker(&mutex_); |
| 653 #endif | 678 #endif |
| 654 | 679 |
| 655 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size, | 680 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size, |
| 656 platform_handles); | 681 platform_handles); |
| 657 } | 682 } |
| 658 | 683 |
| 659 } // namespace system | 684 } // namespace system |
| 660 } // namespace mojo | 685 } // namespace mojo |
| OLD | NEW |