| 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/system/data_pipe.h" | 5 #include "mojo/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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 DataPipe::DataPipe(bool has_local_producer, | 430 DataPipe::DataPipe(bool has_local_producer, |
| 431 bool has_local_consumer, | 431 bool has_local_consumer, |
| 432 const MojoCreateDataPipeOptions& validated_options) | 432 const MojoCreateDataPipeOptions& validated_options) |
| 433 : may_discard_((validated_options.flags & | 433 : may_discard_((validated_options.flags & |
| 434 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD)), | 434 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD)), |
| 435 element_num_bytes_(validated_options.element_num_bytes), | 435 element_num_bytes_(validated_options.element_num_bytes), |
| 436 capacity_num_bytes_(validated_options.capacity_num_bytes), | 436 capacity_num_bytes_(validated_options.capacity_num_bytes), |
| 437 producer_open_(true), | 437 producer_open_(true), |
| 438 consumer_open_(true), | 438 consumer_open_(true), |
| 439 producer_waiter_list_(has_local_producer ? new WaiterList() : NULL), | 439 producer_waiter_list_(has_local_producer ? new WaiterList() : nullptr), |
| 440 consumer_waiter_list_(has_local_consumer ? new WaiterList() : NULL), | 440 consumer_waiter_list_(has_local_consumer ? new WaiterList() : nullptr), |
| 441 producer_two_phase_max_num_bytes_written_(0), | 441 producer_two_phase_max_num_bytes_written_(0), |
| 442 consumer_two_phase_max_num_bytes_read_(0) { | 442 consumer_two_phase_max_num_bytes_read_(0) { |
| 443 // Check that the passed in options actually are validated. | 443 // Check that the passed in options actually are validated. |
| 444 MojoCreateDataPipeOptions unused ALLOW_UNUSED = {0}; | 444 MojoCreateDataPipeOptions unused ALLOW_UNUSED = {0}; |
| 445 DCHECK_EQ(ValidateCreateOptions(MakeUserPointer(&validated_options), &unused), | 445 DCHECK_EQ(ValidateCreateOptions(MakeUserPointer(&validated_options), &unused), |
| 446 MOJO_RESULT_OK); | 446 MOJO_RESULT_OK); |
| 447 } | 447 } |
| 448 | 448 |
| 449 DataPipe::~DataPipe() { | 449 DataPipe::~DataPipe() { |
| 450 DCHECK(!producer_open_); | 450 DCHECK(!producer_open_); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 464 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock( | 464 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock( |
| 465 const HandleSignalsState& new_consumer_state) { | 465 const HandleSignalsState& new_consumer_state) { |
| 466 lock_.AssertAcquired(); | 466 lock_.AssertAcquired(); |
| 467 if (!has_local_consumer_no_lock()) | 467 if (!has_local_consumer_no_lock()) |
| 468 return; | 468 return; |
| 469 consumer_waiter_list_->AwakeWaitersForStateChange(new_consumer_state); | 469 consumer_waiter_list_->AwakeWaitersForStateChange(new_consumer_state); |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace system | 472 } // namespace system |
| 473 } // namespace mojo | 473 } // namespace mojo |
| OLD | NEW |