OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 308 } |
309 | 309 |
310 /////////////////////////////////////////////////////////////////////////////// | 310 /////////////////////////////////////////////////////////////////////////////// |
311 | 311 |
312 void URLRequest::StartJob(URLRequestJob* job) { | 312 void URLRequest::StartJob(URLRequestJob* job) { |
313 DCHECK(!is_pending_); | 313 DCHECK(!is_pending_); |
314 DCHECK(!job_); | 314 DCHECK(!job_); |
315 | 315 |
316 net_log_.BeginEvent( | 316 net_log_.BeginEvent( |
317 net::NetLog::TYPE_URL_REQUEST_START_JOB, | 317 net::NetLog::TYPE_URL_REQUEST_START_JOB, |
318 new URLRequestStartEventParameters( | 318 make_scoped_refptr(new URLRequestStartEventParameters( |
319 url_, method_, load_flags_, priority_)); | 319 url_, method_, load_flags_, priority_))); |
320 | 320 |
321 job_ = job; | 321 job_ = job; |
322 job_->SetExtraRequestHeaders(extra_request_headers_); | 322 job_->SetExtraRequestHeaders(extra_request_headers_); |
323 | 323 |
324 if (upload_.get()) | 324 if (upload_.get()) |
325 job_->SetUpload(upload_.get()); | 325 job_->SetUpload(upload_.get()); |
326 | 326 |
327 is_pending_ = true; | 327 is_pending_ = true; |
328 | 328 |
329 response_info_.request_time = Time::Now(); | 329 response_info_.request_time = Time::Now(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 void URLRequest::OrphanJob() { | 486 void URLRequest::OrphanJob() { |
487 job_->Kill(); | 487 job_->Kill(); |
488 job_->DetachRequest(); // ensures that the job will not call us again | 488 job_->DetachRequest(); // ensures that the job will not call us again |
489 job_ = NULL; | 489 job_ = NULL; |
490 } | 490 } |
491 | 491 |
492 int URLRequest::Redirect(const GURL& location, int http_status_code) { | 492 int URLRequest::Redirect(const GURL& location, int http_status_code) { |
493 if (net_log_.IsLoggingAllEvents()) { | 493 if (net_log_.IsLoggingAllEvents()) { |
494 net_log_.AddEvent( | 494 net_log_.AddEvent( |
495 net::NetLog::TYPE_URL_REQUEST_REDIRECTED, | 495 net::NetLog::TYPE_URL_REQUEST_REDIRECTED, |
496 new net::NetLogStringParameter( | 496 make_scoped_refptr(new net::NetLogStringParameter( |
497 "location", location.possibly_invalid_spec())); | 497 "location", location.possibly_invalid_spec()))); |
498 } | 498 } |
499 if (redirect_limit_ <= 0) { | 499 if (redirect_limit_ <= 0) { |
500 DVLOG(1) << "disallowing redirect: exceeds limit"; | 500 DVLOG(1) << "disallowing redirect: exceeds limit"; |
501 return net::ERR_TOO_MANY_REDIRECTS; | 501 return net::ERR_TOO_MANY_REDIRECTS; |
502 } | 502 } |
503 | 503 |
504 if (!location.is_valid()) | 504 if (!location.is_valid()) |
505 return net::ERR_INVALID_URL; | 505 return net::ERR_INVALID_URL; |
506 | 506 |
507 if (!job_->IsSafeRedirect(location)) { | 507 if (!job_->IsSafeRedirect(location)) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { | 579 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { |
580 UserDataMap::const_iterator found = user_data_.find(key); | 580 UserDataMap::const_iterator found = user_data_.find(key); |
581 if (found != user_data_.end()) | 581 if (found != user_data_.end()) |
582 return found->second.get(); | 582 return found->second.get(); |
583 return NULL; | 583 return NULL; |
584 } | 584 } |
585 | 585 |
586 void URLRequest::SetUserData(const void* key, UserData* data) { | 586 void URLRequest::SetUserData(const void* key, UserData* data) { |
587 user_data_[key] = linked_ptr<UserData>(data); | 587 user_data_[key] = linked_ptr<UserData>(data); |
588 } | 588 } |
OLD | NEW |