| 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/data_pipe.h" | 5 #include "mojo/edk/system/data_pipe.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 392 } |
| 393 | 393 |
| 394 HandleSignalsState DataPipe::ProducerGetHandleSignalsState() { | 394 HandleSignalsState DataPipe::ProducerGetHandleSignalsState() { |
| 395 MutexLocker locker(&mutex_); | 395 MutexLocker locker(&mutex_); |
| 396 DCHECK(has_local_producer_no_lock()); | 396 DCHECK(has_local_producer_no_lock()); |
| 397 return impl_->ProducerGetHandleSignalsState(); | 397 return impl_->ProducerGetHandleSignalsState(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 MojoResult DataPipe::ProducerAddAwakable(Awakable* awakable, | 400 MojoResult DataPipe::ProducerAddAwakable(Awakable* awakable, |
| 401 MojoHandleSignals signals, | 401 MojoHandleSignals signals, |
| 402 bool force, |
| 402 uint64_t context, | 403 uint64_t context, |
| 403 HandleSignalsState* signals_state) { | 404 HandleSignalsState* signals_state) { |
| 404 MutexLocker locker(&mutex_); | 405 MutexLocker locker(&mutex_); |
| 405 DCHECK(has_local_producer_no_lock()); | 406 DCHECK(has_local_producer_no_lock()); |
| 406 | 407 |
| 407 HandleSignalsState producer_state = impl_->ProducerGetHandleSignalsState(); | 408 HandleSignalsState producer_state = impl_->ProducerGetHandleSignalsState(); |
| 408 if (producer_state.satisfies(signals)) { | 409 if (producer_state.satisfies(signals)) { |
| 410 if (force) |
| 411 producer_awakable_list_->Add(awakable, signals, context); |
| 409 if (signals_state) | 412 if (signals_state) |
| 410 *signals_state = producer_state; | 413 *signals_state = producer_state; |
| 411 return MOJO_RESULT_ALREADY_EXISTS; | 414 return MOJO_RESULT_ALREADY_EXISTS; |
| 412 } | 415 } |
| 413 if (!producer_state.can_satisfy(signals)) { | 416 if (!producer_state.can_satisfy(signals)) { |
| 414 if (signals_state) | 417 if (signals_state) |
| 415 *signals_state = producer_state; | 418 *signals_state = producer_state; |
| 416 return MOJO_RESULT_FAILED_PRECONDITION; | 419 return MOJO_RESULT_FAILED_PRECONDITION; |
| 417 } | 420 } |
| 418 | 421 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 614 } |
| 612 | 615 |
| 613 HandleSignalsState DataPipe::ConsumerGetHandleSignalsState() { | 616 HandleSignalsState DataPipe::ConsumerGetHandleSignalsState() { |
| 614 MutexLocker locker(&mutex_); | 617 MutexLocker locker(&mutex_); |
| 615 DCHECK(has_local_consumer_no_lock()); | 618 DCHECK(has_local_consumer_no_lock()); |
| 616 return impl_->ConsumerGetHandleSignalsState(); | 619 return impl_->ConsumerGetHandleSignalsState(); |
| 617 } | 620 } |
| 618 | 621 |
| 619 MojoResult DataPipe::ConsumerAddAwakable(Awakable* awakable, | 622 MojoResult DataPipe::ConsumerAddAwakable(Awakable* awakable, |
| 620 MojoHandleSignals signals, | 623 MojoHandleSignals signals, |
| 624 bool force, |
| 621 uint64_t context, | 625 uint64_t context, |
| 622 HandleSignalsState* signals_state) { | 626 HandleSignalsState* signals_state) { |
| 623 MutexLocker locker(&mutex_); | 627 MutexLocker locker(&mutex_); |
| 624 DCHECK(has_local_consumer_no_lock()); | 628 DCHECK(has_local_consumer_no_lock()); |
| 625 | 629 |
| 626 HandleSignalsState consumer_state = impl_->ConsumerGetHandleSignalsState(); | 630 HandleSignalsState consumer_state = impl_->ConsumerGetHandleSignalsState(); |
| 627 if (consumer_state.satisfies(signals)) { | 631 if (consumer_state.satisfies(signals)) { |
| 632 if (force) |
| 633 consumer_awakable_list_->Add(awakable, signals, context); |
| 628 if (signals_state) | 634 if (signals_state) |
| 629 *signals_state = consumer_state; | 635 *signals_state = consumer_state; |
| 630 return MOJO_RESULT_ALREADY_EXISTS; | 636 return MOJO_RESULT_ALREADY_EXISTS; |
| 631 } | 637 } |
| 632 if (!consumer_state.can_satisfy(signals)) { | 638 if (!consumer_state.can_satisfy(signals)) { |
| 633 if (signals_state) | 639 if (signals_state) |
| 634 *signals_state = consumer_state; | 640 *signals_state = consumer_state; |
| 635 return MOJO_RESULT_FAILED_PRECONDITION; | 641 return MOJO_RESULT_FAILED_PRECONDITION; |
| 636 } | 642 } |
| 637 | 643 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 SetProducerClosedNoLock(); | 853 SetProducerClosedNoLock(); |
| 848 } | 854 } |
| 849 | 855 |
| 850 void DataPipe::SetConsumerClosed() { | 856 void DataPipe::SetConsumerClosed() { |
| 851 MutexLocker locker(&mutex_); | 857 MutexLocker locker(&mutex_); |
| 852 SetConsumerClosedNoLock(); | 858 SetConsumerClosedNoLock(); |
| 853 } | 859 } |
| 854 | 860 |
| 855 } // namespace system | 861 } // namespace system |
| 856 } // namespace mojo | 862 } // namespace mojo |
| OLD | NEW |