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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 work_called_.Signal(); | 56 work_called_.Signal(); |
57 } | 57 } |
58 | 58 |
59 void OnWorkFinished() { | 59 void OnWorkFinished() { |
60 EXPECT_TRUE(message_loop_ == base::MessageLoop::current()); | 60 EXPECT_TRUE(message_loop_ == base::MessageLoop::current()); |
61 EXPECT_EQ(output_value_, input_value_); | 61 EXPECT_EQ(output_value_, input_value_); |
62 BreakNow("OnWorkFinished"); | 62 BreakNow("OnWorkFinished"); |
63 } | 63 } |
64 | 64 |
65 protected: | 65 protected: |
66 void BreakCallback(std::string breakpoint) { | 66 void BreakCallback(const std::string& breakpoint) { |
67 breakpoint_ = breakpoint; | 67 breakpoint_ = breakpoint; |
68 base::MessageLoop::current()->QuitNow(); | 68 base::MessageLoop::current()->QuitNow(); |
69 } | 69 } |
70 | 70 |
71 void BreakNow(std::string b) { | 71 void BreakNow(const std::string& b) { |
72 message_loop_->task_runner()->PostTask( | 72 message_loop_->task_runner()->PostTask( |
73 FROM_HERE, base::Bind(&SerialWorkerTest::BreakCallback, | 73 FROM_HERE, base::Bind(&SerialWorkerTest::BreakCallback, |
74 base::Unretained(this), b)); | 74 base::Unretained(this), b)); |
75 } | 75 } |
76 | 76 |
77 void RunUntilBreak(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_(false, false), |
86 work_called_(false, false), | 86 work_called_(false, false), |
87 work_running_(false) { | 87 work_running_(false) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 RunUntilBreak("OnWorkFinished"); | 156 RunUntilBreak("OnWorkFinished"); |
157 | 157 |
158 // No more tasks should remain. | 158 // No more tasks should remain. |
159 EXPECT_TRUE(message_loop_->IsIdleForTesting()); | 159 EXPECT_TRUE(message_loop_->IsIdleForTesting()); |
160 } | 160 } |
161 | 161 |
162 } // namespace | 162 } // namespace |
163 | 163 |
164 } // namespace net | 164 } // namespace net |
165 | 165 |
OLD | NEW |