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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 if (transaction_.get()) { | 408 if (transaction_.get()) { |
409 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); | 409 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); |
410 auth_credentials_ = AuthCredentials(); | 410 auth_credentials_ = AuthCredentials(); |
411 } else { | 411 } else { |
412 DCHECK(request_->context()->http_transaction_factory()); | 412 DCHECK(request_->context()->http_transaction_factory()); |
413 | 413 |
414 rv = request_->context()->http_transaction_factory()->CreateTransaction( | 414 rv = request_->context()->http_transaction_factory()->CreateTransaction( |
415 priority_, &transaction_); | 415 priority_, &transaction_); |
416 | 416 |
417 transaction_->SetBeforeNetworkStartCallback(base::Bind( | |
418 &URLRequestHttpJob::NotifyBeforeNetworkStart, base::Unretained(this))); | |
419 | |
420 if (rv == OK && request_info_.url.SchemeIsWSOrWSS()) { | 417 if (rv == OK && request_info_.url.SchemeIsWSOrWSS()) { |
421 // TODO(ricea): Implement WebSocket throttling semantics as defined in | 418 // TODO(ricea): Implement WebSocket throttling semantics as defined in |
422 // RFC6455 Section 4.1. | 419 // RFC6455 Section 4.1. |
423 base::SupportsUserData::Data* data = request_->GetUserData( | 420 base::SupportsUserData::Data* data = request_->GetUserData( |
424 WebSocketHandshakeStreamBase::CreateHelper::DataKey()); | 421 WebSocketHandshakeStreamBase::CreateHelper::DataKey()); |
425 if (data) { | 422 if (data) { |
426 transaction_->SetWebSocketHandshakeStreamCreateHelper( | 423 transaction_->SetWebSocketHandshakeStreamCreateHelper( |
427 static_cast<WebSocketHandshakeStreamBase::CreateHelper*>(data)); | 424 static_cast<WebSocketHandshakeStreamBase::CreateHelper*>(data)); |
428 } else { | 425 } else { |
429 rv = ERR_DISALLOWED_URL_SCHEME; | 426 rv = ERR_DISALLOWED_URL_SCHEME; |
430 } | 427 } |
431 } | 428 } |
432 | 429 |
433 if (rv == OK) { | 430 if (rv == OK) { |
| 431 transaction_->SetBeforeNetworkStartCallback( |
| 432 base::Bind(&URLRequestHttpJob::NotifyBeforeNetworkStart, |
| 433 base::Unretained(this))); |
| 434 |
434 if (!throttling_entry_.get() || | 435 if (!throttling_entry_.get() || |
435 !throttling_entry_->ShouldRejectRequest(*request_)) { | 436 !throttling_entry_->ShouldRejectRequest(*request_)) { |
436 rv = transaction_->Start( | 437 rv = transaction_->Start( |
437 &request_info_, start_callback_, request_->net_log()); | 438 &request_info_, start_callback_, request_->net_log()); |
438 start_time_ = base::TimeTicks::Now(); | 439 start_time_ = base::TimeTicks::Now(); |
439 } else { | 440 } else { |
440 // Special error code for the exponential back-off module. | 441 // Special error code for the exponential back-off module. |
441 rv = ERR_TEMPORARILY_THROTTLED; | 442 rv = ERR_TEMPORARILY_THROTTLED; |
442 } | 443 } |
443 } | 444 } |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 return override_response_headers_.get() ? | 1455 return override_response_headers_.get() ? |
1455 override_response_headers_.get() : | 1456 override_response_headers_.get() : |
1456 transaction_->GetResponseInfo()->headers.get(); | 1457 transaction_->GetResponseInfo()->headers.get(); |
1457 } | 1458 } |
1458 | 1459 |
1459 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1460 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1460 awaiting_callback_ = false; | 1461 awaiting_callback_ = false; |
1461 } | 1462 } |
1462 | 1463 |
1463 } // namespace net | 1464 } // namespace net |
OLD | NEW |