Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: net/dns/dns_session.cc

Issue 8762001: Isolates generic DnsClient from AsyncHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/dns/dns_session.h"
6
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/time.h"
10 #include "net/base/ip_endpoint.h"
11 #include "net/dns/dns_config_service.h"
12 #include "net/socket/client_socket_factory.h"
13
14 namespace net {
15
16 DnsSession::DnsSession(const DnsConfig& config,
17 ClientSocketFactory* factory,
18 const RandIntCallback& rand_int_callback,
19 NetLog* net_log)
20 : config_(config),
mmenke 2011/12/02 00:53:55 nit: 4 spaces.
szym 2011/12/05 23:06:28 Done.
21 socket_factory_(factory),
22 rand_callback_(base::Bind(rand_int_callback, 0, kuint16max)),
23 net_log_(net_log),
24 server_index_(0) {
25 }
26
27 int DnsSession::NextId() const {
28 return rand_callback_.Run();
29 }
30
31 const IPEndPoint& DnsSession::NextServer() {
32 // TODO(szym): Rotate servers on failures.
33 const IPEndPoint& ipe = config_.nameservers[server_index_];
34 if (config_.rotate)
35 server_index_ = (server_index_ + 1) % config_.nameservers.size();
36 return ipe;
37 }
38
39 base::TimeDelta DnsSession::NextTimeout(int attempt) {
40 // TODO(szym): Adapt timeout to observed RTT.
41 return config_.timeout * (attempt + 1);
42 }
43
44 DnsSession::~DnsSession() {}
45
46 } // namespace net
47
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698