Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / net / base / layered_network_delegate.cc
blobf84b468732ded7a6aef5360181e821ba3fdb9ce3
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"
7 namespace net {
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(
18 URLRequest* request,
19 const CompletionCallback& callback,
20 GURL* new_url) {
21 OnBeforeURLRequestInternal(request, callback, new_url);
22 return nested_network_delegate_->NotifyBeforeURLRequest(request, callback,
23 new_url);
26 void LayeredNetworkDelegate::OnBeforeURLRequestInternal(
27 URLRequest* request,
28 const CompletionCallback& callback,
29 GURL* new_url) {
32 void LayeredNetworkDelegate::OnResolveProxy(const GURL& url,
33 int load_flags,
34 const ProxyService& proxy_service,
35 ProxyInfo* result) {
36 OnResolveProxyInternal(url, load_flags, proxy_service, result);
37 nested_network_delegate_->NotifyResolveProxy(url, load_flags, proxy_service,
38 result);
41 void LayeredNetworkDelegate::OnResolveProxyInternal(
42 const GURL& url,
43 int load_flags,
44 const ProxyService& proxy_service,
45 ProxyInfo* result) {
48 void LayeredNetworkDelegate::OnProxyFallback(const ProxyServer& bad_proxy,
49 int net_error) {
50 OnProxyFallbackInternal(bad_proxy, net_error);
51 nested_network_delegate_->NotifyProxyFallback(bad_proxy, net_error);
54 void LayeredNetworkDelegate::OnProxyFallbackInternal(
55 const ProxyServer& bad_proxy,
56 int net_error) {
59 int LayeredNetworkDelegate::OnBeforeSendHeaders(
60 URLRequest* request,
61 const CompletionCallback& callback,
62 HttpRequestHeaders* headers) {
63 OnBeforeSendHeadersInternal(request, callback, headers);
64 return nested_network_delegate_->NotifyBeforeSendHeaders(request, callback,
65 headers);
68 void LayeredNetworkDelegate::OnBeforeSendHeadersInternal(
69 URLRequest* request,
70 const CompletionCallback& callback,
71 HttpRequestHeaders* headers) {
74 void LayeredNetworkDelegate::OnBeforeSendProxyHeaders(
75 URLRequest* request,
76 const ProxyInfo& proxy_info,
77 HttpRequestHeaders* headers) {
78 OnBeforeSendProxyHeadersInternal(request, proxy_info, headers);
79 nested_network_delegate_->NotifyBeforeSendProxyHeaders(request, proxy_info,
80 headers);
83 void LayeredNetworkDelegate::OnBeforeSendProxyHeadersInternal(
84 URLRequest* request,
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(
96 URLRequest* request,
97 const HttpRequestHeaders& headers) {
100 int LayeredNetworkDelegate::OnHeadersReceived(
101 URLRequest* request,
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(
115 URLRequest* request,
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(
129 URLRequest* request,
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::OnNetworkBytesReceived(const URLRequest& request,
142 int64_t bytes_received) {
143 OnNetworkBytesReceivedInternal(request, bytes_received);
144 nested_network_delegate_->NotifyNetworkBytesReceived(request, bytes_received);
147 void LayeredNetworkDelegate::OnNetworkBytesReceivedInternal(
148 const URLRequest& request,
149 int64_t bytes_received) {}
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,
157 bool started) {
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::OnURLRequestJobOrphaned(URLRequest* request) {
170 // This hook is only added to debug https://crbug.com/289715, so there is no
171 // need for a OnURLRequestJobOrphanedInternal hook.
172 nested_network_delegate_->NotifyURLRequestJobOrphaned(request);
175 void LayeredNetworkDelegate::OnPACScriptError(int line_number,
176 const base::string16& error) {
177 OnPACScriptErrorInternal(line_number, error);
178 nested_network_delegate_->NotifyPACScriptError(line_number, error);
181 void LayeredNetworkDelegate::OnPACScriptErrorInternal(
182 int line_number,
183 const base::string16& error) {
186 NetworkDelegate::AuthRequiredResponse LayeredNetworkDelegate::OnAuthRequired(
187 URLRequest* request,
188 const AuthChallengeInfo& auth_info,
189 const AuthCallback& callback,
190 AuthCredentials* credentials) {
191 OnAuthRequiredInternal(request, auth_info, callback, credentials);
192 return nested_network_delegate_->NotifyAuthRequired(request, auth_info,
193 callback, credentials);
196 void LayeredNetworkDelegate::OnAuthRequiredInternal(
197 URLRequest* request,
198 const AuthChallengeInfo& auth_info,
199 const AuthCallback& callback,
200 AuthCredentials* credentials) {
203 bool LayeredNetworkDelegate::OnCanGetCookies(const URLRequest& request,
204 const CookieList& cookie_list) {
205 OnCanGetCookiesInternal(request, cookie_list);
206 return nested_network_delegate_->CanGetCookies(request, cookie_list);
209 void LayeredNetworkDelegate::OnCanGetCookiesInternal(
210 const URLRequest& request,
211 const CookieList& cookie_list) {
214 bool LayeredNetworkDelegate::OnCanSetCookie(const URLRequest& request,
215 const std::string& cookie_line,
216 CookieOptions* options) {
217 OnCanSetCookieInternal(request, cookie_line, options);
218 return nested_network_delegate_->CanSetCookie(request, cookie_line, options);
221 void LayeredNetworkDelegate::OnCanSetCookieInternal(
222 const URLRequest& request,
223 const std::string& cookie_line,
224 CookieOptions* options) {
227 bool LayeredNetworkDelegate::OnCanAccessFile(const URLRequest& request,
228 const base::FilePath& path) const {
229 OnCanAccessFileInternal(request, path);
230 return nested_network_delegate_->CanAccessFile(request, path);
233 void LayeredNetworkDelegate::OnCanAccessFileInternal(
234 const URLRequest& request,
235 const base::FilePath& path) const {
238 bool LayeredNetworkDelegate::OnCanEnablePrivacyMode(
239 const GURL& url,
240 const GURL& first_party_for_cookies) const {
241 OnCanEnablePrivacyModeInternal(url, first_party_for_cookies);
242 return nested_network_delegate_->CanEnablePrivacyMode(
243 url, first_party_for_cookies);
246 void LayeredNetworkDelegate::OnCanEnablePrivacyModeInternal(
247 const GURL& url,
248 const GURL& first_party_for_cookies) const {
251 bool LayeredNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabled() const {
252 OnFirstPartyOnlyCookieExperimentEnabledInternal();
253 return nested_network_delegate_->FirstPartyOnlyCookieExperimentEnabled();
256 void LayeredNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabledInternal()
257 const {
260 bool LayeredNetworkDelegate::
261 OnCancelURLRequestWithPolicyViolatingReferrerHeader(
262 const URLRequest& request,
263 const GURL& target_url,
264 const GURL& referrer_url) const {
265 OnCancelURLRequestWithPolicyViolatingReferrerHeaderInternal(
266 request, target_url, referrer_url);
267 return nested_network_delegate_
268 ->CancelURLRequestWithPolicyViolatingReferrerHeader(request, target_url,
269 referrer_url);
272 void LayeredNetworkDelegate::
273 OnCancelURLRequestWithPolicyViolatingReferrerHeaderInternal(
274 const URLRequest& request,
275 const GURL& target_url,
276 const GURL& referrer_url) const {
279 } // namespace net