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
3 // found in the LICENSE file.
5 #include "mojo/edk/system/waiter_test_utils.h"
11 SimpleWaiterThread::SimpleWaiterThread(MojoResult
* result
, uint32_t* context
)
12 : base::SimpleThread("waiter_thread"), result_(result
), context_(context
) {
14 *result_
= -5420734; // Totally invalid result.
15 *context_
= 23489023; // "Random".
18 SimpleWaiterThread::~SimpleWaiterThread() {
22 void SimpleWaiterThread::Run() {
23 *result_
= waiter_
.Wait(MOJO_DEADLINE_INDEFINITE
, context_
);
26 WaiterThread::WaiterThread(scoped_refptr
<Dispatcher
> dispatcher
,
27 MojoHandleSignals handle_signals
,
28 MojoDeadline deadline
,
31 MojoResult
* result_out
,
32 uint32_t* context_out
,
33 HandleSignalsState
* signals_state_out
)
34 : base::SimpleThread("waiter_thread"),
35 dispatcher_(dispatcher
),
36 handle_signals_(handle_signals
),
39 did_wait_out_(did_wait_out
),
40 result_out_(result_out
),
41 context_out_(context_out
),
42 signals_state_out_(signals_state_out
) {
43 *did_wait_out_
= false;
44 // Initialize these with invalid results (so that we'll be sure to catch any
45 // case where they're not set).
46 *result_out_
= -8542346;
47 *context_out_
= 89023444;
48 *signals_state_out_
= HandleSignalsState(~0u, ~0u);
51 WaiterThread::~WaiterThread() {
55 void WaiterThread::Run() {
58 *result_out_
= dispatcher_
->AddAwakable(&waiter_
, handle_signals_
, context_
,
60 if (*result_out_
!= MOJO_RESULT_OK
)
63 *did_wait_out_
= true;
64 *result_out_
= waiter_
.Wait(deadline_
, context_out_
);
65 dispatcher_
->RemoveAwakable(&waiter_
, signals_state_out_
);