| 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/waiter_test_utils.h" | 5 #include "mojo/edk/system/waiter_test_utils.h" |
| 6 | 6 |
| 7 namespace mojo { | 7 namespace mojo { |
| 8 namespace system { | 8 namespace system { |
| 9 namespace test { | 9 namespace test { |
| 10 | 10 |
| 11 SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint32_t* context) | 11 SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint32_t* context) |
| 12 : base::SimpleThread("waiter_thread"), result_(result), context_(context) { | 12 : result_(result), context_(context) { |
| 13 waiter_.Init(); | 13 waiter_.Init(); |
| 14 *result_ = 5420734; // Totally invalid result. | 14 *result_ = 5420734; // Totally invalid result. |
| 15 *context_ = 23489023; // "Random". | 15 *context_ = 23489023; // "Random". |
| 16 } | 16 } |
| 17 | 17 |
| 18 SimpleWaiterThread::~SimpleWaiterThread() { | 18 SimpleWaiterThread::~SimpleWaiterThread() { |
| 19 Join(); | 19 Join(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void SimpleWaiterThread::Run() { | 22 void SimpleWaiterThread::Run() { |
| 23 *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_); | 23 *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_); |
| 24 } | 24 } |
| 25 | 25 |
| 26 WaiterThread::WaiterThread(scoped_refptr<Dispatcher> dispatcher, | 26 WaiterThread::WaiterThread(scoped_refptr<Dispatcher> dispatcher, |
| 27 MojoHandleSignals handle_signals, | 27 MojoHandleSignals handle_signals, |
| 28 MojoDeadline deadline, | 28 MojoDeadline deadline, |
| 29 uint32_t context, | 29 uint32_t context, |
| 30 bool* did_wait_out, | 30 bool* did_wait_out, |
| 31 MojoResult* result_out, | 31 MojoResult* result_out, |
| 32 uint32_t* context_out, | 32 uint32_t* context_out, |
| 33 HandleSignalsState* signals_state_out) | 33 HandleSignalsState* signals_state_out) |
| 34 : base::SimpleThread("waiter_thread"), | 34 : dispatcher_(dispatcher), |
| 35 dispatcher_(dispatcher), | |
| 36 handle_signals_(handle_signals), | 35 handle_signals_(handle_signals), |
| 37 deadline_(deadline), | 36 deadline_(deadline), |
| 38 context_(context), | 37 context_(context), |
| 39 did_wait_out_(did_wait_out), | 38 did_wait_out_(did_wait_out), |
| 40 result_out_(result_out), | 39 result_out_(result_out), |
| 41 context_out_(context_out), | 40 context_out_(context_out), |
| 42 signals_state_out_(signals_state_out) { | 41 signals_state_out_(signals_state_out) { |
| 43 *did_wait_out_ = false; | 42 *did_wait_out_ = false; |
| 44 // Initialize these with invalid results (so that we'll be sure to catch any | 43 // Initialize these with invalid results (so that we'll be sure to catch any |
| 45 // case where they're not set). | 44 // case where they're not set). |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 return; | 60 return; |
| 62 | 61 |
| 63 *did_wait_out_ = true; | 62 *did_wait_out_ = true; |
| 64 *result_out_ = waiter_.Wait(deadline_, context_out_); | 63 *result_out_ = waiter_.Wait(deadline_, context_out_); |
| 65 dispatcher_->RemoveAwakable(&waiter_, signals_state_out_); | 64 dispatcher_->RemoveAwakable(&waiter_, signals_state_out_); |
| 66 } | 65 } |
| 67 | 66 |
| 68 } // namespace test | 67 } // namespace test |
| 69 } // namespace system | 68 } // namespace system |
| 70 } // namespace mojo | 69 } // namespace mojo |
| OLD | NEW |