Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / base / network_delegate.cc
blob76d94abd2df9488d804ac07b9fc83f7745bfe504
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
3 // found in the LICENSE file.
5 #include "net/base/network_delegate.h"
7 #include "base/logging.h"
8 #include "net/base/load_flags.h"
9 #include "net/base/net_errors.h"
10 #include "net/proxy/proxy_info.h"
11 #include "net/url_request/url_request.h"
13 namespace net {
15 int NetworkDelegate::NotifyBeforeURLRequest(
16 URLRequest* request, const CompletionCallback& callback,
17 GURL* new_url) {
18 DCHECK(CalledOnValidThread());
19 DCHECK(request);
20 DCHECK(!callback.is_null());
21 return OnBeforeURLRequest(request, callback, new_url);
24 void NetworkDelegate::NotifyResolveProxy(
25 const GURL& url,
26 int load_flags,
27 const ProxyService& proxy_service,
28 ProxyInfo* result) {
29 DCHECK(CalledOnValidThread());
30 DCHECK(result);
31 OnResolveProxy(url, load_flags, proxy_service, result);
34 void NetworkDelegate::NotifyProxyFallback(
35 const ProxyServer& bad_proxy,
36 int net_error) {
37 DCHECK(CalledOnValidThread());
38 OnProxyFallback(bad_proxy, net_error);
41 int NetworkDelegate::NotifyBeforeSendHeaders(
42 URLRequest* request, const CompletionCallback& callback,
43 HttpRequestHeaders* headers) {
44 DCHECK(CalledOnValidThread());
45 DCHECK(headers);
46 DCHECK(!callback.is_null());
47 return OnBeforeSendHeaders(request, callback, headers);
50 void NetworkDelegate::NotifyBeforeSendProxyHeaders(
51 URLRequest* request,
52 const ProxyInfo& proxy_info,
53 HttpRequestHeaders* headers) {
54 DCHECK(CalledOnValidThread());
55 DCHECK(headers);
56 OnBeforeSendProxyHeaders(request, proxy_info, headers);
59 void NetworkDelegate::NotifySendHeaders(URLRequest* request,
60 const HttpRequestHeaders& headers) {
61 DCHECK(CalledOnValidThread());
62 OnSendHeaders(request, headers);
65 int NetworkDelegate::NotifyHeadersReceived(
66 URLRequest* request,
67 const CompletionCallback& callback,
68 const HttpResponseHeaders* original_response_headers,
69 scoped_refptr<HttpResponseHeaders>* override_response_headers,
70 GURL* allowed_unsafe_redirect_url) {
71 DCHECK(CalledOnValidThread());
72 DCHECK(original_response_headers);
73 DCHECK(!callback.is_null());
74 return OnHeadersReceived(request,
75 callback,
76 original_response_headers,
77 override_response_headers,
78 allowed_unsafe_redirect_url);
81 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) {
82 DCHECK(CalledOnValidThread());
83 DCHECK(request);
84 OnResponseStarted(request);
87 void NetworkDelegate::NotifyRawBytesRead(const URLRequest& request,
88 int bytes_read) {
89 DCHECK(CalledOnValidThread());
90 OnRawBytesRead(request, bytes_read);
93 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request,
94 const GURL& new_location) {
95 DCHECK(CalledOnValidThread());
96 DCHECK(request);
97 OnBeforeRedirect(request, new_location);
100 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) {
101 DCHECK(CalledOnValidThread());
102 DCHECK(request);
103 OnCompleted(request, started);
106 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
107 DCHECK(CalledOnValidThread());
108 DCHECK(request);
109 OnURLRequestDestroyed(request);
112 void NetworkDelegate::NotifyPACScriptError(int line_number,
113 const base::string16& error) {
114 DCHECK(CalledOnValidThread());
115 OnPACScriptError(line_number, error);
118 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired(
119 URLRequest* request,
120 const AuthChallengeInfo& auth_info,
121 const AuthCallback& callback,
122 AuthCredentials* credentials) {
123 DCHECK(CalledOnValidThread());
124 return OnAuthRequired(request, auth_info, callback, credentials);
127 int NetworkDelegate::NotifyBeforeSocketStreamConnect(
128 SocketStream* socket,
129 const CompletionCallback& callback) {
130 DCHECK(CalledOnValidThread());
131 DCHECK(socket);
132 DCHECK(!callback.is_null());
133 return OnBeforeSocketStreamConnect(socket, callback);
136 bool NetworkDelegate::CanGetCookies(const URLRequest& request,
137 const CookieList& cookie_list) {
138 DCHECK(CalledOnValidThread());
139 DCHECK(!(request.load_flags() & net::LOAD_DO_NOT_SEND_COOKIES));
140 return OnCanGetCookies(request, cookie_list);
143 bool NetworkDelegate::CanSetCookie(const URLRequest& request,
144 const std::string& cookie_line,
145 CookieOptions* options) {
146 DCHECK(CalledOnValidThread());
147 DCHECK(!(request.load_flags() & net::LOAD_DO_NOT_SAVE_COOKIES));
148 return OnCanSetCookie(request, cookie_line, options);
151 bool NetworkDelegate::CanAccessFile(const URLRequest& request,
152 const base::FilePath& path) const {
153 DCHECK(CalledOnValidThread());
154 return OnCanAccessFile(request, path);
157 bool NetworkDelegate::CanThrottleRequest(const URLRequest& request) const {
158 DCHECK(CalledOnValidThread());
159 return OnCanThrottleRequest(request);
162 bool NetworkDelegate::CanEnablePrivacyMode(
163 const GURL& url,
164 const GURL& first_party_for_cookies) const {
165 DCHECK(CalledOnValidThread());
166 return OnCanEnablePrivacyMode(url, first_party_for_cookies);
169 int NetworkDelegate::OnBeforeURLRequest(URLRequest* request,
170 const CompletionCallback& callback,
171 GURL* new_url) {
172 return OK;
175 void NetworkDelegate::OnResolveProxy(
176 const GURL& url,
177 int load_flags,
178 const ProxyService& proxy_service,
179 ProxyInfo* result) {
182 void NetworkDelegate::OnProxyFallback(const ProxyServer& bad_proxy,
183 int net_error) {
186 int NetworkDelegate::OnBeforeSendHeaders(URLRequest* request,
187 const CompletionCallback& callback,
188 HttpRequestHeaders* headers) {
189 return OK;
192 void NetworkDelegate::OnBeforeSendProxyHeaders(
193 URLRequest* request,
194 const ProxyInfo& proxy_info,
195 HttpRequestHeaders* headers) {
198 void NetworkDelegate::OnSendHeaders(URLRequest* request,
199 const HttpRequestHeaders& headers) {
202 int NetworkDelegate::OnHeadersReceived(
203 URLRequest* request,
204 const CompletionCallback& callback,
205 const HttpResponseHeaders* original_response_headers,
206 scoped_refptr<HttpResponseHeaders>* override_response_headers,
207 GURL* allowed_unsafe_redirect_url) {
208 return OK;
211 void NetworkDelegate::OnBeforeRedirect(URLRequest* request,
212 const GURL& new_location) {
215 void NetworkDelegate::OnResponseStarted(URLRequest* request) {
218 void NetworkDelegate::OnRawBytesRead(const URLRequest& request,
219 int bytes_read) {
222 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) {
225 void NetworkDelegate::OnURLRequestDestroyed(URLRequest* request) {
228 void NetworkDelegate::OnPACScriptError(int line_number,
229 const base::string16& error) {
232 NetworkDelegate::AuthRequiredResponse NetworkDelegate::OnAuthRequired(
233 URLRequest* request,
234 const AuthChallengeInfo& auth_info,
235 const AuthCallback& callback,
236 AuthCredentials* credentials) {
237 return AUTH_REQUIRED_RESPONSE_NO_ACTION;
240 bool NetworkDelegate::OnCanGetCookies(const URLRequest& request,
241 const CookieList& cookie_list) {
242 return true;
245 bool NetworkDelegate::OnCanSetCookie(const URLRequest& request,
246 const std::string& cookie_line,
247 CookieOptions* options) {
248 return true;
251 bool NetworkDelegate::OnCanAccessFile(const URLRequest& request,
252 const base::FilePath& path) const {
253 return false;
256 bool NetworkDelegate::OnCanThrottleRequest(const URLRequest& request) const {
257 return false;
260 bool NetworkDelegate::OnCanEnablePrivacyMode(
261 const GURL& url,
262 const GURL& first_party_for_cookies) const {
263 return false;
266 int NetworkDelegate::OnBeforeSocketStreamConnect(
267 SocketStream* socket,
268 const CompletionCallback& callback) {
269 return OK;
272 } // namespace net