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 #ifndef MOJO_SYSTEM_WAITER_TEST_UTILS_H_ | 5 #ifndef MOJO_SYSTEM_WAITER_TEST_UTILS_H_ |
6 #define MOJO_SYSTEM_WAITER_TEST_UTILS_H_ | 6 #define MOJO_SYSTEM_WAITER_TEST_UTILS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 class SimpleWaiterThread : public base::SimpleThread { | 47 class SimpleWaiterThread : public base::SimpleThread { |
48 public: | 48 public: |
49 // For the duration of the lifetime of this object, |*result| belongs to it | 49 // For the duration of the lifetime of this object, |*result| belongs to it |
50 // (in the sense that it will write to it whenever it wants). | 50 // (in the sense that it will write to it whenever it wants). |
51 SimpleWaiterThread(MojoResult* result, uint32_t* context); | 51 SimpleWaiterThread(MojoResult* result, uint32_t* context); |
52 virtual ~SimpleWaiterThread(); // Joins the thread. | 52 virtual ~SimpleWaiterThread(); // Joins the thread. |
53 | 53 |
54 Waiter* waiter() { return &waiter_; } | 54 Waiter* waiter() { return &waiter_; } |
55 | 55 |
56 private: | 56 private: |
57 virtual void Run() OVERRIDE; | 57 virtual void Run() override; |
58 | 58 |
59 MojoResult* const result_; | 59 MojoResult* const result_; |
60 uint32_t* const context_; | 60 uint32_t* const context_; |
61 Waiter waiter_; | 61 Waiter waiter_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(SimpleWaiterThread); | 63 DISALLOW_COPY_AND_ASSIGN(SimpleWaiterThread); |
64 }; | 64 }; |
65 | 65 |
66 // This is a more complex and realistic thread that has a |Waiter|, on which it | 66 // This is a more complex and realistic thread that has a |Waiter|, on which it |
67 // waits for the given deadline (with the given flags). Unlike | 67 // waits for the given deadline (with the given flags). Unlike |
68 // |SimpleWaiterThread|, it requires the machinery of |Dispatcher|. | 68 // |SimpleWaiterThread|, it requires the machinery of |Dispatcher|. |
69 class WaiterThread : public base::SimpleThread { | 69 class WaiterThread : public base::SimpleThread { |
70 public: | 70 public: |
71 // Note: |*did_wait_out|, |*result_out|, |*context_out| and | 71 // Note: |*did_wait_out|, |*result_out|, |*context_out| and |
72 // |*signals_state_out| "belong" to this object (i.e., may be modified by, on | 72 // |*signals_state_out| "belong" to this object (i.e., may be modified by, on |
73 // some other thread) while it's alive. | 73 // some other thread) while it's alive. |
74 WaiterThread(scoped_refptr<Dispatcher> dispatcher, | 74 WaiterThread(scoped_refptr<Dispatcher> dispatcher, |
75 MojoHandleSignals handle_signals, | 75 MojoHandleSignals handle_signals, |
76 MojoDeadline deadline, | 76 MojoDeadline deadline, |
77 uint32_t context, | 77 uint32_t context, |
78 bool* did_wait_out, | 78 bool* did_wait_out, |
79 MojoResult* result_out, | 79 MojoResult* result_out, |
80 uint32_t* context_out, | 80 uint32_t* context_out, |
81 HandleSignalsState* signals_state_out); | 81 HandleSignalsState* signals_state_out); |
82 virtual ~WaiterThread(); | 82 virtual ~WaiterThread(); |
83 | 83 |
84 private: | 84 private: |
85 virtual void Run() OVERRIDE; | 85 virtual void Run() override; |
86 | 86 |
87 const scoped_refptr<Dispatcher> dispatcher_; | 87 const scoped_refptr<Dispatcher> dispatcher_; |
88 const MojoHandleSignals handle_signals_; | 88 const MojoHandleSignals handle_signals_; |
89 const MojoDeadline deadline_; | 89 const MojoDeadline deadline_; |
90 const uint32_t context_; | 90 const uint32_t context_; |
91 bool* const did_wait_out_; | 91 bool* const did_wait_out_; |
92 MojoResult* const result_out_; | 92 MojoResult* const result_out_; |
93 uint32_t* const context_out_; | 93 uint32_t* const context_out_; |
94 HandleSignalsState* const signals_state_out_; | 94 HandleSignalsState* const signals_state_out_; |
95 | 95 |
96 Waiter waiter_; | 96 Waiter waiter_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(WaiterThread); | 98 DISALLOW_COPY_AND_ASSIGN(WaiterThread); |
99 }; | 99 }; |
100 | 100 |
101 } // namespace test | 101 } // namespace test |
102 } // namespace system | 102 } // namespace system |
103 } // namespace mojo | 103 } // namespace mojo |
104 | 104 |
105 #endif // MOJO_SYSTEM_WAITER_TEST_UTILS_H_ | 105 #endif // MOJO_SYSTEM_WAITER_TEST_UTILS_H_ |
OLD | NEW |