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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD)), | 435 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD)), |
436 element_num_bytes_(validated_options.element_num_bytes), | 436 element_num_bytes_(validated_options.element_num_bytes), |
437 capacity_num_bytes_(validated_options.capacity_num_bytes), | 437 capacity_num_bytes_(validated_options.capacity_num_bytes), |
438 producer_open_(true), | 438 producer_open_(true), |
439 consumer_open_(true), | 439 consumer_open_(true), |
440 producer_waiter_list_(has_local_producer ? new WaiterList() : nullptr), | 440 producer_waiter_list_(has_local_producer ? new WaiterList() : nullptr), |
441 consumer_waiter_list_(has_local_consumer ? new WaiterList() : nullptr), | 441 consumer_waiter_list_(has_local_consumer ? new WaiterList() : nullptr), |
442 producer_two_phase_max_num_bytes_written_(0), | 442 producer_two_phase_max_num_bytes_written_(0), |
443 consumer_two_phase_max_num_bytes_read_(0) { | 443 consumer_two_phase_max_num_bytes_read_(0) { |
444 // Check that the passed in options actually are validated. | 444 // Check that the passed in options actually are validated. |
445 MojoCreateDataPipeOptions unused ALLOW_UNUSED = {0}; | 445 MojoCreateDataPipeOptions unused = {0}; |
446 DCHECK_EQ(ValidateCreateOptions(MakeUserPointer(&validated_options), &unused), | 446 DCHECK_EQ(ValidateCreateOptions(MakeUserPointer(&validated_options), &unused), |
447 MOJO_RESULT_OK); | 447 MOJO_RESULT_OK); |
448 } | 448 } |
449 | 449 |
450 DataPipe::~DataPipe() { | 450 DataPipe::~DataPipe() { |
451 DCHECK(!producer_open_); | 451 DCHECK(!producer_open_); |
452 DCHECK(!consumer_open_); | 452 DCHECK(!consumer_open_); |
453 DCHECK(!producer_waiter_list_); | 453 DCHECK(!producer_waiter_list_); |
454 DCHECK(!consumer_waiter_list_); | 454 DCHECK(!consumer_waiter_list_); |
455 } | 455 } |
456 | 456 |
457 void DataPipe::AwakeProducerWaitersForStateChangeNoLock( | 457 void DataPipe::AwakeProducerWaitersForStateChangeNoLock( |
458 const HandleSignalsState& new_producer_state) { | 458 const HandleSignalsState& new_producer_state) { |
459 lock_.AssertAcquired(); | 459 lock_.AssertAcquired(); |
460 if (!has_local_producer_no_lock()) | 460 if (!has_local_producer_no_lock()) |
461 return; | 461 return; |
462 producer_waiter_list_->AwakeWaitersForStateChange(new_producer_state); | 462 producer_waiter_list_->AwakeWaitersForStateChange(new_producer_state); |
463 } | 463 } |
464 | 464 |
465 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock( | 465 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock( |
466 const HandleSignalsState& new_consumer_state) { | 466 const HandleSignalsState& new_consumer_state) { |
467 lock_.AssertAcquired(); | 467 lock_.AssertAcquired(); |
468 if (!has_local_consumer_no_lock()) | 468 if (!has_local_consumer_no_lock()) |
469 return; | 469 return; |
470 consumer_waiter_list_->AwakeWaitersForStateChange(new_consumer_state); | 470 consumer_waiter_list_->AwakeWaitersForStateChange(new_consumer_state); |
471 } | 471 } |
472 | 472 |
473 } // namespace system | 473 } // namespace system |
474 } // namespace mojo | 474 } // namespace mojo |
OLD | NEW |