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/common/message_pump_mojo.h" | 5 #include "mojo/common/message_pump_mojo.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void MessagePumpMojo::SignalControlPipe(const RunState& run_state) { | 208 void MessagePumpMojo::SignalControlPipe(const RunState& run_state) { |
209 // TODO(sky): deal with error? | 209 // TODO(sky): deal with error? |
210 WriteMessageRaw(run_state.write_handle.get(), NULL, 0, NULL, 0, | 210 WriteMessageRaw(run_state.write_handle.get(), NULL, 0, NULL, 0, |
211 MOJO_WRITE_MESSAGE_FLAG_NONE); | 211 MOJO_WRITE_MESSAGE_FLAG_NONE); |
212 } | 212 } |
213 | 213 |
214 MessagePumpMojo::WaitState MessagePumpMojo::GetWaitState( | 214 MessagePumpMojo::WaitState MessagePumpMojo::GetWaitState( |
215 const RunState& run_state) const { | 215 const RunState& run_state) const { |
216 WaitState wait_state; | 216 WaitState wait_state; |
217 wait_state.handles.push_back(run_state.read_handle.get()); | 217 wait_state.handles.push_back(run_state.read_handle.get()); |
218 wait_state.wait_signals.push_back(MOJO_WAIT_FLAG_READABLE); | 218 wait_state.wait_signals.push_back(MOJO_HANDLE_SIGNAL_READABLE); |
219 | 219 |
220 for (HandleToHandler::const_iterator i = handlers_.begin(); | 220 for (HandleToHandler::const_iterator i = handlers_.begin(); |
221 i != handlers_.end(); ++i) { | 221 i != handlers_.end(); ++i) { |
222 wait_state.handles.push_back(i->first); | 222 wait_state.handles.push_back(i->first); |
223 wait_state.wait_signals.push_back(i->second.wait_signals); | 223 wait_state.wait_signals.push_back(i->second.wait_signals); |
224 } | 224 } |
225 return wait_state; | 225 return wait_state; |
226 } | 226 } |
227 | 227 |
228 MojoDeadline MessagePumpMojo::GetDeadlineForWait( | 228 MojoDeadline MessagePumpMojo::GetDeadlineForWait( |
229 const RunState& run_state) const { | 229 const RunState& run_state) const { |
230 base::TimeTicks min_time = run_state.delayed_work_time; | 230 base::TimeTicks min_time = run_state.delayed_work_time; |
231 for (HandleToHandler::const_iterator i = handlers_.begin(); | 231 for (HandleToHandler::const_iterator i = handlers_.begin(); |
232 i != handlers_.end(); ++i) { | 232 i != handlers_.end(); ++i) { |
233 if (min_time.is_null() && i->second.deadline < min_time) | 233 if (min_time.is_null() && i->second.deadline < min_time) |
234 min_time = i->second.deadline; | 234 min_time = i->second.deadline; |
235 } | 235 } |
236 return min_time.is_null() ? MOJO_DEADLINE_INDEFINITE : | 236 return min_time.is_null() ? MOJO_DEADLINE_INDEFINITE : |
237 std::max(static_cast<MojoDeadline>(0), | 237 std::max(static_cast<MojoDeadline>(0), |
238 static_cast<MojoDeadline>( | 238 static_cast<MojoDeadline>( |
239 (min_time - internal::NowTicks()).InMicroseconds())); | 239 (min_time - internal::NowTicks()).InMicroseconds())); |
240 } | 240 } |
241 | 241 |
242 } // namespace common | 242 } // namespace common |
243 } // namespace mojo | 243 } // namespace mojo |
OLD | NEW |