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 #include "net/base/network_delegate.h" | 5 #include "net/base/network_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
| 9 #include "net/base/net_errors.h" |
9 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
10 | 11 |
11 namespace net { | 12 namespace net { |
12 | 13 |
13 int NetworkDelegate::NotifyBeforeURLRequest( | 14 int NetworkDelegate::NotifyBeforeURLRequest( |
14 URLRequest* request, const CompletionCallback& callback, | 15 URLRequest* request, const CompletionCallback& callback, |
15 GURL* new_url) { | 16 GURL* new_url) { |
16 DCHECK(CalledOnValidThread()); | 17 DCHECK(CalledOnValidThread()); |
17 DCHECK(request); | 18 DCHECK(request); |
18 DCHECK(!callback.is_null()); | 19 DCHECK(!callback.is_null()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 86 |
86 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired( | 87 NetworkDelegate::AuthRequiredResponse NetworkDelegate::NotifyAuthRequired( |
87 URLRequest* request, | 88 URLRequest* request, |
88 const AuthChallengeInfo& auth_info, | 89 const AuthChallengeInfo& auth_info, |
89 const AuthCallback& callback, | 90 const AuthCallback& callback, |
90 AuthCredentials* credentials) { | 91 AuthCredentials* credentials) { |
91 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
92 return OnAuthRequired(request, auth_info, callback, credentials); | 93 return OnAuthRequired(request, auth_info, callback, credentials); |
93 } | 94 } |
94 | 95 |
| 96 int NetworkDelegate::NotifyBeforeSocketStreamConnect( |
| 97 SocketStream* socket, |
| 98 const CompletionCallback& callback) { |
| 99 DCHECK(CalledOnValidThread()); |
| 100 DCHECK(socket); |
| 101 DCHECK(!callback.is_null()); |
| 102 return OnBeforeSocketStreamConnect(socket, callback); |
| 103 } |
| 104 |
| 105 void NetworkDelegate::NotifyRequestWaitStateChange(const URLRequest& request, |
| 106 RequestWaitState state) { |
| 107 DCHECK(CalledOnValidThread()); |
| 108 OnRequestWaitStateChange(request, state); |
| 109 } |
| 110 |
95 bool NetworkDelegate::CanGetCookies(const URLRequest& request, | 111 bool NetworkDelegate::CanGetCookies(const URLRequest& request, |
96 const CookieList& cookie_list) { | 112 const CookieList& cookie_list) { |
97 DCHECK(CalledOnValidThread()); | 113 DCHECK(CalledOnValidThread()); |
98 DCHECK(!(request.load_flags() & net::LOAD_DO_NOT_SEND_COOKIES)); | 114 DCHECK(!(request.load_flags() & net::LOAD_DO_NOT_SEND_COOKIES)); |
99 return OnCanGetCookies(request, cookie_list); | 115 return OnCanGetCookies(request, cookie_list); |
100 } | 116 } |
101 | 117 |
102 bool NetworkDelegate::CanSetCookie(const URLRequest& request, | 118 bool NetworkDelegate::CanSetCookie(const URLRequest& request, |
103 const std::string& cookie_line, | 119 const std::string& cookie_line, |
104 CookieOptions* options) { | 120 CookieOptions* options) { |
(...skipping 13 matching lines...) Expand all Loading... |
118 return OnCanThrottleRequest(request); | 134 return OnCanThrottleRequest(request); |
119 } | 135 } |
120 | 136 |
121 bool NetworkDelegate::CanEnablePrivacyMode( | 137 bool NetworkDelegate::CanEnablePrivacyMode( |
122 const GURL& url, | 138 const GURL& url, |
123 const GURL& first_party_for_cookies) const { | 139 const GURL& first_party_for_cookies) const { |
124 DCHECK(CalledOnValidThread()); | 140 DCHECK(CalledOnValidThread()); |
125 return OnCanEnablePrivacyMode(url, first_party_for_cookies); | 141 return OnCanEnablePrivacyMode(url, first_party_for_cookies); |
126 } | 142 } |
127 | 143 |
| 144 int NetworkDelegate::OnBeforeURLRequest(URLRequest* request, |
| 145 const CompletionCallback& callback, |
| 146 GURL* new_url) { |
| 147 return OK; |
| 148 } |
| 149 |
| 150 int NetworkDelegate::OnBeforeSendHeaders(URLRequest* request, |
| 151 const CompletionCallback& callback, |
| 152 HttpRequestHeaders* headers) { |
| 153 return OK; |
| 154 } |
| 155 |
| 156 void NetworkDelegate::OnSendHeaders(URLRequest* request, |
| 157 const HttpRequestHeaders& headers) { |
| 158 } |
| 159 |
| 160 int NetworkDelegate::OnHeadersReceived( |
| 161 URLRequest* request, |
| 162 const CompletionCallback& callback, |
| 163 const HttpResponseHeaders* original_response_headers, |
| 164 scoped_refptr<HttpResponseHeaders>* override_response_headers) { |
| 165 return OK; |
| 166 } |
| 167 |
| 168 void NetworkDelegate::OnBeforeRedirect(URLRequest* request, |
| 169 const GURL& new_location) { |
| 170 } |
| 171 |
| 172 void NetworkDelegate::OnResponseStarted(URLRequest* request) { |
| 173 } |
| 174 |
| 175 void NetworkDelegate::OnRawBytesRead(const URLRequest& request, |
| 176 int bytes_read) { |
| 177 } |
| 178 |
| 179 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) { |
| 180 } |
| 181 |
| 182 void NetworkDelegate::OnURLRequestDestroyed(URLRequest* request) { |
| 183 } |
| 184 |
| 185 void NetworkDelegate::OnPACScriptError(int line_number, |
| 186 const base::string16& error) { |
| 187 } |
| 188 |
| 189 NetworkDelegate::AuthRequiredResponse NetworkDelegate::OnAuthRequired( |
| 190 URLRequest* request, |
| 191 const AuthChallengeInfo& auth_info, |
| 192 const AuthCallback& callback, |
| 193 AuthCredentials* credentials) { |
| 194 return AUTH_REQUIRED_RESPONSE_NO_ACTION; |
| 195 } |
| 196 |
| 197 bool NetworkDelegate::OnCanGetCookies(const URLRequest& request, |
| 198 const CookieList& cookie_list) { |
| 199 return true; |
| 200 } |
| 201 |
| 202 bool NetworkDelegate::OnCanSetCookie(const URLRequest& request, |
| 203 const std::string& cookie_line, |
| 204 CookieOptions* options) { |
| 205 return true; |
| 206 } |
| 207 |
| 208 bool NetworkDelegate::OnCanAccessFile(const URLRequest& request, |
| 209 const base::FilePath& path) const { |
| 210 return false; |
| 211 } |
| 212 |
| 213 bool NetworkDelegate::OnCanThrottleRequest(const URLRequest& request) const { |
| 214 return false; |
| 215 } |
| 216 |
128 bool NetworkDelegate::OnCanEnablePrivacyMode( | 217 bool NetworkDelegate::OnCanEnablePrivacyMode( |
129 const GURL& url, | 218 const GURL& url, |
130 const GURL& first_party_for_cookies) const { | 219 const GURL& first_party_for_cookies) const { |
131 // Default implementation disables privacy mode. | |
132 return false; | 220 return false; |
133 } | 221 } |
134 | 222 |
135 int NetworkDelegate::NotifyBeforeSocketStreamConnect( | 223 int NetworkDelegate::OnBeforeSocketStreamConnect( |
136 SocketStream* socket, | 224 SocketStream* socket, |
137 const CompletionCallback& callback) { | 225 const CompletionCallback& callback) { |
138 DCHECK(CalledOnValidThread()); | 226 return OK; |
139 DCHECK(socket); | |
140 DCHECK(!callback.is_null()); | |
141 return OnBeforeSocketStreamConnect(socket, callback); | |
142 } | 227 } |
143 | 228 |
144 void NetworkDelegate::NotifyRequestWaitStateChange(const URLRequest& request, | 229 void NetworkDelegate::OnRequestWaitStateChange(const URLRequest& request, |
145 RequestWaitState state) { | 230 RequestWaitState state) { |
146 DCHECK(CalledOnValidThread()); | |
147 OnRequestWaitStateChange(request, state); | |
148 } | 231 } |
149 | 232 |
150 } // namespace net | 233 } // namespace net |
OLD | NEW |