OLD | NEW |
---|---|
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_BASE_NETWORK_DELEGATE_H_ | 5 #ifndef NET_BASE_NETWORK_DELEGATE_H_ |
6 #define NET_BASE_NETWORK_DELEGATE_H_ | 6 #define NET_BASE_NETWORK_DELEGATE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 void NotifyStartTransaction(URLRequest* request, | 73 void NotifyStartTransaction(URLRequest* request, |
74 const HttpRequestHeaders& headers); | 74 const HttpRequestHeaders& headers); |
75 int NotifyHeadersReceived( | 75 int NotifyHeadersReceived( |
76 URLRequest* request, | 76 URLRequest* request, |
77 const CompletionCallback& callback, | 77 const CompletionCallback& callback, |
78 const HttpResponseHeaders* original_response_headers, | 78 const HttpResponseHeaders* original_response_headers, |
79 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 79 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
80 GURL* allowed_unsafe_redirect_url); | 80 GURL* allowed_unsafe_redirect_url); |
81 void NotifyBeforeRedirect(URLRequest* request, | 81 void NotifyBeforeRedirect(URLRequest* request, |
82 const GURL& new_location); | 82 const GURL& new_location); |
83 void NotifyResponseStarted(URLRequest* request, int net_error); | |
84 // Deprecated. | |
83 void NotifyResponseStarted(URLRequest* request); | 85 void NotifyResponseStarted(URLRequest* request); |
84 void NotifyNetworkBytesReceived(URLRequest* request, int64_t bytes_received); | 86 void NotifyNetworkBytesReceived(URLRequest* request, int64_t bytes_received); |
85 void NotifyNetworkBytesSent(URLRequest* request, int64_t bytes_sent); | 87 void NotifyNetworkBytesSent(URLRequest* request, int64_t bytes_sent); |
88 void NotifyCompleted(URLRequest* request, bool started, int net_error); | |
89 // Deprecated. | |
86 void NotifyCompleted(URLRequest* request, bool started); | 90 void NotifyCompleted(URLRequest* request, bool started); |
87 void NotifyURLRequestDestroyed(URLRequest* request); | 91 void NotifyURLRequestDestroyed(URLRequest* request); |
88 void NotifyPACScriptError(int line_number, const base::string16& error); | 92 void NotifyPACScriptError(int line_number, const base::string16& error); |
89 AuthRequiredResponse NotifyAuthRequired(URLRequest* request, | 93 AuthRequiredResponse NotifyAuthRequired(URLRequest* request, |
90 const AuthChallengeInfo& auth_info, | 94 const AuthChallengeInfo& auth_info, |
91 const AuthCallback& callback, | 95 const AuthCallback& callback, |
92 AuthCredentials* credentials); | 96 AuthCredentials* credentials); |
93 bool CanGetCookies(const URLRequest& request, | 97 bool CanGetCookies(const URLRequest& request, |
94 const CookieList& cookie_list); | 98 const CookieList& cookie_list); |
95 bool CanSetCookie(const URLRequest& request, | 99 bool CanSetCookie(const URLRequest& request, |
96 const std::string& cookie_line, | 100 const std::string& cookie_line, |
97 CookieOptions* options); | 101 CookieOptions* options); |
98 bool CanAccessFile(const URLRequest& request, | 102 bool CanAccessFile(const URLRequest& request, |
99 const base::FilePath& path) const; | 103 const base::FilePath& path) const; |
100 bool CanEnablePrivacyMode(const GURL& url, | 104 bool CanEnablePrivacyMode(const GURL& url, |
101 const GURL& first_party_for_cookies) const; | 105 const GURL& first_party_for_cookies) const; |
102 | 106 |
103 bool AreExperimentalCookieFeaturesEnabled() const; | 107 bool AreExperimentalCookieFeaturesEnabled() const; |
104 | 108 |
105 // TODO(jww): Remove this once we ship strict secure cookies: | 109 // TODO(jww): Remove this once we ship strict secure cookies: |
106 // https://crbug.com/546820 | 110 // https://crbug.com/546820 |
107 bool AreStrictSecureCookiesEnabled() const; | 111 bool AreStrictSecureCookiesEnabled() const; |
108 | 112 |
109 bool CancelURLRequestWithPolicyViolatingReferrerHeader( | 113 bool CancelURLRequestWithPolicyViolatingReferrerHeader( |
110 const URLRequest& request, | 114 const URLRequest& request, |
111 const GURL& target_url, | 115 const GURL& target_url, |
112 const GURL& referrer_url) const; | 116 const GURL& referrer_url) const; |
113 | 117 |
118 protected: | |
119 // Let NetworkDelegateImpl to set |not_implemented_| value. | |
120 // See the comment bellow that explains what this value means. | |
121 void set_implemented(bool value) { implemented_ = value; } | |
122 | |
114 private: | 123 private: |
115 // This is the interface for subclasses of NetworkDelegate to implement. These | 124 // This is the interface for subclasses of NetworkDelegate to implement. These |
116 // member functions will be called by the respective public notification | 125 // member functions will be called by the respective public notification |
117 // member function, which will perform basic sanity checking. | 126 // member function, which will perform basic sanity checking. |
118 | 127 |
119 // Called before a request is sent. Allows the delegate to rewrite the URL | 128 // Called before a request is sent. Allows the delegate to rewrite the URL |
120 // being fetched by modifying |new_url|. If set, the URL must be valid. The | 129 // being fetched by modifying |new_url|. If set, the URL must be valid. The |
121 // reference fragment from the original URL is not automatically appended to | 130 // reference fragment from the original URL is not automatically appended to |
122 // |new_url|; callers are responsible for copying the reference fragment if | 131 // |new_url|; callers are responsible for copying the reference fragment if |
123 // desired. | 132 // desired. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 187 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
179 GURL* allowed_unsafe_redirect_url) = 0; | 188 GURL* allowed_unsafe_redirect_url) = 0; |
180 | 189 |
181 // Called right after a redirect response code was received. | 190 // Called right after a redirect response code was received. |
182 // |new_location| is only valid until OnURLRequestDestroyed is called for this | 191 // |new_location| is only valid until OnURLRequestDestroyed is called for this |
183 // request. | 192 // request. |
184 virtual void OnBeforeRedirect(URLRequest* request, | 193 virtual void OnBeforeRedirect(URLRequest* request, |
185 const GURL& new_location) = 0; | 194 const GURL& new_location) = 0; |
186 | 195 |
187 // This corresponds to URLRequestDelegate::OnResponseStarted. | 196 // This corresponds to URLRequestDelegate::OnResponseStarted. |
188 virtual void OnResponseStarted(URLRequest* request) = 0; | 197 virtual void OnResponseStarted(URLRequest* request, int net_error); |
198 // Deprecated. | |
199 virtual void OnResponseStarted(URLRequest* request); | |
189 | 200 |
190 // Called when bytes are received from the network, such as after receiving | 201 // Called when bytes are received from the network, such as after receiving |
191 // headers or reading raw response bytes. This includes localhost requests. | 202 // headers or reading raw response bytes. This includes localhost requests. |
192 // |bytes_received| is the number of bytes measured at the application layer | 203 // |bytes_received| is the number of bytes measured at the application layer |
193 // that have been received over the network for this request since the last | 204 // that have been received over the network for this request since the last |
194 // time OnNetworkBytesReceived was called. |bytes_received| will always be | 205 // time OnNetworkBytesReceived was called. |bytes_received| will always be |
195 // greater than 0. | 206 // greater than 0. |
196 // Currently, this is only implemented for HTTP transactions, and | 207 // Currently, this is only implemented for HTTP transactions, and |
197 // |bytes_received| does not include TLS overhead or TCP retransmits. | 208 // |bytes_received| does not include TLS overhead or TCP retransmits. |
198 virtual void OnNetworkBytesReceived(URLRequest* request, | 209 virtual void OnNetworkBytesReceived(URLRequest* request, |
199 int64_t bytes_received) = 0; | 210 int64_t bytes_received) = 0; |
200 | 211 |
201 // Called when bytes are sent over the network, such as when sending request | 212 // Called when bytes are sent over the network, such as when sending request |
202 // headers or uploading request body bytes. This includes localhost requests. | 213 // headers or uploading request body bytes. This includes localhost requests. |
203 // |bytes_sent| is the number of bytes measured at the application layer that | 214 // |bytes_sent| is the number of bytes measured at the application layer that |
204 // have been sent over the network for this request since the last time | 215 // have been sent over the network for this request since the last time |
205 // OnNetworkBytesSent was called. |bytes_sent| will always be greater than 0. | 216 // OnNetworkBytesSent was called. |bytes_sent| will always be greater than 0. |
206 // Currently, this is only implemented for HTTP transactions, and |bytes_sent| | 217 // Currently, this is only implemented for HTTP transactions, and |bytes_sent| |
207 // does not include TLS overhead or TCP retransmits. | 218 // does not include TLS overhead or TCP retransmits. |
208 virtual void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) = 0; | 219 virtual void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) = 0; |
209 | 220 |
210 // Indicates that the URL request has been completed or failed. | 221 // Indicates that the URL request has been completed or failed. |
211 // |started| indicates whether the request has been started. If false, | 222 // |started| indicates whether the request has been started. If false, |
212 // some information like the socket address is not available. | 223 // some information like the socket address is not available. |
213 virtual void OnCompleted(URLRequest* request, bool started) = 0; | 224 virtual void OnCompleted(URLRequest* request, bool started, int net_error); |
225 // Deprecated. | |
226 virtual void OnCompleted(URLRequest* request, bool started); | |
214 | 227 |
215 // Called when an URLRequest is being destroyed. Note that the request is | 228 // Called when an URLRequest is being destroyed. Note that the request is |
216 // being deleted, so it's not safe to call any methods that may result in | 229 // being deleted, so it's not safe to call any methods that may result in |
217 // a virtual method call. | 230 // a virtual method call. |
218 virtual void OnURLRequestDestroyed(URLRequest* request) = 0; | 231 virtual void OnURLRequestDestroyed(URLRequest* request) = 0; |
219 | 232 |
220 // Corresponds to ProxyResolverJSBindings::OnError. | 233 // Corresponds to ProxyResolverJSBindings::OnError. |
221 virtual void OnPACScriptError(int line_number, | 234 virtual void OnPACScriptError(int line_number, |
222 const base::string16& error) = 0; | 235 const base::string16& error) = 0; |
223 | 236 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 | 296 |
284 // Called when the |referrer_url| for requesting |target_url| during handling | 297 // Called when the |referrer_url| for requesting |target_url| during handling |
285 // of the |request| is does not comply with the referrer policy (e.g. a | 298 // of the |request| is does not comply with the referrer policy (e.g. a |
286 // secure referrer for an insecure initial target). | 299 // secure referrer for an insecure initial target). |
287 // Returns true if the request should be cancelled. Otherwise, the referrer | 300 // Returns true if the request should be cancelled. Otherwise, the referrer |
288 // header is stripped from the request. | 301 // header is stripped from the request. |
289 virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 302 virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
290 const URLRequest& request, | 303 const URLRequest& request, |
291 const GURL& target_url, | 304 const GURL& target_url, |
292 const GURL& referrer_url) const = 0; | 305 const GURL& referrer_url) const = 0; |
306 | |
307 // Used to distinguish whether modified a method is overridden by clients. | |
308 bool implemented_; | |
mmenke
2016/08/30 22:09:11
No longer used
maksims (do not use this acc)
2016/08/31 11:16:59
Hmm, interesting. I've seen build-bots has been fa
mmenke
2016/08/31 21:35:47
The checks don't detect class members that aren't
| |
293 }; | 309 }; |
294 | 310 |
295 } // namespace net | 311 } // namespace net |
296 | 312 |
297 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 313 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
OLD | NEW |