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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: net/dns/dns_session.cc
diff --git a/net/dns/dns_session.cc b/net/dns/dns_session.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a524500926f62951bd7fd326a6d83bfcc2e66ae8
--- /dev/null
+++ b/net/dns/dns_session.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/dns/dns_session.h"
+
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/time.h"
+#include "net/base/ip_endpoint.h"
+#include "net/dns/dns_config_service.h"
+#include "net/socket/client_socket_factory.h"
+
+namespace net {
+
+DnsSession::DnsSession(const DnsConfig& config,
+ ClientSocketFactory* factory,
+ const RandIntCallback& rand_int_callback,
+ NetLog* net_log)
+ : config_(config),
mmenke 2011/12/02 00:53:55 nit: 4 spaces.
szym 2011/12/05 23:06:28 Done.
+ socket_factory_(factory),
+ rand_callback_(base::Bind(rand_int_callback, 0, kuint16max)),
+ net_log_(net_log),
+ server_index_(0) {
+}
+
+int DnsSession::NextId() const {
+ return rand_callback_.Run();
+}
+
+const IPEndPoint& DnsSession::NextServer() {
+ // TODO(szym): Rotate servers on failures.
+ const IPEndPoint& ipe = config_.nameservers[server_index_];
+ if (config_.rotate)
+ server_index_ = (server_index_ + 1) % config_.nameservers.size();
+ return ipe;
+}
+
+base::TimeDelta DnsSession::NextTimeout(int attempt) {
+ // TODO(szym): Adapt timeout to observed RTT.
+ return config_.timeout * (attempt + 1);
+}
+
+DnsSession::~DnsSession() {}
+
+} // namespace net
+

Powered by Google App Engine
This is Rietveld 408576698