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/local_message_pipe_endpoint.h" | 5 #include "mojo/system/local_message_pipe_endpoint.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "mojo/system/dispatcher.h" | 10 #include "mojo/system/dispatcher.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 if (!enough_space) | 124 if (!enough_space) |
125 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 125 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
126 | 126 |
127 return MOJO_RESULT_OK; | 127 return MOJO_RESULT_OK; |
128 } | 128 } |
129 | 129 |
130 MojoResult LocalMessagePipeEndpoint::AddWaiter(Waiter* waiter, | 130 MojoResult LocalMessagePipeEndpoint::AddWaiter(Waiter* waiter, |
131 MojoWaitFlags flags, | 131 MojoHandleSignals signals, |
132 uint32_t context) { | 132 uint32_t context) { |
133 DCHECK(is_open_); | 133 DCHECK(is_open_); |
134 | 134 |
135 WaitFlagsState state = GetWaitFlagsState(); | 135 WaitFlagsState state = GetWaitFlagsState(); |
136 if (state.satisfies(flags)) | 136 if (state.satisfies(signals)) |
137 return MOJO_RESULT_ALREADY_EXISTS; | 137 return MOJO_RESULT_ALREADY_EXISTS; |
138 if (!state.can_satisfy(flags)) | 138 if (!state.can_satisfy(signals)) |
139 return MOJO_RESULT_FAILED_PRECONDITION; | 139 return MOJO_RESULT_FAILED_PRECONDITION; |
140 | 140 |
141 waiter_list_.AddWaiter(waiter, flags, context); | 141 waiter_list_.AddWaiter(waiter, signals, context); |
142 return MOJO_RESULT_OK; | 142 return MOJO_RESULT_OK; |
143 } | 143 } |
144 | 144 |
145 void LocalMessagePipeEndpoint::RemoveWaiter(Waiter* waiter) { | 145 void LocalMessagePipeEndpoint::RemoveWaiter(Waiter* waiter) { |
146 DCHECK(is_open_); | 146 DCHECK(is_open_); |
147 waiter_list_.RemoveWaiter(waiter); | 147 waiter_list_.RemoveWaiter(waiter); |
148 } | 148 } |
149 | 149 |
150 WaitFlagsState LocalMessagePipeEndpoint::GetWaitFlagsState() { | 150 WaitFlagsState LocalMessagePipeEndpoint::GetWaitFlagsState() { |
151 WaitFlagsState rv; | 151 WaitFlagsState rv; |
152 if (!message_queue_.IsEmpty()) { | 152 if (!message_queue_.IsEmpty()) { |
153 rv.satisfied_flags |= MOJO_WAIT_FLAG_READABLE; | 153 rv.satisfied_signals |= MOJO_WAIT_FLAG_READABLE; |
154 rv.satisfiable_flags |= MOJO_WAIT_FLAG_READABLE; | 154 rv.satisfiable_signals |= MOJO_WAIT_FLAG_READABLE; |
155 } | 155 } |
156 if (is_peer_open_) { | 156 if (is_peer_open_) { |
157 rv.satisfied_flags |= MOJO_WAIT_FLAG_WRITABLE; | 157 rv.satisfied_signals |= MOJO_WAIT_FLAG_WRITABLE; |
158 rv.satisfiable_flags |= MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE; | 158 rv.satisfiable_signals |= MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE; |
159 } | 159 } |
160 return rv; | 160 return rv; |
161 } | 161 } |
162 | 162 |
163 } // namespace system | 163 } // namespace system |
164 } // namespace mojo | 164 } // namespace mojo |
OLD | NEW |