diff options
author | jamesr <jamesr@chromium.org> | 2014-10-02 21:26:48 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-03 04:27:07 +0000 |
commit | a03ae49d253d7d1f517e2f92146a6ba201c78aa6 (patch) | |
tree | df4eae1239d49490fa4e85d184b9000224a7a31c /mojo/edk/system/waiter_test_utils.cc | |
parent | 24b9789375c3c23d0d10e5197c6a7674946ea44b (diff) | |
download | chromium_src-a03ae49d253d7d1f517e2f92146a6ba201c78aa6.zip chromium_src-a03ae49d253d7d1f517e2f92146a6ba201c78aa6.tar.gz chromium_src-a03ae49d253d7d1f517e2f92146a6ba201c78aa6.tar.bz2 |
Move mojo edk into mojo/edk
This creates a mojo/edk directory which contains the "embedder developer
kit" aka the set of code needed to embed mojo code.
mojo/edk/embedder = code from mojo/embedder
mojo/edk/system = code from mojo/system
mojo/edk/test = code used to test the previous two, from mojo/common/test
mojo/edk/ can only depend on mojo/public/, base/ and itself.
R=viettrungluu@chromium.org
TBR=sky@chromium.org for file renames
Committed: https://chromium.googlesource.com/chromium/src/+/ee7ff197a98da4636f33bd713de784948b487bd4
Review URL: https://codereview.chromium.org/621153003
Cr-Commit-Position: refs/heads/master@{#297986}
Diffstat (limited to 'mojo/edk/system/waiter_test_utils.cc')
-rw-r--r-- | mojo/edk/system/waiter_test_utils.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/mojo/edk/system/waiter_test_utils.cc b/mojo/edk/system/waiter_test_utils.cc new file mode 100644 index 0000000..06a4033 --- /dev/null +++ b/mojo/edk/system/waiter_test_utils.cc @@ -0,0 +1,70 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/edk/system/waiter_test_utils.h" + +namespace mojo { +namespace system { +namespace test { + +SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint32_t* context) + : base::SimpleThread("waiter_thread"), result_(result), context_(context) { + waiter_.Init(); + *result_ = -5420734; // Totally invalid result. + *context_ = 23489023; // "Random". +} + +SimpleWaiterThread::~SimpleWaiterThread() { + Join(); +} + +void SimpleWaiterThread::Run() { + *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_); +} + +WaiterThread::WaiterThread(scoped_refptr<Dispatcher> dispatcher, + MojoHandleSignals handle_signals, + MojoDeadline deadline, + uint32_t context, + bool* did_wait_out, + MojoResult* result_out, + uint32_t* context_out, + HandleSignalsState* signals_state_out) + : base::SimpleThread("waiter_thread"), + dispatcher_(dispatcher), + handle_signals_(handle_signals), + deadline_(deadline), + context_(context), + did_wait_out_(did_wait_out), + result_out_(result_out), + context_out_(context_out), + signals_state_out_(signals_state_out) { + *did_wait_out_ = false; + // Initialize these with invalid results (so that we'll be sure to catch any + // case where they're not set). + *result_out_ = -8542346; + *context_out_ = 89023444; + *signals_state_out_ = HandleSignalsState(~0u, ~0u); +} + +WaiterThread::~WaiterThread() { + Join(); +} + +void WaiterThread::Run() { + waiter_.Init(); + + *result_out_ = dispatcher_->AddWaiter( + &waiter_, handle_signals_, context_, signals_state_out_); + if (*result_out_ != MOJO_RESULT_OK) + return; + + *did_wait_out_ = true; + *result_out_ = waiter_.Wait(deadline_, context_out_); + dispatcher_->RemoveWaiter(&waiter_, signals_state_out_); +} + +} // namespace test +} // namespace system +} // namespace mojo |