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

Unified Diff: net/dns/async_host_resolver.h

Issue 8835011: Revert 113282 - 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/dns_util.cc ('k') | net/dns/async_host_resolver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/async_host_resolver.h
===================================================================
--- net/dns/async_host_resolver.h (revision 113383)
+++ net/dns/async_host_resolver.h (working copy)
@@ -8,8 +8,6 @@
#include <list>
#include <map>
-#include <string>
-#include <utility>
#include "base/threading/non_thread_safe.h"
#include "net/base/address_family.h"
@@ -17,18 +15,24 @@
#include "net/base/host_resolver.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_log.h"
-#include "net/dns/dns_client.h"
+#include "net/base/rand_callback.h"
+#include "net/dns/dns_transaction.h"
namespace net {
+class ClientSocketFactory;
+
class NET_EXPORT AsyncHostResolver
: public HostResolver,
+ public DnsTransaction::Delegate,
NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
- AsyncHostResolver(size_t max_dns_requests,
- size_t max_pending_requests,
+ AsyncHostResolver(const IPEndPoint& dns_server,
+ size_t max_transactions,
+ size_t max_pending_requests_,
+ const RandIntCallback& rand_int,
HostCache* cache,
- DnsClient* client,
+ ClientSocketFactory* factory,
NetLog* net_log);
virtual ~AsyncHostResolver();
@@ -46,9 +50,11 @@
virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE;
virtual HostCache* GetHostCache() OVERRIDE;
- void OnDnsRequestComplete(DnsClient::Request* request,
- int result,
- const DnsResponse* transaction);
+ // DnsTransaction::Delegate interface
+ virtual void OnTransactionComplete(
+ int result,
+ const DnsTransaction* transaction,
+ const IPAddressList& ip_addresses) OVERRIDE;
private:
FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, QueuedLookup);
@@ -62,9 +68,9 @@
class Request;
- typedef std::pair<std::string, uint16> Key;
+ typedef DnsTransaction::Key Key;
typedef std::list<Request*> RequestList;
- typedef std::list<const DnsClient::Request*> DnsRequestList;
+ typedef std::list<const DnsTransaction*> TransactionList;
typedef std::map<Key, RequestList> KeyRequestListMap;
// Create a new request for the incoming Resolve() call.
@@ -86,9 +92,9 @@
// attach |request| to the respective list.
bool AttachToRequestList(Request* request);
- // Will start a new DNS request for |request|, will insert a new key in
+ // Will start a new transaction for |request|, will insert a new key in
// |requestlist_map_| and append |request| to the respective list.
- int StartNewDnsRequestFor(Request* request);
+ int StartNewTransactionFor(Request* request);
// Will enqueue |request| in |pending_requests_|.
int Enqueue(Request* request);
@@ -108,11 +114,11 @@
// there are pending requests.
void ProcessPending();
- // Maximum number of concurrent DNS requests.
- size_t max_dns_requests_;
+ // Maximum number of concurrent transactions.
+ size_t max_transactions_;
- // List of current DNS requests.
- DnsRequestList dns_requests_;
+ // List of current transactions.
+ TransactionList transactions_;
// A map from Key to a list of requests waiting for the Key to resolve.
KeyRequestListMap requestlist_map_;
@@ -123,10 +129,18 @@
// Queues based on priority for putting pending requests.
RequestList pending_requests_[NUM_PRIORITIES];
+ // DNS server to which queries will be setn.
+ IPEndPoint dns_server_;
+
+ // Callback to be passed to DnsTransaction for generating DNS query ids.
+ RandIntCallback rand_int_cb_;
+
// Cache of host resolution results.
scoped_ptr<HostCache> cache_;
- DnsClient* client_;
+ // Also passed to DnsTransaction; it's a dependency injection to aid
+ // testing, outside of unit tests, its value is always NULL.
+ ClientSocketFactory* factory_;
NetLog* net_log_;
« no previous file with comments | « net/base/dns_util.cc ('k') | net/dns/async_host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698