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/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, | 194 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, |
195 const SSLInfo& ssl_info, | 195 const SSLInfo& ssl_info, |
196 bool is_hsts_ok) { | 196 bool is_hsts_ok) { |
197 request->Cancel(); | 197 request->Cancel(); |
198 } | 198 } |
199 | 199 |
200 /////////////////////////////////////////////////////////////////////////////// | 200 /////////////////////////////////////////////////////////////////////////////// |
201 // URLRequest | 201 // URLRequest |
202 | 202 |
203 // TODO(shalev): Get rid of this constructor in favour of the one below it. | |
204 URLRequest::URLRequest(const GURL& url, | 203 URLRequest::URLRequest(const GURL& url, |
| 204 RequestPriority priority, |
205 Delegate* delegate, | 205 Delegate* delegate, |
206 const URLRequestContext* context) | 206 const URLRequestContext* context) |
207 : context_(context), | 207 : context_(context), |
208 network_delegate_(context->network_delegate()), | 208 network_delegate_(context->network_delegate()), |
209 net_log_(BoundNetLog::Make(context->net_log(), | 209 net_log_(BoundNetLog::Make(context->net_log(), |
210 NetLog::SOURCE_URL_REQUEST)), | 210 NetLog::SOURCE_URL_REQUEST)), |
211 url_chain_(1, url), | 211 url_chain_(1, url), |
212 method_("GET"), | 212 method_("GET"), |
213 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), | 213 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), |
214 load_flags_(LOAD_NORMAL), | 214 load_flags_(LOAD_NORMAL), |
215 delegate_(delegate), | 215 delegate_(delegate), |
216 is_pending_(false), | 216 is_pending_(false), |
217 is_redirecting_(false), | 217 is_redirecting_(false), |
218 redirect_limit_(kMaxRedirects), | 218 redirect_limit_(kMaxRedirects), |
219 priority_(DEFAULT_PRIORITY), | 219 priority_(priority), |
220 identifier_(GenerateURLRequestIdentifier()), | 220 identifier_(GenerateURLRequestIdentifier()), |
221 calling_delegate_(false), | 221 calling_delegate_(false), |
222 delegate_info_usage_(DELEGATE_INFO_DEBUG_ONLY), | 222 delegate_info_usage_(DELEGATE_INFO_DEBUG_ONLY), |
223 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, | |
224 base::Unretained(this))), | |
225 has_notified_completion_(false), | |
226 received_response_content_length_(0), | |
227 creation_time_(base::TimeTicks::Now()) { | |
228 SIMPLE_STATS_COUNTER("URLRequestCount"); | |
229 | |
230 // Sanity check out environment. | |
231 DCHECK(base::MessageLoop::current()) | |
232 << "The current base::MessageLoop must exist"; | |
233 | |
234 CHECK(context); | |
235 context->url_requests()->insert(this); | |
236 | |
237 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE); | |
238 } | |
239 | |
240 URLRequest::URLRequest(const GURL& url, | |
241 Delegate* delegate, | |
242 const URLRequestContext* context, | |
243 NetworkDelegate* network_delegate) | |
244 : context_(context), | |
245 network_delegate_(network_delegate), | |
246 net_log_(BoundNetLog::Make(context->net_log(), | |
247 NetLog::SOURCE_URL_REQUEST)), | |
248 url_chain_(1, url), | |
249 method_("GET"), | |
250 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), | |
251 load_flags_(LOAD_NORMAL), | |
252 delegate_(delegate), | |
253 is_pending_(false), | |
254 is_redirecting_(false), | |
255 redirect_limit_(kMaxRedirects), | |
256 priority_(DEFAULT_PRIORITY), | |
257 identifier_(GenerateURLRequestIdentifier()), | |
258 calling_delegate_(false), | |
259 delegate_info_usage_(DELEGATE_INFO_DEBUG_ONLY), | |
260 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, | 223 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, |
261 base::Unretained(this))), | 224 base::Unretained(this))), |
262 has_notified_completion_(false), | 225 has_notified_completion_(false), |
263 received_response_content_length_(0), | 226 received_response_content_length_(0), |
264 creation_time_(base::TimeTicks::Now()) { | 227 creation_time_(base::TimeTicks::Now()) { |
265 SIMPLE_STATS_COUNTER("URLRequestCount"); | 228 SIMPLE_STATS_COUNTER("URLRequestCount"); |
266 | 229 |
267 // Sanity check out environment. | 230 // Sanity check out environment. |
268 DCHECK(base::MessageLoop::current()) | 231 DCHECK(base::MessageLoop::current()) |
269 << "The current base::MessageLoop must exist"; | 232 << "The current base::MessageLoop must exist"; |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 new base::debug::StackTrace(NULL, 0); | 1159 new base::debug::StackTrace(NULL, 0); |
1197 *stack_trace_copy = stack_trace; | 1160 *stack_trace_copy = stack_trace; |
1198 stack_trace_.reset(stack_trace_copy); | 1161 stack_trace_.reset(stack_trace_copy); |
1199 } | 1162 } |
1200 | 1163 |
1201 const base::debug::StackTrace* URLRequest::stack_trace() const { | 1164 const base::debug::StackTrace* URLRequest::stack_trace() const { |
1202 return stack_trace_.get(); | 1165 return stack_trace_.get(); |
1203 } | 1166 } |
1204 | 1167 |
1205 } // namespace net | 1168 } // namespace net |
OLD | NEW |