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/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/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "net/base/dns_util.h" | 10 #include "net/base/dns_util.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (rv < 0) | 299 if (rv < 0) |
300 return rv; | 300 return rv; |
301 | 301 |
302 DCHECK(rv); | 302 DCHECK(rv); |
303 // TODO(agayev): when supporting EDNS0 we may need to do multiple reads | 303 // TODO(agayev): when supporting EDNS0 we may need to do multiple reads |
304 // to read the whole response. | 304 // to read the whole response. |
305 return response_->Parse(rv, &ip_addresses_); | 305 return response_->Parse(rv, &ip_addresses_); |
306 } | 306 } |
307 | 307 |
308 void DnsTransaction::StartTimer(base::TimeDelta delay) { | 308 void DnsTransaction::StartTimer(base::TimeDelta delay) { |
309 timer_.Start(FROM_HERE, delay, this, &DnsTransaction::OnTimeout); | 309 timer_.Start(delay, this, &DnsTransaction::OnTimeout); |
310 } | 310 } |
311 | 311 |
312 void DnsTransaction::RevokeTimer() { | 312 void DnsTransaction::RevokeTimer() { |
313 timer_.Stop(); | 313 timer_.Stop(); |
314 } | 314 } |
315 | 315 |
316 void DnsTransaction::OnTimeout() { | 316 void DnsTransaction::OnTimeout() { |
317 DCHECK(next_state_ == STATE_SEND_QUERY_COMPLETE || | 317 DCHECK(next_state_ == STATE_SEND_QUERY_COMPLETE || |
318 next_state_ == STATE_READ_RESPONSE_COMPLETE); | 318 next_state_ == STATE_READ_RESPONSE_COMPLETE); |
319 if (attempts_ == timeouts_ms_.size()) { | 319 if (attempts_ == timeouts_ms_.size()) { |
320 DoCallback(ERR_DNS_TIMED_OUT); | 320 DoCallback(ERR_DNS_TIMED_OUT); |
321 return; | 321 return; |
322 } | 322 } |
323 next_state_ = STATE_CONNECT; | 323 next_state_ = STATE_CONNECT; |
324 query_.reset(query_->CloneWithNewId()); | 324 query_.reset(query_->CloneWithNewId()); |
325 int rv = DoLoop(OK); | 325 int rv = DoLoop(OK); |
326 if (rv != ERR_IO_PENDING) | 326 if (rv != ERR_IO_PENDING) |
327 DoCallback(rv); | 327 DoCallback(rv); |
328 } | 328 } |
329 | 329 |
330 void DnsTransaction::set_timeouts_ms( | 330 void DnsTransaction::set_timeouts_ms( |
331 const std::vector<base::TimeDelta>& timeouts_ms) { | 331 const std::vector<base::TimeDelta>& timeouts_ms) { |
332 DCHECK_EQ(0u, attempts_); | 332 DCHECK_EQ(0u, attempts_); |
333 timeouts_ms_ = timeouts_ms; | 333 timeouts_ms_ = timeouts_ms; |
334 } | 334 } |
335 | 335 |
336 } // namespace net | 336 } // namespace net |
OLD | NEW |