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

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

Issue 8533011: Remove unused HostResolver::Observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove id from AsyncHostResolver; add double-cancelation check; comments' 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/host_resolver_impl.h » ('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) 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_BASE_HOST_RESOLVER_H_ 5 #ifndef NET_BASE_HOST_RESOLVER_H_
6 #define NET_BASE_HOST_RESOLVER_H_ 6 #define NET_BASE_HOST_RESOLVER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "googleurl/src/gurl.h"
13 #include "net/base/address_family.h" 12 #include "net/base/address_family.h"
14 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
15 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
16 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
17 #include "net/base/net_util.h" 16 #include "net/base/net_util.h"
18 #include "net/base/request_priority.h" 17 #include "net/base/request_priority.h"
19 18
20 namespace net { 19 namespace net {
21 20
22 class AddressList; 21 class AddressList;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 63
65 bool allow_cached_response() const { return allow_cached_response_; } 64 bool allow_cached_response() const { return allow_cached_response_; }
66 void set_allow_cached_response(bool b) { allow_cached_response_ = b; } 65 void set_allow_cached_response(bool b) { allow_cached_response_ = b; }
67 66
68 bool is_speculative() const { return is_speculative_; } 67 bool is_speculative() const { return is_speculative_; }
69 void set_is_speculative(bool b) { is_speculative_ = b; } 68 void set_is_speculative(bool b) { is_speculative_ = b; }
70 69
71 RequestPriority priority() const { return priority_; } 70 RequestPriority priority() const { return priority_; }
72 void set_priority(RequestPriority priority) { priority_ = priority; } 71 void set_priority(RequestPriority priority) { priority_ = priority; }
73 72
74 const GURL& referrer() const { return referrer_; }
75 void set_referrer(const GURL& referrer) { referrer_ = referrer; }
76
77 private: 73 private:
78 // The hostname to resolve, and the port to use in resulting sockaddrs. 74 // The hostname to resolve, and the port to use in resulting sockaddrs.
79 HostPortPair host_port_pair_; 75 HostPortPair host_port_pair_;
80 76
81 // The address family to restrict results to. 77 // The address family to restrict results to.
82 AddressFamily address_family_; 78 AddressFamily address_family_;
83 79
84 // Flags to use when resolving this request. 80 // Flags to use when resolving this request.
85 HostResolverFlags host_resolver_flags_; 81 HostResolverFlags host_resolver_flags_;
86 82
87 // Whether it is ok to return a result from the host cache. 83 // Whether it is ok to return a result from the host cache.
88 bool allow_cached_response_; 84 bool allow_cached_response_;
89 85
90 // Whether this request was started by the DNS prefetcher. 86 // Whether this request was started by the DNS prefetcher.
91 bool is_speculative_; 87 bool is_speculative_;
92 88
93 // The priority for the request. 89 // The priority for the request.
94 RequestPriority priority_; 90 RequestPriority priority_;
95
96 // Optional data for consumption by observers. This is the URL of the
97 // page that lead us to the navigation, for DNS prefetcher's benefit.
98 GURL referrer_;
99 };
100
101 // Interface for observing the requests that flow through a HostResolver.
102 class Observer {
103 public:
104 virtual ~Observer() {}
105
106 // Called at the start of HostResolver::Resolve(). |id| is a unique number
107 // given to the request, so it can be matched up with a corresponding call
108 // to OnFinishResolutionWithStatus() or OnCancelResolution().
109 virtual void OnStartResolution(int id, const RequestInfo& info) = 0;
110
111 // Called on completion of request |id|. Note that if the request was
112 // cancelled, OnCancelResolution() will be called instead.
113 virtual void OnFinishResolutionWithStatus(int id, bool was_resolved,
114 const RequestInfo& info) = 0;
115
116 // Called when request |id| has been cancelled. A request is "cancelled"
117 // if either the HostResolver is destroyed while a resolution is in
118 // progress, or HostResolver::CancelRequest() is called.
119 virtual void OnCancelResolution(int id, const RequestInfo& info) = 0;
120 }; 91 };
121 92
122 // Opaque type used to cancel a request. 93 // Opaque type used to cancel a request.
123 typedef void* RequestHandle; 94 typedef void* RequestHandle;
124 95
125 // This value can be passed into CreateSystemHostResolver as the 96 // This value can be passed into CreateSystemHostResolver as the
126 // |max_concurrent_resolves| parameter. It will select a default level of 97 // |max_concurrent_resolves| parameter. It will select a default level of
127 // concurrency. 98 // concurrency.
128 static const size_t kDefaultParallelism = 0; 99 static const size_t kDefaultParallelism = 0;
129 100
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 134
164 // Resolves the given hostname (or IP address literal) out of cache 135 // Resolves the given hostname (or IP address literal) out of cache
165 // only. This is guaranteed to complete synchronously. This acts like 136 // only. This is guaranteed to complete synchronously. This acts like
166 // |Resolve()| if the hostname is IP literal or cached value exists. 137 // |Resolve()| if the hostname is IP literal or cached value exists.
167 // Otherwise, ERR_DNS_CACHE_MISS is returned. 138 // Otherwise, ERR_DNS_CACHE_MISS is returned.
168 virtual int ResolveFromCache(const RequestInfo& info, 139 virtual int ResolveFromCache(const RequestInfo& info,
169 AddressList* addresses, 140 AddressList* addresses,
170 const BoundNetLog& net_log) = 0; 141 const BoundNetLog& net_log) = 0;
171 142
172 // Cancels the specified request. |req| is the handle returned by Resolve(). 143 // Cancels the specified request. |req| is the handle returned by Resolve().
173 // After a request is cancelled, its completion callback will not be called. 144 // After a request is canceled, its completion callback will not be called.
145 // CancelRequest must NOT be called after the request's completion callback
146 // has already run or the request was canceled.
174 virtual void CancelRequest(RequestHandle req) = 0; 147 virtual void CancelRequest(RequestHandle req) = 0;
175 148
176 // Adds an observer to this resolver. The observer will be notified of the
177 // start and completion of all requests (excluding cancellation). |observer|
178 // must remain valid for the duration of this HostResolver's lifetime.
179 virtual void AddObserver(Observer* observer) = 0;
180
181 // Unregisters an observer previously added by AddObserver().
182 virtual void RemoveObserver(Observer* observer) = 0;
183
184 // Sets the default AddressFamily to use when requests have left it 149 // Sets the default AddressFamily to use when requests have left it
185 // unspecified. For example, this could be used to restrict resolution 150 // unspecified. For example, this could be used to restrict resolution
186 // results to AF_INET by passing in ADDRESS_FAMILY_IPV4, or to 151 // results to AF_INET by passing in ADDRESS_FAMILY_IPV4, or to
187 // AF_INET6 by passing in ADDRESS_FAMILY_IPV6. 152 // AF_INET6 by passing in ADDRESS_FAMILY_IPV6.
188 virtual void SetDefaultAddressFamily(AddressFamily address_family) {} 153 virtual void SetDefaultAddressFamily(AddressFamily address_family) {}
189 virtual AddressFamily GetDefaultAddressFamily() const; 154 virtual AddressFamily GetDefaultAddressFamily() const;
190 155
191 // Continuously observe whether IPv6 is supported, and set the allowable 156 // Continuously observe whether IPv6 is supported, and set the allowable
192 // address family to IPv4 iff IPv6 is not supported. 157 // address family to IPv4 iff IPv6 is not supported.
193 virtual void ProbeIPv6Support(); 158 virtual void ProbeIPv6Support();
(...skipping 24 matching lines...) Expand all
218 NetLog* net_log); 183 NetLog* net_log);
219 184
220 // Creates a HostResolver implementation that sends actual DNS queries to 185 // Creates a HostResolver implementation that sends actual DNS queries to
221 // the specified DNS server and parses response and returns results. 186 // the specified DNS server and parses response and returns results.
222 NET_EXPORT HostResolver* CreateAsyncHostResolver(size_t max_concurrent_resolves, 187 NET_EXPORT HostResolver* CreateAsyncHostResolver(size_t max_concurrent_resolves,
223 const IPAddressNumber& dns_ip, 188 const IPAddressNumber& dns_ip,
224 NetLog* net_log); 189 NetLog* net_log);
225 } // namespace net 190 } // namespace net
226 191
227 #endif // NET_BASE_HOST_RESOLVER_H_ 192 #endif // NET_BASE_HOST_RESOLVER_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698