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

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

Issue 1903263002: DNS: Expose stale results through HostResolverImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dns_stale1
Patch Set: rebase Created 4 years, 7 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
« no previous file with comments | « no previous file | net/dns/host_resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_HOST_RESOLVER_H_ 5 #ifndef NET_DNS_HOST_RESOLVER_H_
6 #define NET_DNS_HOST_RESOLVER_H_ 6 #define NET_DNS_HOST_RESOLVER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "net/base/address_family.h" 15 #include "net/base/address_family.h"
16 #include "net/base/completion_callback.h" 16 #include "net/base/completion_callback.h"
17 #include "net/base/host_port_pair.h" 17 #include "net/base/host_port_pair.h"
18 #include "net/base/net_export.h" 18 #include "net/base/net_export.h"
19 #include "net/base/prioritized_dispatcher.h" 19 #include "net/base/prioritized_dispatcher.h"
20 #include "net/base/request_priority.h" 20 #include "net/base/request_priority.h"
21 #include "net/dns/host_cache.h"
21 22
22 namespace base { 23 namespace base {
23 class Value; 24 class Value;
24 } 25 }
25 26
26 namespace net { 27 namespace net {
27 28
28 class AddressList; 29 class AddressList;
29 class BoundNetLog; 30 class BoundNetLog;
30 class HostCache;
31 class HostResolverProc; 31 class HostResolverProc;
32 class NetLog; 32 class NetLog;
33 33
34 // This class represents the task of resolving hostnames (or IP address 34 // This class represents the task of resolving hostnames (or IP address
35 // literal) to an AddressList object. 35 // literal) to an AddressList object.
36 // 36 //
37 // HostResolver can handle multiple requests at a time, so when cancelling a 37 // HostResolver can handle multiple requests at a time, so when cancelling a
38 // request the RequestHandle that was returned by Resolve() needs to be 38 // request the RequestHandle that was returned by Resolve() needs to be
39 // given. A simpler alternative for consumers that only have 1 outstanding 39 // given. A simpler alternative for consumers that only have 1 outstanding
40 // request at a time is to create a SingleRequestHostResolver wrapper around 40 // request at a time is to create a SingleRequestHostResolver wrapper around
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const BoundNetLog& net_log) = 0; 156 const BoundNetLog& net_log) = 0;
157 157
158 // Resolves the given hostname (or IP address literal) out of cache or HOSTS 158 // Resolves the given hostname (or IP address literal) out of cache or HOSTS
159 // file (if enabled) only. This is guaranteed to complete synchronously. 159 // file (if enabled) only. This is guaranteed to complete synchronously.
160 // This acts like |Resolve()| if the hostname is IP literal, or cached value 160 // This acts like |Resolve()| if the hostname is IP literal, or cached value
161 // or HOSTS entry exists. Otherwise, ERR_DNS_CACHE_MISS is returned. 161 // or HOSTS entry exists. Otherwise, ERR_DNS_CACHE_MISS is returned.
162 virtual int ResolveFromCache(const RequestInfo& info, 162 virtual int ResolveFromCache(const RequestInfo& info,
163 AddressList* addresses, 163 AddressList* addresses,
164 const BoundNetLog& net_log) = 0; 164 const BoundNetLog& net_log) = 0;
165 165
166 // Like |ResolveFromCache()|, but can return a stale response. If it does,
167 // fills in |stale_info| with details on why the response is not valid.
168 // (Defaults to calling |ResolveFromCache()| if not overridden.)
Randy Smith (Not in Mondays) 2016/04/28 16:29:55 This implies that |stale_info| is not filled in if
Julia Tuttle 2016/04/29 17:34:47 Oh, it's supposed to (and does) always fill in sta
169 virtual int ResolveStaleFromCache(const RequestInfo& info,
170 AddressList* addresses,
171 HostCache::StaleEntryInfo* stale_info,
172 const BoundNetLog& net_log);
173
174 // Uses |ResolveStaleFromCache| and |Resolve| to get fresh data (either from
175 // the cache or from the network) but also return stale data if any is
176 // available.
177 //
178 // If fresh data is available in cache, populates |addresses| and returns
179 // synchronously. Sets |*stale_error| to ERR_UNEXPECTED, since it should not
180 // be used.
181 //
182 // If stale data is available in cache, starts a network request like
183 // |Resolve()|, but also returns the stale data through |stale_error|,
184 // |stale_addresses|, and |stale_info|.
185 //
186 // If no data is available in cache, starts a network request like
187 // |Resolve()| and sets |*stale_error| to ERR_DNS_CACHE_MISS.
Randy Smith (Not in Mondays) 2016/04/28 16:29:55 Confirming: All cases that start a network request
Julia Tuttle 2016/04/29 17:34:47 Yup. Should be clearer in the new version of the c
188 int ResolveStale(const RequestInfo& info,
189 RequestPriority priority,
190 AddressList* addresses,
191 const CompletionCallback& callback,
192 RequestHandle* out_req,
193 int* stale_error,
194 AddressList* stale_addresses,
195 HostCache::StaleEntryInfo* stale_info,
196 const BoundNetLog& net_log);
197
166 // Cancels the specified request. |req| is the handle returned by Resolve(). 198 // Cancels the specified request. |req| is the handle returned by Resolve().
167 // After a request is canceled, its completion callback will not be called. 199 // After a request is canceled, its completion callback will not be called.
168 // CancelRequest must NOT be called after the request's completion callback 200 // CancelRequest must NOT be called after the request's completion callback
169 // has already run or the request was canceled. 201 // has already run or the request was canceled.
170 virtual void CancelRequest(RequestHandle req) = 0; 202 virtual void CancelRequest(RequestHandle req) = 0;
171 203
172 // Enable or disable the built-in asynchronous DnsClient. 204 // Enable or disable the built-in asynchronous DnsClient.
173 virtual void SetDnsClientEnabled(bool enabled); 205 virtual void SetDnsClientEnabled(bool enabled);
174 206
175 // Returns the HostResolverCache |this| uses, or NULL if there isn't one. 207 // Returns the HostResolverCache |this| uses, or NULL if there isn't one.
(...skipping 17 matching lines...) Expand all
193 protected: 225 protected:
194 HostResolver(); 226 HostResolver();
195 227
196 private: 228 private:
197 DISALLOW_COPY_AND_ASSIGN(HostResolver); 229 DISALLOW_COPY_AND_ASSIGN(HostResolver);
198 }; 230 };
199 231
200 } // namespace net 232 } // namespace net
201 233
202 #endif // NET_DNS_HOST_RESOLVER_H_ 234 #endif // NET_DNS_HOST_RESOLVER_H_
OLDNEW
« no previous file with comments | « no previous file | net/dns/host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698