OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dns_transaction.h" | 5 #include "net/dns/dns_transaction.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 cancel_in_callback_(false), | 229 cancel_in_callback_(false), |
230 quit_in_callback_(false), | 230 quit_in_callback_(false), |
231 completed_(false) { | 231 completed_(false) { |
232 } | 232 } |
233 | 233 |
234 // Mark that the transaction shall be destroyed immediately upon callback. | 234 // Mark that the transaction shall be destroyed immediately upon callback. |
235 void set_cancel_in_callback() { | 235 void set_cancel_in_callback() { |
236 cancel_in_callback_ = true; | 236 cancel_in_callback_ = true; |
237 } | 237 } |
238 | 238 |
239 // Mark to call MessageLoop::Quit() upon callback. | 239 // Mark to call MessageLoop::QuitWhenIdle() upon callback. |
240 void set_quit_in_callback() { | 240 void set_quit_in_callback() { |
241 quit_in_callback_ = true; | 241 quit_in_callback_ = true; |
242 } | 242 } |
243 | 243 |
244 void StartTransaction(DnsTransactionFactory* factory) { | 244 void StartTransaction(DnsTransactionFactory* factory) { |
245 EXPECT_EQ(NULL, transaction_.get()); | 245 EXPECT_EQ(NULL, transaction_.get()); |
246 transaction_ = factory->CreateTransaction( | 246 transaction_ = factory->CreateTransaction( |
247 hostname_, | 247 hostname_, |
248 qtype_, | 248 qtype_, |
249 base::Bind(&TransactionHelper::OnTransactionComplete, | 249 base::Bind(&TransactionHelper::OnTransactionComplete, |
(...skipping 17 matching lines...) Expand all Loading... |
267 | 267 |
268 completed_ = true; | 268 completed_ = true; |
269 | 269 |
270 if (cancel_in_callback_) { | 270 if (cancel_in_callback_) { |
271 Cancel(); | 271 Cancel(); |
272 return; | 272 return; |
273 } | 273 } |
274 | 274 |
275 // Tell MessageLoop to quit now, in case any ASSERT_* fails. | 275 // Tell MessageLoop to quit now, in case any ASSERT_* fails. |
276 if (quit_in_callback_) | 276 if (quit_in_callback_) |
277 base::MessageLoop::current()->Quit(); | 277 base::MessageLoop::current()->QuitWhenIdle(); |
278 | 278 |
279 if (expected_answer_count_ >= 0) { | 279 if (expected_answer_count_ >= 0) { |
280 ASSERT_EQ(OK, rv); | 280 ASSERT_EQ(OK, rv); |
281 ASSERT_TRUE(response != NULL); | 281 ASSERT_TRUE(response != NULL); |
282 EXPECT_EQ(static_cast<unsigned>(expected_answer_count_), | 282 EXPECT_EQ(static_cast<unsigned>(expected_answer_count_), |
283 response->answer_count()); | 283 response->answer_count()); |
284 EXPECT_EQ(qtype_, response->qtype()); | 284 EXPECT_EQ(qtype_, response->qtype()); |
285 | 285 |
286 DnsRecordParser parser = response->Parser(); | 286 DnsRecordParser parser = response->Parser(); |
287 DnsResourceRecord record; | 287 DnsResourceRecord record; |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 config_.timeout = TestTimeouts::tiny_timeout(); | 1004 config_.timeout = TestTimeouts::tiny_timeout(); |
1005 ConfigureFactory(); | 1005 ConfigureFactory(); |
1006 | 1006 |
1007 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); | 1007 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); |
1008 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); | 1008 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); |
1009 } | 1009 } |
1010 | 1010 |
1011 } // namespace | 1011 } // namespace |
1012 | 1012 |
1013 } // namespace net | 1013 } // namespace net |
OLD | NEW |