| 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_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 transaction_.reset(); | 335 transaction_.reset(); |
| 336 response_info_ = NULL; | 336 response_info_ = NULL; |
| 337 } | 337 } |
| 338 | 338 |
| 339 void URLRequestHttpJob::StartTransaction() { | 339 void URLRequestHttpJob::StartTransaction() { |
| 340 if (request_->context()->network_delegate()) { | 340 if (request_->context()->network_delegate()) { |
| 341 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders( | 341 int rv = request_->context()->network_delegate()->NotifyBeforeSendHeaders( |
| 342 request_, notify_before_headers_sent_callback_, | 342 request_, notify_before_headers_sent_callback_, |
| 343 &request_info_.extra_headers); | 343 &request_info_.extra_headers); |
| 344 // If an extension blocks the request, we rely on the callback to | 344 // If an extension blocks the request, we rely on the callback to |
| 345 // StartTransactionInternal(). | 345 // MaybeStartTransactionInternal(). |
| 346 if (rv == ERR_IO_PENDING) { | 346 if (rv == ERR_IO_PENDING) { |
| 347 SetBlockedOnDelegate(); | 347 SetBlockedOnDelegate(); |
| 348 return; | 348 return; |
| 349 } | 349 } |
| 350 MaybeStartTransactionInternal(rv); |
| 351 return; |
| 350 } | 352 } |
| 351 StartTransactionInternal(); | 353 StartTransactionInternal(); |
| 352 } | 354 } |
| 353 | 355 |
| 354 void URLRequestHttpJob::NotifyBeforeSendHeadersCallback(int result) { | 356 void URLRequestHttpJob::NotifyBeforeSendHeadersCallback(int result) { |
| 355 SetUnblockedOnDelegate(); | 357 SetUnblockedOnDelegate(); |
| 356 | 358 |
| 357 // Check that there are no callbacks to already canceled requests. | 359 // Check that there are no callbacks to already canceled requests. |
| 358 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); | 360 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); |
| 359 | 361 |
| 362 MaybeStartTransactionInternal(result); |
| 363 } |
| 364 |
| 365 void URLRequestHttpJob::MaybeStartTransactionInternal(int result) { |
| 360 if (result == OK) { | 366 if (result == OK) { |
| 361 StartTransactionInternal(); | 367 StartTransactionInternal(); |
| 362 } else { | 368 } else { |
| 363 std::string source("delegate"); | 369 std::string source("delegate"); |
| 364 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, | 370 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, |
| 365 NetLog::StringCallback("source", &source)); | 371 NetLog::StringCallback("source", &source)); |
| 366 NotifyCanceled(); | 372 NotifyCanceled(); |
| 373 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 367 } | 374 } |
| 368 } | 375 } |
| 369 | 376 |
| 370 void URLRequestHttpJob::StartTransactionInternal() { | 377 void URLRequestHttpJob::StartTransactionInternal() { |
| 371 // NOTE: This method assumes that request_info_ is already setup properly. | 378 // NOTE: This method assumes that request_info_ is already setup properly. |
| 372 | 379 |
| 373 // If we already have a transaction, then we should restart the transaction | 380 // If we already have a transaction, then we should restart the transaction |
| 374 // with auth provided by auth_credentials_. | 381 // with auth provided by auth_credentials_. |
| 375 | 382 |
| 376 int rv; | 383 int rv; |
| (...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 | 1635 |
| 1629 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1636 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1630 awaiting_callback_ = false; | 1637 awaiting_callback_ = false; |
| 1631 } | 1638 } |
| 1632 | 1639 |
| 1633 void URLRequestHttpJob::OnDetachRequest() { | 1640 void URLRequestHttpJob::OnDetachRequest() { |
| 1634 http_transaction_delegate_->OnDetachRequest(); | 1641 http_transaction_delegate_->OnDetachRequest(); |
| 1635 } | 1642 } |
| 1636 | 1643 |
| 1637 } // namespace net | 1644 } // namespace net |
| OLD | NEW |