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

Side by Side Diff: net/dns/async_host_resolver.h

Issue 9190031: DnsClient refactoring + features (timeout, suffix search, server rotation). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comments. Fixed tests. Created 8 years, 11 months 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
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 #ifndef NET_DNS_ASYNC_HOST_RESOLVER_H_ 5 #ifndef NET_DNS_ASYNC_HOST_RESOLVER_H_
6 #define NET_DNS_ASYNC_HOST_RESOLVER_H_ 6 #define NET_DNS_ASYNC_HOST_RESOLVER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 10 matching lines...) Expand all
21 21
22 namespace net { 22 namespace net {
23 23
24 class NET_EXPORT AsyncHostResolver 24 class NET_EXPORT AsyncHostResolver
25 : public HostResolver, 25 : public HostResolver,
26 NON_EXPORTED_BASE(public base::NonThreadSafe) { 26 NON_EXPORTED_BASE(public base::NonThreadSafe) {
27 public: 27 public:
28 AsyncHostResolver(size_t max_dns_requests, 28 AsyncHostResolver(size_t max_dns_requests,
29 size_t max_pending_requests, 29 size_t max_pending_requests,
30 HostCache* cache, 30 HostCache* cache,
31 DnsClient* client, 31 scoped_ptr<DnsClient> client,
32 NetLog* net_log); 32 NetLog* net_log);
33 virtual ~AsyncHostResolver(); 33 virtual ~AsyncHostResolver();
34 34
35 // HostResolver interface 35 // HostResolver interface
36 virtual int Resolve(const RequestInfo& info, 36 virtual int Resolve(const RequestInfo& info,
37 AddressList* addresses, 37 AddressList* addresses,
38 const CompletionCallback& callback, 38 const CompletionCallback& callback,
39 RequestHandle* out_req, 39 RequestHandle* out_req,
40 const BoundNetLog& source_net_log) OVERRIDE; 40 const BoundNetLog& source_net_log) OVERRIDE;
41 virtual int ResolveFromCache(const RequestInfo& info, 41 virtual int ResolveFromCache(const RequestInfo& info,
42 AddressList* addresses, 42 AddressList* addresses,
43 const BoundNetLog& source_net_log) OVERRIDE; 43 const BoundNetLog& source_net_log) OVERRIDE;
44 virtual void CancelRequest(RequestHandle req_handle) OVERRIDE; 44 virtual void CancelRequest(RequestHandle req_handle) OVERRIDE;
45 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; 45 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE;
46 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; 46 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE;
47 virtual HostCache* GetHostCache() OVERRIDE; 47 virtual HostCache* GetHostCache() OVERRIDE;
48 48
49 void OnDnsRequestComplete(DnsClient::Request* request, 49 void OnDnsTransactionComplete(DnsTransaction* transaction,
50 int result, 50 int result,
51 const DnsResponse* transaction); 51 const DnsResponse* response);
52 52
53 private: 53 private:
54 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, QueuedLookup); 54 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, QueuedLookup);
55 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, CancelPendingLookup); 55 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, CancelPendingLookup);
56 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, 56 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest,
57 ResolverDestructionCancelsLookups); 57 ResolverDestructionCancelsLookups);
58 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, 58 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest,
59 OverflowQueueWithLowPriorityLookup); 59 OverflowQueueWithLowPriorityLookup);
60 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest, 60 FRIEND_TEST_ALL_PREFIXES(AsyncHostResolverTest,
61 OverflowQueueWithHighPriorityLookup); 61 OverflowQueueWithHighPriorityLookup);
62 62
63 class Request; 63 class Request;
64 64
65 typedef std::pair<std::string, uint16> Key; 65 typedef std::pair<std::string, uint16> Key;
66 typedef std::list<Request*> RequestList; 66 typedef std::list<Request*> RequestList;
67 typedef std::list<const DnsClient::Request*> DnsRequestList; 67 typedef std::list<const DnsTransaction*> DnsRequestList;
cbentzel 2012/01/13 13:39:54 DnsTransactionList?
mmenke 2012/01/13 16:44:37 nit: DnsTransactionList
68 typedef std::map<Key, RequestList> KeyRequestListMap; 68 typedef std::map<Key, RequestList> KeyRequestListMap;
69 69
70 // Create a new request for the incoming Resolve() call. 70 // Create a new request for the incoming Resolve() call.
71 Request* CreateNewRequest(const RequestInfo& info, 71 Request* CreateNewRequest(const RequestInfo& info,
72 const CompletionCallback& callback, 72 const CompletionCallback& callback,
73 AddressList* addresses, 73 AddressList* addresses,
74 const BoundNetLog& source_net_log); 74 const BoundNetLog& source_net_log);
75 75
76 // Called when a request has just been started. 76 // Called when a request has just been started.
77 void OnStart(Request* request); 77 void OnStart(Request* request);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 // Maximum number of pending requests. 120 // Maximum number of pending requests.
121 size_t max_pending_requests_; 121 size_t max_pending_requests_;
122 122
123 // Queues based on priority for putting pending requests. 123 // Queues based on priority for putting pending requests.
124 RequestList pending_requests_[NUM_PRIORITIES]; 124 RequestList pending_requests_[NUM_PRIORITIES];
125 125
126 // Cache of host resolution results. 126 // Cache of host resolution results.
127 scoped_ptr<HostCache> cache_; 127 scoped_ptr<HostCache> cache_;
128 128
129 DnsClient* client_; 129 scoped_ptr<DnsClient> client_;
130 130
131 NetLog* net_log_; 131 NetLog* net_log_;
132 132
133 DISALLOW_COPY_AND_ASSIGN(AsyncHostResolver); 133 DISALLOW_COPY_AND_ASSIGN(AsyncHostResolver);
134 }; 134 };
135 135
136 } // namespace net 136 } // namespace net
137 137
138 #endif // NET_DNS_ASYNC_HOST_RESOLVER_H_ 138 #endif // NET_DNS_ASYNC_HOST_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698