Update V8 to version 4.7.42.
[chromium-blink-merge.git] / net / base / network_delegate.cc
blob82c0cf6d0f0615b17db7fffeb481eb45828a6798
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 "base/profiler/scoped_tracker.h"
9 #include "net/base/load_flags.h"
10 #include "net/base/net_errors.h"
11 #include "net/proxy/proxy_info.h"
12 #include "net/url_request/url_request.h"
14 namespace net {
16 int NetworkDelegate::NotifyBeforeURLRequest(
17 URLRequest* request, const CompletionCallback& callback,
18 GURL* new_url) {
19 DCHECK(CalledOnValidThread());
20 DCHECK(request);
21 DCHECK(!callback.is_null());
22 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
23 tracked_objects::ScopedTracker tracking_profile(
24 FROM_HERE_WITH_EXPLICIT_FUNCTION(
25 "475753 NetworkDelegate::OnBeforeURLRequest"));
26 return OnBeforeURLRequest(request, callback, new_url);
29 void NetworkDelegate::NotifyResolveProxy(
30 const GURL& url,
31 int load_flags,
32 const ProxyService& proxy_service,
33 ProxyInfo* result) {
34 DCHECK(CalledOnValidThread());
35 DCHECK(result);
36 OnResolveProxy(url, load_flags, proxy_service, result);
39 void NetworkDelegate::NotifyProxyFallback(
40 const ProxyServer& bad_proxy,
41 int net_error) {
42 DCHECK(CalledOnValidThread());
43 OnProxyFallback(bad_proxy, net_error);
46 int NetworkDelegate::NotifyBeforeSendHeaders(
47 URLRequest* request, const CompletionCallback& callback,
48 HttpRequestHeaders* headers) {
49 DCHECK(CalledOnValidThread());
50 DCHECK(headers);
51 DCHECK(!callback.is_null());
52 return OnBeforeSendHeaders(request, callback, headers);
55 void NetworkDelegate::NotifyBeforeSendProxyHeaders(
56 URLRequest* request,
57 const ProxyInfo& proxy_info,
58 HttpRequestHeaders* headers) {
59 DCHECK(CalledOnValidThread());
60 DCHECK(headers);
61 OnBeforeSendProxyHeaders(request, proxy_info, headers);
64 void NetworkDelegate::NotifySendHeaders(URLRequest* request,
65 const HttpRequestHeaders& headers) {
66 DCHECK(CalledOnValidThread());
67 OnSendHeaders(request, headers);
70 int NetworkDelegate::NotifyHeadersReceived(
71 URLRequest* request,
72 const CompletionCallback& callback,
73 const HttpResponseHeaders* original_response_headers,
74 scoped_refptr<HttpResponseHeaders>* override_response_headers,
75 GURL* allowed_unsafe_redirect_url) {
76 DCHECK(CalledOnValidThread());
77 DCHECK(original_response_headers);
78 DCHECK(!callback.is_null());
79 return OnHeadersReceived(request,
80 callback,
81 original_response_headers,
82 override_response_headers,
83 allowed_unsafe_redirect_url);
86 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) {
87 DCHECK(CalledOnValidThread());
88 DCHECK(request);
89 OnResponseStarted(request);
92 void NetworkDelegate::NotifyNetworkBytesReceived(const URLRequest& request,
93 int64_t bytes_received) {
94 DCHECK(CalledOnValidThread());
95 DCHECK_GT(bytes_received, 0);
96 OnNetworkBytesReceived(request, bytes_received);
99 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request,
100 const GURL& new_location) {
101 DCHECK(CalledOnValidThread());
102 DCHECK(request);
103 OnBeforeRedirect(request, new_location);
106 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) {
107 DCHECK(CalledOnValidThread());
108 DCHECK(request);
109 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed.
110 tracked_objects::ScopedTracker tracking_profile(
111 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted"));
112 OnCompleted(request, started);
115 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) {
116 DCHECK(CalledOnValidThread());
117 DCHECK(request);
118 OnURLRequestDestroyed(request);
121 void NetworkDelegate::NotifyPACScriptError(int line_number,
122 const base::string16& error) {
123 DCHECK(CalledOnValidThread());
124 OnPACScriptError(line_number, error);
127 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired(
128 URLRequest* request,
129 const AuthChallengeInfo& auth_info,
130 const AuthCallback& callback,
131 AuthCredentials* credentials) {
132 DCHECK(CalledOnValidThread());
133 return OnAuthRequired(request, auth_info, callback, credentials);
136 bool NetworkDelegate::CanGetCookies(const URLRequest& request,
137 const CookieList& cookie_list) {
138 DCHECK(CalledOnValidThread());
139 DCHECK(!(request.load_flags() & 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() & 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::CanEnablePrivacyMode(
158 const GURL& url,
159 const GURL& first_party_for_cookies) const {
160 DCHECK(CalledOnValidThread());
161 return OnCanEnablePrivacyMode(url, first_party_for_cookies);
164 bool NetworkDelegate::FirstPartyOnlyCookieExperimentEnabled() const {
165 return OnFirstPartyOnlyCookieExperimentEnabled();
168 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader(
169 const URLRequest& request,
170 const GURL& target_url,
171 const GURL& referrer_url) const {
172 DCHECK(CalledOnValidThread());
173 return OnCancelURLRequestWithPolicyViolatingReferrerHeader(
174 request, target_url, referrer_url);
177 } // namespace net