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

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

Issue 10532121: NetLogEventParameter to Callback refactoring 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Update includes Created 8 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
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 void URLRequestHttpJob::NotifyBeforeSendHeadersCallback(int result) { 272 void URLRequestHttpJob::NotifyBeforeSendHeadersCallback(int result) {
273 SetUnblockedOnDelegate(); 273 SetUnblockedOnDelegate();
274 274
275 // Check that there are no callbacks to already canceled requests. 275 // Check that there are no callbacks to already canceled requests.
276 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); 276 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status());
277 277
278 if (result == OK) { 278 if (result == OK) {
279 StartTransactionInternal(); 279 StartTransactionInternal();
280 } else { 280 } else {
281 std::string source("delegate");
eroman 2012/06/13 18:48:11 (Same comment as earlier applies here).
281 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 282 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
282 make_scoped_refptr(new NetLogStringParameter("source", "delegate"))); 283 NetLog::StringCallback("source", &source));
283 NotifyCanceled(); 284 NotifyCanceled();
284 } 285 }
285 } 286 }
286 287
287 void URLRequestHttpJob::StartTransactionInternal() { 288 void URLRequestHttpJob::StartTransactionInternal() {
288 // NOTE: This method assumes that request_info_ is already setup properly. 289 // NOTE: This method assumes that request_info_ is already setup properly.
289 290
290 // If we already have a transaction, then we should restart the transaction 291 // If we already have a transaction, then we should restart the transaction
291 // with auth provided by auth_credentials_. 292 // with auth provided by auth_credentials_.
292 293
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // We may have been canceled while retrieving cookies. 469 // We may have been canceled while retrieving cookies.
469 if (GetStatus().is_success()) { 470 if (GetStatus().is_success()) {
470 StartTransaction(); 471 StartTransaction();
471 } else { 472 } else {
472 NotifyCanceled(); 473 NotifyCanceled();
473 } 474 }
474 } 475 }
475 476
476 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { 477 void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) {
477 if (result != net::OK) { 478 if (result != net::OK) {
479 std::string source("delegate");
eroman 2012/06/13 18:48:11 Ditto.
478 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 480 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
479 make_scoped_refptr(new NetLogStringParameter("source", "delegate"))); 481 NetLog::StringCallback("source", &source));
480 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); 482 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result));
481 return; 483 return;
482 } 484 }
483 485
484 DCHECK(transaction_.get()); 486 DCHECK(transaction_.get());
485 487
486 const HttpResponseInfo* response_info = transaction_->GetResponseInfo(); 488 const HttpResponseInfo* response_info = transaction_->GetResponseInfo();
487 DCHECK(response_info); 489 DCHECK(response_info);
488 490
489 response_cookies_.clear(); 491 response_cookies_.clear();
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 // Note that |this| may not be deleted until 673 // Note that |this| may not be deleted until
672 // |on_headers_received_callback_| or 674 // |on_headers_received_callback_| or
673 // |NetworkDelegate::URLRequestDestroyed()| has been called. 675 // |NetworkDelegate::URLRequestDestroyed()| has been called.
674 int error = context->network_delegate()-> 676 int error = context->network_delegate()->
675 NotifyHeadersReceived(request_, on_headers_received_callback_, 677 NotifyHeadersReceived(request_, on_headers_received_callback_,
676 headers, &override_response_headers_); 678 headers, &override_response_headers_);
677 if (error != net::OK) { 679 if (error != net::OK) {
678 if (error == net::ERR_IO_PENDING) { 680 if (error == net::ERR_IO_PENDING) {
679 awaiting_callback_ = true; 681 awaiting_callback_ = true;
680 request_->net_log().BeginEvent( 682 request_->net_log().BeginEvent(
681 NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); 683 NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
682 } else { 684 } else {
685 std::string source("delegate");
eroman 2012/06/13 18:48:11 ditto.
683 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED, 686 request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
684 make_scoped_refptr( 687 NetLog::StringCallback("source",
685 new NetLogStringParameter("source", "delegate"))); 688 &source));
686 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error)); 689 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, error));
687 } 690 }
688 return; 691 return;
689 } 692 }
690 } 693 }
691 694
692 SaveCookiesAndNotifyHeadersComplete(net::OK); 695 SaveCookiesAndNotifyHeadersComplete(net::OK);
693 } else if (IsCertificateError(result)) { 696 } else if (IsCertificateError(result)) {
694 // We encountered an SSL certificate error. Ask our delegate to decide 697 // We encountered an SSL certificate error. Ask our delegate to decide
695 // what we should do. 698 // what we should do.
696 699
697 TransportSecurityState::DomainState domain_state; 700 TransportSecurityState::DomainState domain_state;
698 const URLRequestContext* context = request_->context(); 701 const URLRequestContext* context = request_->context();
699 const bool fatal = 702 const bool fatal =
700 context->transport_security_state() && 703 context->transport_security_state() &&
701 context->transport_security_state()->GetDomainState( 704 context->transport_security_state()->GetDomainState(
702 request_info_.url.host(), 705 request_info_.url.host(),
703 SSLConfigService::IsSNIAvailable(context->ssl_config_service()), 706 SSLConfigService::IsSNIAvailable(context->ssl_config_service()),
704 &domain_state); 707 &domain_state);
705 NotifySSLCertificateError(transaction_->GetResponseInfo()->ssl_info, fatal); 708 NotifySSLCertificateError(transaction_->GetResponseInfo()->ssl_info, fatal);
706 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { 709 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
707 NotifyCertificateRequested( 710 NotifyCertificateRequested(
708 transaction_->GetResponseInfo()->cert_request_info); 711 transaction_->GetResponseInfo()->cert_request_info);
709 } else { 712 } else {
710 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); 713 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result));
711 } 714 }
712 } 715 }
713 716
714 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) { 717 void URLRequestHttpJob::OnHeadersReceivedCallback(int result) {
715 request_->net_log().EndEvent( 718 request_->net_log().EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
716 NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL);
717 awaiting_callback_ = false; 719 awaiting_callback_ = false;
718 720
719 // Check that there are no callbacks to already canceled requests. 721 // Check that there are no callbacks to already canceled requests.
720 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); 722 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status());
721 723
722 SaveCookiesAndNotifyHeadersComplete(result); 724 SaveCookiesAndNotifyHeadersComplete(result);
723 } 725 }
724 726
725 void URLRequestHttpJob::OnReadCompleted(int result) { 727 void URLRequestHttpJob::OnReadCompleted(int result) {
726 read_in_progress_ = false; 728 read_in_progress_ = false;
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 return override_response_headers_.get() ? 1389 return override_response_headers_.get() ?
1388 override_response_headers_ : 1390 override_response_headers_ :
1389 transaction_->GetResponseInfo()->headers; 1391 transaction_->GetResponseInfo()->headers;
1390 } 1392 }
1391 1393
1392 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1394 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1393 awaiting_callback_ = false; 1395 awaiting_callback_ = false;
1394 } 1396 }
1395 1397
1396 } // namespace net 1398 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698