Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1306)

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_ftp_job.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 361
362 void URLRequestHttpJob::NotifyHeadersComplete() { 362 void URLRequestHttpJob::NotifyHeadersComplete() {
363 DCHECK(!response_info_); 363 DCHECK(!response_info_);
364 364
365 response_info_ = transaction_->GetResponseInfo(); 365 response_info_ = transaction_->GetResponseInfo();
366 366
367 // Save boolean, as we'll need this info at destruction time, and filters may 367 // Save boolean, as we'll need this info at destruction time, and filters may
368 // also need this info. 368 // also need this info.
369 is_cached_content_ = response_info_->was_cached; 369 is_cached_content_ = response_info_->was_cached;
370 370
371 if (!is_cached_content_ && throttling_entry_) { 371 if (!is_cached_content_ && throttling_entry_.get()) {
372 URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders()); 372 URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders());
373 throttling_entry_->UpdateWithResponse(request_info_.url.host(), 373 throttling_entry_->UpdateWithResponse(request_info_.url.host(),
374 &response_adapter); 374 &response_adapter);
375 } 375 }
376 376
377 // The ordering of these calls is not important. 377 // The ordering of these calls is not important.
378 ProcessStrictTransportSecurityHeader(); 378 ProcessStrictTransportSecurityHeader();
379 ProcessPublicKeyPinsHeader(); 379 ProcessPublicKeyPinsHeader();
380 380
381 if (SdchManager::Global() && 381 if (SdchManager::Global() &&
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 if (transaction_.get()) { 482 if (transaction_.get()) {
483 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); 483 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_);
484 auth_credentials_ = AuthCredentials(); 484 auth_credentials_ = AuthCredentials();
485 } else { 485 } else {
486 DCHECK(request_->context()->http_transaction_factory()); 486 DCHECK(request_->context()->http_transaction_factory());
487 487
488 rv = request_->context()->http_transaction_factory()->CreateTransaction( 488 rv = request_->context()->http_transaction_factory()->CreateTransaction(
489 priority_, &transaction_, http_transaction_delegate_.get()); 489 priority_, &transaction_, http_transaction_delegate_.get());
490 if (rv == OK) { 490 if (rv == OK) {
491 if (!throttling_entry_ || 491 if (!throttling_entry_.get() ||
492 !throttling_entry_->ShouldRejectRequest(*request_)) { 492 !throttling_entry_->ShouldRejectRequest(*request_)) {
493 rv = transaction_->Start( 493 rv = transaction_->Start(
494 &request_info_, start_callback_, request_->net_log()); 494 &request_info_, start_callback_, request_->net_log());
495 start_time_ = base::TimeTicks::Now(); 495 start_time_ = base::TimeTicks::Now();
496 } else { 496 } else {
497 // Special error code for the exponential back-off module. 497 // Special error code for the exponential back-off module.
498 rv = ERR_TEMPORARILY_THROTTLED; 498 rv = ERR_TEMPORARILY_THROTTLED;
499 } 499 }
500 } 500 }
501 } 501 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 852 }
853 } 853 }
854 854
855 if (result == OK) { 855 if (result == OK) {
856 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); 856 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders();
857 if (network_delegate()) { 857 if (network_delegate()) {
858 // Note that |this| may not be deleted until 858 // Note that |this| may not be deleted until
859 // |on_headers_received_callback_| or 859 // |on_headers_received_callback_| or
860 // |NetworkDelegate::URLRequestDestroyed()| has been called. 860 // |NetworkDelegate::URLRequestDestroyed()| has been called.
861 int error = network_delegate()->NotifyHeadersReceived( 861 int error = network_delegate()->NotifyHeadersReceived(
862 request_, on_headers_received_callback_, 862 request_,
863 headers, &override_response_headers_); 863 on_headers_received_callback_,
864 headers.get(),
865 &override_response_headers_);
864 if (error != net::OK) { 866 if (error != net::OK) {
865 if (error == net::ERR_IO_PENDING) { 867 if (error == net::ERR_IO_PENDING) {
866 awaiting_callback_ = true; 868 awaiting_callback_ = true;
867 SetBlockedOnDelegate(); 869 SetBlockedOnDelegate();
868 } else { 870 } else {
869 std::string source("delegate"); 871 std::string source("delegate");
870 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 872 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
871 NetLog::StringCallback("source", 873 NetLog::StringCallback("source",
872 &source)); 874 &source));
873 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error)); 875 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error));
(...skipping 11 matching lines...) Expand all
885 const URLRequestContext* context = request_->context(); 887 const URLRequestContext* context = request_->context();
886 const bool fatal = context->transport_security_state() && 888 const bool fatal = context->transport_security_state() &&
887 context->transport_security_state()->GetDomainState( 889 context->transport_security_state()->GetDomainState(
888 request_info_.url.host(), 890 request_info_.url.host(),
889 SSLConfigService::IsSNIAvailable(context->ssl_config_service()), 891 SSLConfigService::IsSNIAvailable(context->ssl_config_service()),
890 &domain_state) && 892 &domain_state) &&
891 domain_state.ShouldSSLErrorsBeFatal(); 893 domain_state.ShouldSSLErrorsBeFatal();
892 NotifySSLCertificateError(transaction_->GetResponseInfo()->ssl_info, fatal); 894 NotifySSLCertificateError(transaction_->GetResponseInfo()->ssl_info, fatal);
893 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { 895 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
894 NotifyCertificateRequested( 896 NotifyCertificateRequested(
895 transaction_->GetResponseInfo()->cert_request_info); 897 transaction_->GetResponseInfo()->cert_request_info.get());
896 } else { 898 } else {
897 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); 899 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result));
898 } 900 }
899 } 901 }
900 902
901 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { 903 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) {
902 SetUnblockedOnDelegate(); 904 SetUnblockedOnDelegate();
903 awaiting_callback_ = false; 905 awaiting_callback_ = false;
904 906
905 // Check that there are no callbacks to already canceled requests. 907 // Check that there are no callbacks to already canceled requests.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 985
984 return GetResponseHeaders()->GetCharset(charset); 986 return GetResponseHeaders()->GetCharset(charset);
985 } 987 }
986 988
987 void URLRequestHttpJob::GetResponseInfo(HttpResponseInfo* info) { 989 void URLRequestHttpJob::GetResponseInfo(HttpResponseInfo* info) {
988 DCHECK(request_); 990 DCHECK(request_);
989 DCHECK(transaction_.get()); 991 DCHECK(transaction_.get());
990 992
991 if (response_info_) { 993 if (response_info_) {
992 *info = *response_info_; 994 *info = *response_info_;
993 if (override_response_headers_) 995 if (override_response_headers_.get())
994 info->headers = override_response_headers_; 996 info->headers = override_response_headers_;
995 } 997 }
996 } 998 }
997 999
998 void URLRequestHttpJob::GetLoadTimingInfo( 1000 void URLRequestHttpJob::GetLoadTimingInfo(
999 LoadTimingInfo* load_timing_info) const { 1001 LoadTimingInfo* load_timing_info) const {
1000 // If haven't made it far enough to receive any headers, don't return 1002 // If haven't made it far enough to receive any headers, don't return
1001 // anything. This makes for more consistent behavior in the case of errors. 1003 // anything. This makes for more consistent behavior in the case of errors.
1002 if (!transaction_ || receive_headers_end_.is_null()) 1004 if (!transaction_ || receive_headers_end_.is_null())
1003 return; 1005 return;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 if (reason == FINISHED) { 1473 if (reason == FINISHED) {
1472 request_->set_received_response_content_length(prefilter_bytes_read()); 1474 request_->set_received_response_content_length(prefilter_bytes_read());
1473 RecordCompressionHistograms(); 1475 RecordCompressionHistograms();
1474 } 1476 }
1475 } 1477 }
1476 1478
1477 HttpResponseHeaders* URLRequestHttpJob::GetResponseHeaders() const { 1479 HttpResponseHeaders* URLRequestHttpJob::GetResponseHeaders() const {
1478 DCHECK(transaction_.get()); 1480 DCHECK(transaction_.get());
1479 DCHECK(transaction_->GetResponseInfo()); 1481 DCHECK(transaction_->GetResponseInfo());
1480 return override_response_headers_.get() ? 1482 return override_response_headers_.get() ?
1481 override_response_headers_ : 1483 override_response_headers_.get() :
1482 transaction_->GetResponseInfo()->headers; 1484 transaction_->GetResponseInfo()->headers.get();
1483 } 1485 }
1484 1486
1485 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1487 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1486 awaiting_callback_ = false; 1488 awaiting_callback_ = false;
1487 } 1489 }
1488 1490
1489 void URLRequestHttpJob::OnDetachRequest() { 1491 void URLRequestHttpJob::OnDetachRequest() {
1490 http_transaction_delegate_->OnDetachRequest(); 1492 http_transaction_delegate_->OnDetachRequest();
1491 } 1493 }
1492 1494
1493 } // namespace net 1495 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_ftp_job.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698