| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 if (network_delegate_) { | 179 if (network_delegate_) { |
| 180 network_delegate_->NotifyURLRequestDestroyed(this); | 180 network_delegate_->NotifyURLRequestDestroyed(this); |
| 181 if (job_.get()) | 181 if (job_.get()) |
| 182 job_->NotifyURLRequestDestroyed(); | 182 job_->NotifyURLRequestDestroyed(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Delete job before |this|, since subclasses may do weird things, like depend | 185 // Delete job before |this|, since subclasses may do weird things, like depend |
| 186 // on UserData associated with |this| and poke at it during teardown. | 186 // on UserData associated with |this| and poke at it during teardown. |
| 187 job_.reset(); | 187 job_.reset(); |
| 188 | 188 |
| 189 DCHECK_EQ(1u, context_->url_requests()->count(this)); | 189 context_->RemoveURLRequest(this); |
| 190 context_->url_requests()->erase(this); | |
| 191 | 190 |
| 192 int net_error = OK; | 191 int net_error = OK; |
| 193 // Log error only on failure, not cancellation, as even successful requests | 192 // Log error only on failure, not cancellation, as even successful requests |
| 194 // are "cancelled" on destruction. | 193 // are "cancelled" on destruction. |
| 195 if (status_.status() == URLRequestStatus::FAILED) | 194 if (status_.status() == URLRequestStatus::FAILED) |
| 196 net_error = status_.error(); | 195 net_error = status_.error(); |
| 197 net_log_.EndEventWithNetErrorCode(NetLogEventType::REQUEST_ALIVE, net_error); | 196 net_log_.EndEventWithNetErrorCode(NetLogEventType::REQUEST_ALIVE, net_error); |
| 198 } | 197 } |
| 199 | 198 |
| 200 void URLRequest::set_upload(std::unique_ptr<UploadDataStream> upload) { | 199 void URLRequest::set_upload(std::unique_ptr<UploadDataStream> upload) { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 use_blocked_by_as_load_param_(false), | 577 use_blocked_by_as_load_param_(false), |
| 579 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, | 578 before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete, |
| 580 base::Unretained(this))), | 579 base::Unretained(this))), |
| 581 has_notified_completion_(false), | 580 has_notified_completion_(false), |
| 582 received_response_content_length_(0), | 581 received_response_content_length_(0), |
| 583 creation_time_(base::TimeTicks::Now()), | 582 creation_time_(base::TimeTicks::Now()), |
| 584 raw_header_size_(0) { | 583 raw_header_size_(0) { |
| 585 // Sanity check out environment. | 584 // Sanity check out environment. |
| 586 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); | 585 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); |
| 587 | 586 |
| 588 context->url_requests()->insert(this); | 587 context->InsertURLRequest(this); |
| 589 net_log_.BeginEvent( | 588 net_log_.BeginEvent( |
| 590 NetLogEventType::REQUEST_ALIVE, | 589 NetLogEventType::REQUEST_ALIVE, |
| 591 base::Bind(&NetLogURLRequestConstructorCallback, &url, priority_)); | 590 base::Bind(&NetLogURLRequestConstructorCallback, &url, priority_)); |
| 592 } | 591 } |
| 593 | 592 |
| 594 void URLRequest::BeforeRequestComplete(int error) { | 593 void URLRequest::BeforeRequestComplete(int error) { |
| 595 DCHECK(!job_.get()); | 594 DCHECK(!job_.get()); |
| 596 DCHECK_NE(ERR_IO_PENDING, error); | 595 DCHECK_NE(ERR_IO_PENDING, error); |
| 597 | 596 |
| 598 // Check that there are no callbacks to already canceled requests. | 597 // Check that there are no callbacks to already canceled requests. |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 out->clear(); | 1215 out->clear(); |
| 1217 } | 1216 } |
| 1218 | 1217 |
| 1219 void URLRequest::set_status(URLRequestStatus status) { | 1218 void URLRequest::set_status(URLRequestStatus status) { |
| 1220 DCHECK(status_.is_io_pending() || status_.is_success() || | 1219 DCHECK(status_.is_io_pending() || status_.is_success() || |
| 1221 (!status.is_success() && !status.is_io_pending())); | 1220 (!status.is_success() && !status.is_io_pending())); |
| 1222 status_ = status; | 1221 status_ = status; |
| 1223 } | 1222 } |
| 1224 | 1223 |
| 1225 } // namespace net | 1224 } // namespace net |
| OLD | NEW |