1 // Copyright 2014 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/layered_network_delegate.h"
9 LayeredNetworkDelegate::LayeredNetworkDelegate(
10 scoped_ptr
<NetworkDelegate
> nested_network_delegate
)
11 : nested_network_delegate_(nested_network_delegate
.Pass()) {
14 LayeredNetworkDelegate::~LayeredNetworkDelegate() {
17 int LayeredNetworkDelegate::OnBeforeURLRequest(
19 const CompletionCallback
& callback
,
21 OnBeforeURLRequestInternal(request
, callback
, new_url
);
22 return nested_network_delegate_
->NotifyBeforeURLRequest(request
, callback
,
26 void LayeredNetworkDelegate::OnBeforeURLRequestInternal(
28 const CompletionCallback
& callback
,
32 void LayeredNetworkDelegate::OnResolveProxy(const GURL
& url
,
34 const ProxyService
& proxy_service
,
36 OnResolveProxyInternal(url
, load_flags
, proxy_service
, result
);
37 nested_network_delegate_
->NotifyResolveProxy(url
, load_flags
, proxy_service
,
41 void LayeredNetworkDelegate::OnResolveProxyInternal(
44 const ProxyService
& proxy_service
,
48 void LayeredNetworkDelegate::OnProxyFallback(const ProxyServer
& bad_proxy
,
50 OnProxyFallbackInternal(bad_proxy
, net_error
);
51 nested_network_delegate_
->NotifyProxyFallback(bad_proxy
, net_error
);
54 void LayeredNetworkDelegate::OnProxyFallbackInternal(
55 const ProxyServer
& bad_proxy
,
59 int LayeredNetworkDelegate::OnBeforeSendHeaders(
61 const CompletionCallback
& callback
,
62 HttpRequestHeaders
* headers
) {
63 OnBeforeSendHeadersInternal(request
, callback
, headers
);
64 return nested_network_delegate_
->NotifyBeforeSendHeaders(request
, callback
,
68 void LayeredNetworkDelegate::OnBeforeSendHeadersInternal(
70 const CompletionCallback
& callback
,
71 HttpRequestHeaders
* headers
) {
74 void LayeredNetworkDelegate::OnBeforeSendProxyHeaders(
76 const ProxyInfo
& proxy_info
,
77 HttpRequestHeaders
* headers
) {
78 OnBeforeSendProxyHeadersInternal(request
, proxy_info
, headers
);
79 nested_network_delegate_
->NotifyBeforeSendProxyHeaders(request
, proxy_info
,
83 void LayeredNetworkDelegate::OnBeforeSendProxyHeadersInternal(
85 const ProxyInfo
& proxy_info
,
86 HttpRequestHeaders
* headers
) {
89 void LayeredNetworkDelegate::OnSendHeaders(URLRequest
* request
,
90 const HttpRequestHeaders
& headers
) {
91 OnSendHeadersInternal(request
, headers
);
92 nested_network_delegate_
->NotifySendHeaders(request
, headers
);
95 void LayeredNetworkDelegate::OnSendHeadersInternal(
97 const HttpRequestHeaders
& headers
) {
100 int LayeredNetworkDelegate::OnHeadersReceived(
102 const CompletionCallback
& callback
,
103 const HttpResponseHeaders
* original_response_headers
,
104 scoped_refptr
<HttpResponseHeaders
>* override_response_headers
,
105 GURL
* allowed_unsafe_redirect_url
) {
106 OnHeadersReceivedInternal(request
, callback
, original_response_headers
,
107 override_response_headers
,
108 allowed_unsafe_redirect_url
);
109 return nested_network_delegate_
->NotifyHeadersReceived(
110 request
, callback
, original_response_headers
, override_response_headers
,
111 allowed_unsafe_redirect_url
);
114 void LayeredNetworkDelegate::OnHeadersReceivedInternal(
116 const CompletionCallback
& callback
,
117 const HttpResponseHeaders
* original_response_headers
,
118 scoped_refptr
<HttpResponseHeaders
>* override_response_headers
,
119 GURL
* allowed_unsafe_redirect_url
) {
122 void LayeredNetworkDelegate::OnBeforeRedirect(URLRequest
* request
,
123 const GURL
& new_location
) {
124 OnBeforeRedirectInternal(request
, new_location
);
125 nested_network_delegate_
->NotifyBeforeRedirect(request
, new_location
);
128 void LayeredNetworkDelegate::OnBeforeRedirectInternal(
130 const GURL
& new_location
) {
133 void LayeredNetworkDelegate::OnResponseStarted(URLRequest
* request
) {
134 OnResponseStartedInternal(request
);
135 nested_network_delegate_
->NotifyResponseStarted(request
);
138 void LayeredNetworkDelegate::OnResponseStartedInternal(URLRequest
* request
) {
141 void LayeredNetworkDelegate::OnRawBytesRead(const URLRequest
& request
,
143 OnRawBytesReadInternal(request
, bytes_read
);
144 nested_network_delegate_
->NotifyRawBytesRead(request
, bytes_read
);
147 void LayeredNetworkDelegate::OnRawBytesReadInternal(const URLRequest
& request
,
151 void LayeredNetworkDelegate::OnCompleted(URLRequest
* request
, bool started
) {
152 OnCompletedInternal(request
, started
);
153 nested_network_delegate_
->NotifyCompleted(request
, started
);
156 void LayeredNetworkDelegate::OnCompletedInternal(URLRequest
* request
,
160 void LayeredNetworkDelegate::OnURLRequestDestroyed(URLRequest
* request
) {
161 OnURLRequestDestroyedInternal(request
);
162 nested_network_delegate_
->NotifyURLRequestDestroyed(request
);
165 void LayeredNetworkDelegate::OnURLRequestDestroyedInternal(
166 URLRequest
* request
) {
169 void LayeredNetworkDelegate::OnPACScriptError(int line_number
,
170 const base::string16
& error
) {
171 OnPACScriptErrorInternal(line_number
, error
);
172 nested_network_delegate_
->NotifyPACScriptError(line_number
, error
);
175 void LayeredNetworkDelegate::OnPACScriptErrorInternal(
177 const base::string16
& error
) {
180 NetworkDelegate::AuthRequiredResponse
LayeredNetworkDelegate::OnAuthRequired(
182 const AuthChallengeInfo
& auth_info
,
183 const AuthCallback
& callback
,
184 AuthCredentials
* credentials
) {
185 OnAuthRequiredInternal(request
, auth_info
, callback
, credentials
);
186 return nested_network_delegate_
->NotifyAuthRequired(request
, auth_info
,
187 callback
, credentials
);
190 void LayeredNetworkDelegate::OnAuthRequiredInternal(
192 const AuthChallengeInfo
& auth_info
,
193 const AuthCallback
& callback
,
194 AuthCredentials
* credentials
) {
197 bool LayeredNetworkDelegate::OnCanGetCookies(const URLRequest
& request
,
198 const CookieList
& cookie_list
) {
199 OnCanGetCookiesInternal(request
, cookie_list
);
200 return nested_network_delegate_
->CanGetCookies(request
, cookie_list
);
203 void LayeredNetworkDelegate::OnCanGetCookiesInternal(
204 const URLRequest
& request
,
205 const CookieList
& cookie_list
) {
208 bool LayeredNetworkDelegate::OnCanSetCookie(const URLRequest
& request
,
209 const std::string
& cookie_line
,
210 CookieOptions
* options
) {
211 OnCanSetCookieInternal(request
, cookie_line
, options
);
212 return nested_network_delegate_
->CanSetCookie(request
, cookie_line
, options
);
215 void LayeredNetworkDelegate::OnCanSetCookieInternal(
216 const URLRequest
& request
,
217 const std::string
& cookie_line
,
218 CookieOptions
* options
) {
221 bool LayeredNetworkDelegate::OnCanAccessFile(const URLRequest
& request
,
222 const base::FilePath
& path
) const {
223 OnCanAccessFileInternal(request
, path
);
224 return nested_network_delegate_
->CanAccessFile(request
, path
);
227 void LayeredNetworkDelegate::OnCanAccessFileInternal(
228 const URLRequest
& request
,
229 const base::FilePath
& path
) const {
232 bool LayeredNetworkDelegate::OnCanThrottleRequest(
233 const URLRequest
& request
) const {
234 OnCanThrottleRequestInternal(request
);
235 return nested_network_delegate_
->CanThrottleRequest(request
);
238 void LayeredNetworkDelegate::OnCanThrottleRequestInternal(
239 const URLRequest
& request
) const {
242 bool LayeredNetworkDelegate::OnCanEnablePrivacyMode(
244 const GURL
& first_party_for_cookies
) const {
245 OnCanEnablePrivacyModeInternal(url
, first_party_for_cookies
);
246 return nested_network_delegate_
->CanEnablePrivacyMode(
247 url
, first_party_for_cookies
);
250 void LayeredNetworkDelegate::OnCanEnablePrivacyModeInternal(
252 const GURL
& first_party_for_cookies
) const {
255 bool LayeredNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabled() const {
256 OnFirstPartyOnlyCookieExperimentEnabledInternal();
257 return nested_network_delegate_
->FirstPartyOnlyCookieExperimentEnabled();
260 void LayeredNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabledInternal()
264 bool LayeredNetworkDelegate::
265 OnCancelURLRequestWithPolicyViolatingReferrerHeader(
266 const URLRequest
& request
,
267 const GURL
& target_url
,
268 const GURL
& referrer_url
) const {
269 OnCancelURLRequestWithPolicyViolatingReferrerHeaderInternal(
270 request
, target_url
, referrer_url
);
271 return nested_network_delegate_
272 ->CancelURLRequestWithPolicyViolatingReferrerHeader(request
, target_url
,
276 void LayeredNetworkDelegate::
277 OnCancelURLRequestWithPolicyViolatingReferrerHeaderInternal(
278 const URLRequest
& request
,
279 const GURL
& target_url
,
280 const GURL
& referrer_url
) const {