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 19 matching lines...) Expand all Loading... |
30 }; | 30 }; |
31 if (!in_options) { | 31 if (!in_options) { |
32 *out_options = kDefaultOptions; | 32 *out_options = kDefaultOptions; |
33 return MOJO_RESULT_OK; | 33 return MOJO_RESULT_OK; |
34 } | 34 } |
35 | 35 |
36 if (in_options->struct_size < sizeof(*in_options)) | 36 if (in_options->struct_size < sizeof(*in_options)) |
37 return MOJO_RESULT_INVALID_ARGUMENT; | 37 return MOJO_RESULT_INVALID_ARGUMENT; |
38 out_options->struct_size = static_cast<uint32_t>(sizeof(*out_options)); | 38 out_options->struct_size = static_cast<uint32_t>(sizeof(*out_options)); |
39 | 39 |
| 40 // All flags are okay (unrecognized flags will be ignored). |
| 41 out_options->flags = in_options->flags; |
| 42 |
40 if (in_options->element_num_bytes == 0) | 43 if (in_options->element_num_bytes == 0) |
41 return MOJO_RESULT_INVALID_ARGUMENT; | 44 return MOJO_RESULT_INVALID_ARGUMENT; |
42 out_options->element_num_bytes = in_options->element_num_bytes; | 45 out_options->element_num_bytes = in_options->element_num_bytes; |
43 | 46 |
44 if (in_options->capacity_num_bytes == 0) { | 47 if (in_options->capacity_num_bytes == 0) { |
45 // Round the default capacity down to a multiple of the element size (but at | 48 // Round the default capacity down to a multiple of the element size (but at |
46 // least one element). | 49 // least one element). |
47 out_options->capacity_num_bytes = std::max( | 50 out_options->capacity_num_bytes = std::max( |
48 static_cast<uint32_t>(kDefaultDataPipeCapacityBytes - | 51 static_cast<uint32_t>(kDefaultDataPipeCapacityBytes - |
49 (kDefaultDataPipeCapacityBytes % in_options->element_num_bytes)), | 52 (kDefaultDataPipeCapacityBytes % in_options->element_num_bytes)), |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock() { | 311 void DataPipe::AwakeConsumerWaitersForStateChangeNoLock() { |
309 lock_.AssertAcquired(); | 312 lock_.AssertAcquired(); |
310 if (!has_local_consumer_no_lock()) | 313 if (!has_local_consumer_no_lock()) |
311 return; | 314 return; |
312 consumer_waiter_list_->AwakeWaitersForStateChange( | 315 consumer_waiter_list_->AwakeWaitersForStateChange( |
313 ConsumerSatisfiedFlagsNoLock(), ConsumerSatisfiableFlagsNoLock()); | 316 ConsumerSatisfiedFlagsNoLock(), ConsumerSatisfiableFlagsNoLock()); |
314 } | 317 } |
315 | 318 |
316 } // namespace system | 319 } // namespace system |
317 } // namespace mojo | 320 } // namespace mojo |
OLD | NEW |