Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: mojo/edk/system/waiter_test_utils.cc

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/waiter_test_utils.h ('k') | mojo/edk/system/waiter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "mojo/edk/system/waiter_test_utils.h"
6
7 namespace mojo {
8 namespace system {
9 namespace test {
10
11 SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint32_t* context)
12 : base::SimpleThread("waiter_thread"), result_(result), context_(context) {
13 waiter_.Init();
14 *result_ = -5420734; // Totally invalid result.
15 *context_ = 23489023; // "Random".
16 }
17
18 SimpleWaiterThread::~SimpleWaiterThread() {
19 Join();
20 }
21
22 void SimpleWaiterThread::Run() {
23 *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_);
24 }
25
26 WaiterThread::WaiterThread(scoped_refptr<Dispatcher> dispatcher,
27 MojoHandleSignals handle_signals,
28 MojoDeadline deadline,
29 uint32_t context,
30 bool* did_wait_out,
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),
37 deadline_(deadline),
38 context_(context),
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);
49 }
50
51 WaiterThread::~WaiterThread() {
52 Join();
53 }
54
55 void WaiterThread::Run() {
56 waiter_.Init();
57
58 *result_out_ = dispatcher_->AddAwakable(&waiter_, handle_signals_, context_,
59 signals_state_out_);
60 if (*result_out_ != MOJO_RESULT_OK)
61 return;
62
63 *did_wait_out_ = true;
64 *result_out_ = waiter_.Wait(deadline_, context_out_);
65 dispatcher_->RemoveAwakable(&waiter_, signals_state_out_);
66 }
67
68 } // namespace test
69 } // namespace system
70 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/waiter_test_utils.h ('k') | mojo/edk/system/waiter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698