OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/dns/serial_worker.h" | 5 #include "net/dns/serial_worker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 void RunUntilBreak(const std::string& b) { | 77 void RunUntilBreak(const std::string& b) { |
78 message_loop_->Run(); | 78 message_loop_->Run(); |
79 ASSERT_EQ(breakpoint_, b); | 79 ASSERT_EQ(breakpoint_, b); |
80 } | 80 } |
81 | 81 |
82 SerialWorkerTest() | 82 SerialWorkerTest() |
83 : input_value_(0), | 83 : input_value_(0), |
84 output_value_(-1), | 84 output_value_(-1), |
85 work_allowed_(false, false), | 85 work_allowed_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
86 work_called_(false, false), | 86 base::WaitableEvent::InitialState::NOT_SIGNALED), |
87 work_running_(false) { | 87 work_called_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
88 } | 88 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 89 work_running_(false) {} |
89 | 90 |
90 // Helpers for tests. | 91 // Helpers for tests. |
91 | 92 |
92 // Lets OnWork run and waits for it to complete. Can only return if OnWork is | 93 // Lets OnWork run and waits for it to complete. Can only return if OnWork is |
93 // executed on a concurrent thread. | 94 // executed on a concurrent thread. |
94 void WaitForWork() { | 95 void WaitForWork() { |
95 RunUntilBreak("OnWork"); | 96 RunUntilBreak("OnWork"); |
96 work_allowed_.Signal(); | 97 work_allowed_.Signal(); |
97 work_called_.Wait(); | 98 work_called_.Wait(); |
98 } | 99 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 RunUntilBreak("OnWorkFinished"); | 157 RunUntilBreak("OnWorkFinished"); |
157 | 158 |
158 // No more tasks should remain. | 159 // No more tasks should remain. |
159 EXPECT_TRUE(message_loop_->IsIdleForTesting()); | 160 EXPECT_TRUE(message_loop_->IsIdleForTesting()); |
160 } | 161 } |
161 | 162 |
162 } // namespace | 163 } // namespace |
163 | 164 |
164 } // namespace net | 165 } // namespace net |
165 | 166 |
OLD | NEW |