| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/singleton.h" | 9 #include "base/singleton.h" |
| 10 #include "base/stats_counters.h" | 10 #include "base/stats_counters.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 void URLRequest::Start() { | 252 void URLRequest::Start() { |
| 253 StartJob(GetJobManager()->CreateJob(this)); | 253 StartJob(GetJobManager()->CreateJob(this)); |
| 254 } | 254 } |
| 255 | 255 |
| 256 /////////////////////////////////////////////////////////////////////////////// | 256 /////////////////////////////////////////////////////////////////////////////// |
| 257 | 257 |
| 258 void URLRequest::StartJob(URLRequestJob* job) { | 258 void URLRequest::StartJob(URLRequestJob* job) { |
| 259 DCHECK(!is_pending_); | 259 DCHECK(!is_pending_); |
| 260 DCHECK(!job_); | 260 DCHECK(!job_); |
| 261 | 261 |
| 262 net_log_.BeginEvent(net::NetLog::TYPE_URL_REQUEST_START); | 262 net_log_.BeginEventWithString(net::NetLog::TYPE_URL_REQUEST_START, |
| 263 original_url().possibly_invalid_spec()); |
| 263 | 264 |
| 264 job_ = job; | 265 job_ = job; |
| 265 job_->SetExtraRequestHeaders(extra_request_headers_); | 266 job_->SetExtraRequestHeaders(extra_request_headers_); |
| 266 | 267 |
| 267 if (upload_.get()) | 268 if (upload_.get()) |
| 268 job_->SetUpload(upload_.get()); | 269 job_->SetUpload(upload_.get()); |
| 269 | 270 |
| 270 is_pending_ = true; | 271 is_pending_ = true; |
| 271 | 272 |
| 272 response_info_.request_time = Time::Now(); | 273 response_info_.request_time = Time::Now(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 void URLRequest::ReceivedRedirect(const GURL& location, bool* defer_redirect) { | 359 void URLRequest::ReceivedRedirect(const GURL& location, bool* defer_redirect) { |
| 359 URLRequestJob* job = GetJobManager()->MaybeInterceptRedirect(this, location); | 360 URLRequestJob* job = GetJobManager()->MaybeInterceptRedirect(this, location); |
| 360 if (job) { | 361 if (job) { |
| 361 RestartWithJob(job); | 362 RestartWithJob(job); |
| 362 } else if (delegate_) { | 363 } else if (delegate_) { |
| 363 delegate_->OnReceivedRedirect(this, location, defer_redirect); | 364 delegate_->OnReceivedRedirect(this, location, defer_redirect); |
| 364 } | 365 } |
| 365 } | 366 } |
| 366 | 367 |
| 367 void URLRequest::ResponseStarted() { | 368 void URLRequest::ResponseStarted() { |
| 368 if (!status_.is_success()) | 369 if (!status_.is_success()) { |
| 369 net_log_.AddErrorCode(status_.os_error()); | 370 net_log_.EndEventWithInteger(net::NetLog::TYPE_URL_REQUEST_START, |
| 370 | 371 status_.os_error()); |
| 371 net_log_.EndEvent(net::NetLog::TYPE_URL_REQUEST_START); | 372 } else { |
| 373 net_log_.EndEvent(net::NetLog::TYPE_URL_REQUEST_START); |
| 374 } |
| 372 | 375 |
| 373 URLRequestJob* job = GetJobManager()->MaybeInterceptResponse(this); | 376 URLRequestJob* job = GetJobManager()->MaybeInterceptResponse(this); |
| 374 if (job) { | 377 if (job) { |
| 375 RestartWithJob(job); | 378 RestartWithJob(job); |
| 376 } else if (delegate_) { | 379 } else if (delegate_) { |
| 377 delegate_->OnResponseStarted(this); | 380 delegate_->OnResponseStarted(this); |
| 378 } | 381 } |
| 379 } | 382 } |
| 380 | 383 |
| 381 void URLRequest::FollowDeferredRedirect() { | 384 void URLRequest::FollowDeferredRedirect() { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 context_ = context; | 511 context_ = context; |
| 509 | 512 |
| 510 // If the context this request belongs to has changed, update the tracker. | 513 // If the context this request belongs to has changed, update the tracker. |
| 511 if (prev_context != context) { | 514 if (prev_context != context) { |
| 512 net_log_.EndEvent(net::NetLog::TYPE_REQUEST_ALIVE); | 515 net_log_.EndEvent(net::NetLog::TYPE_REQUEST_ALIVE); |
| 513 net_log_ = net::BoundNetLog(); | 516 net_log_ = net::BoundNetLog(); |
| 514 | 517 |
| 515 if (context) { | 518 if (context) { |
| 516 net_log_ = net::BoundNetLog::Make(context->net_log(), | 519 net_log_ = net::BoundNetLog::Make(context->net_log(), |
| 517 net::NetLog::SOURCE_URL_REQUEST); | 520 net::NetLog::SOURCE_URL_REQUEST); |
| 518 | 521 net_log_.BeginEvent(net::NetLog::TYPE_REQUEST_ALIVE); |
| 519 net_log_.BeginEventWithString(net::NetLog::TYPE_REQUEST_ALIVE, | |
| 520 original_url_.possibly_invalid_spec()); | |
| 521 } | 522 } |
| 522 } | 523 } |
| 523 } | 524 } |
| 524 | 525 |
| 525 int64 URLRequest::GetExpectedContentSize() const { | 526 int64 URLRequest::GetExpectedContentSize() const { |
| 526 int64 expected_content_size = -1; | 527 int64 expected_content_size = -1; |
| 527 if (job_) | 528 if (job_) |
| 528 expected_content_size = job_->expected_content_size(); | 529 expected_content_size = job_->expected_content_size(); |
| 529 | 530 |
| 530 return expected_content_size; | 531 return expected_content_size; |
| 531 } | 532 } |
| 532 | 533 |
| 533 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { | 534 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { |
| 534 UserDataMap::const_iterator found = user_data_.find(key); | 535 UserDataMap::const_iterator found = user_data_.find(key); |
| 535 if (found != user_data_.end()) | 536 if (found != user_data_.end()) |
| 536 return found->second.get(); | 537 return found->second.get(); |
| 537 return NULL; | 538 return NULL; |
| 538 } | 539 } |
| 539 | 540 |
| 540 void URLRequest::SetUserData(const void* key, UserData* data) { | 541 void URLRequest::SetUserData(const void* key, UserData* data) { |
| 541 user_data_[key] = linked_ptr<UserData>(data); | 542 user_data_[key] = linked_ptr<UserData>(data); |
| 542 } | 543 } |
| OLD | NEW |