| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 platform_handles); | 450 platform_handles); |
| 451 | 451 |
| 452 ProducerCancelAllStateNoLock(); | 452 ProducerCancelAllStateNoLock(); |
| 453 producer_awakable_list_.reset(); | 453 producer_awakable_list_.reset(); |
| 454 if (!has_local_consumer_no_lock()) | 454 if (!has_local_consumer_no_lock()) |
| 455 producer_open_ = false; | 455 producer_open_ = false; |
| 456 | 456 |
| 457 return rv; | 457 return rv; |
| 458 } | 458 } |
| 459 | 459 |
| 460 bool DataPipe::ProducerIsBusy() const { | |
| 461 MutexLocker locker(&mutex_); | |
| 462 return producer_in_two_phase_write_no_lock(); | |
| 463 } | |
| 464 | |
| 465 void DataPipe::ConsumerCancelAllState() { | 460 void DataPipe::ConsumerCancelAllState() { |
| 466 MutexLocker locker(&mutex_); | 461 MutexLocker locker(&mutex_); |
| 467 ConsumerCancelAllStateNoLock(); | 462 ConsumerCancelAllStateNoLock(); |
| 468 } | 463 } |
| 469 | 464 |
| 470 void DataPipe::ConsumerClose() { | 465 void DataPipe::ConsumerClose() { |
| 471 MutexLocker locker(&mutex_); | 466 MutexLocker locker(&mutex_); |
| 472 ConsumerCloseNoLock(); | 467 ConsumerCloseNoLock(); |
| 473 } | 468 } |
| 474 | 469 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 platform_handles); | 669 platform_handles); |
| 675 | 670 |
| 676 ConsumerCancelAllStateNoLock(); | 671 ConsumerCancelAllStateNoLock(); |
| 677 consumer_awakable_list_.reset(); | 672 consumer_awakable_list_.reset(); |
| 678 if (!has_local_producer_no_lock()) | 673 if (!has_local_producer_no_lock()) |
| 679 consumer_open_ = false; | 674 consumer_open_ = false; |
| 680 | 675 |
| 681 return rv; | 676 return rv; |
| 682 } | 677 } |
| 683 | 678 |
| 684 bool DataPipe::ConsumerIsBusy() const { | |
| 685 MutexLocker locker(&mutex_); | |
| 686 return consumer_in_two_phase_read_no_lock(); | |
| 687 } | |
| 688 | |
| 689 DataPipe::DataPipe(bool has_local_producer, | 679 DataPipe::DataPipe(bool has_local_producer, |
| 690 bool has_local_consumer, | 680 bool has_local_consumer, |
| 691 const MojoCreateDataPipeOptions& validated_options, | 681 const MojoCreateDataPipeOptions& validated_options, |
| 692 std::unique_ptr<DataPipeImpl> impl) | 682 std::unique_ptr<DataPipeImpl> impl) |
| 693 : element_num_bytes_(validated_options.element_num_bytes), | 683 : element_num_bytes_(validated_options.element_num_bytes), |
| 694 capacity_num_bytes_(validated_options.capacity_num_bytes), | 684 capacity_num_bytes_(validated_options.capacity_num_bytes), |
| 695 producer_open_(true), | 685 producer_open_(true), |
| 696 consumer_open_(true), | 686 consumer_open_(true), |
| 697 producer_write_threshold_num_bytes_(0), | 687 producer_write_threshold_num_bytes_(0), |
| 698 consumer_read_threshold_num_bytes_(0), | 688 consumer_read_threshold_num_bytes_(0), |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 SetProducerClosedNoLock(); | 847 SetProducerClosedNoLock(); |
| 858 } | 848 } |
| 859 | 849 |
| 860 void DataPipe::SetConsumerClosed() { | 850 void DataPipe::SetConsumerClosed() { |
| 861 MutexLocker locker(&mutex_); | 851 MutexLocker locker(&mutex_); |
| 862 SetConsumerClosedNoLock(); | 852 SetConsumerClosedNoLock(); |
| 863 } | 853 } |
| 864 | 854 |
| 865 } // namespace system | 855 } // namespace system |
| 866 } // namespace mojo | 856 } // namespace mojo |
| OLD | NEW |