Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: net/url_request/url_request.cc

Issue 51953002: [Net] Add a priority parameter to URLRequest's constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error from rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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,
205 Delegate* delegate, 204 RequestPriority priority,
206 const URLRequestContext* context)
207 : context_(context),
208 network_delegate_(context->network_delegate()),
209 net_log_(BoundNetLog::Make(context->net_log(),
210 NetLog::SOURCE_URL_REQUEST)),
211 url_chain_(1, url),
212 method_("GET"),
213 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
214 load_flags_(LOAD_NORMAL),
215 delegate_(delegate),
216 is_pending_(false),
217 is_redirecting_(false),
218 redirect_limit_(kMaxRedirects),
219 priority_(DEFAULT_PRIORITY),
220 identifier_(GenerateURLRequestIdentifier()),
221 calling_delegate_(false),
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, 205 Delegate* delegate,
242 const URLRequestContext* context, 206 const URLRequestContext* context,
243 NetworkDelegate* network_delegate) 207 NetworkDelegate* network_delegate)
244 : context_(context), 208 : context_(context),
245 network_delegate_(network_delegate), 209 network_delegate_(network_delegate),
246 net_log_(BoundNetLog::Make(context->net_log(), 210 net_log_(BoundNetLog::Make(context->net_log(),
247 NetLog::SOURCE_URL_REQUEST)), 211 NetLog::SOURCE_URL_REQUEST)),
248 url_chain_(1, url), 212 url_chain_(1, url),
249 method_("GET"), 213 method_("GET"),
250 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), 214 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
251 load_flags_(LOAD_NORMAL), 215 load_flags_(LOAD_NORMAL),
252 delegate_(delegate), 216 delegate_(delegate),
253 is_pending_(false), 217 is_pending_(false),
254 is_redirecting_(false), 218 is_redirecting_(false),
255 redirect_limit_(kMaxRedirects), 219 redirect_limit_(kMaxRedirects),
256 priority_(DEFAULT_PRIORITY), 220 priority_(priority),
257 identifier_(GenerateURLRequestIdentifier()), 221 identifier_(GenerateURLRequestIdentifier()),
258 calling_delegate_(false), 222 calling_delegate_(false),
259 delegate_info_usage_(DELEGATE_INFO_DEBUG_ONLY), 223 delegate_info_usage_(DELEGATE_INFO_DEBUG_ONLY),
260 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, 224 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete,
261 base::Unretained(this))), 225 base::Unretained(this))),
262 has_notified_completion_(false), 226 has_notified_completion_(false),
263 received_response_content_length_(0), 227 received_response_content_length_(0),
264 creation_time_(base::TimeTicks::Now()) { 228 creation_time_(base::TimeTicks::Now()) {
265 SIMPLE_STATS_COUNTER("URLRequestCount"); 229 SIMPLE_STATS_COUNTER("URLRequestCount");
266 230
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 new base::debug::StackTrace(NULL, 0); 1160 new base::debug::StackTrace(NULL, 0);
1197 *stack_trace_copy = stack_trace; 1161 *stack_trace_copy = stack_trace;
1198 stack_trace_.reset(stack_trace_copy); 1162 stack_trace_.reset(stack_trace_copy);
1199 } 1163 }
1200 1164
1201 const base::debug::StackTrace* URLRequest::stack_trace() const { 1165 const base::debug::StackTrace* URLRequest::stack_trace() const {
1202 return stack_trace_.get(); 1166 return stack_trace_.get();
1203 } 1167 }
1204 1168
1205 } // namespace net 1169 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698