Chromium Code Reviews| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 127 |
| 128 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, | 128 void URLRequest::Delegate::OnSSLCertificateError(URLRequest* request, |
| 129 const SSLInfo& ssl_info, | 129 const SSLInfo& ssl_info, |
| 130 bool is_hsts_ok) { | 130 bool is_hsts_ok) { |
| 131 request->Cancel(); | 131 request->Cancel(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 /////////////////////////////////////////////////////////////////////////////// | 134 /////////////////////////////////////////////////////////////////////////////// |
| 135 // URLRequest | 135 // URLRequest |
| 136 | 136 |
| 137 // TODO(shalev): Get rid of this constructor in favour of the one below it. | |
| 137 URLRequest::URLRequest(const GURL& url, | 138 URLRequest::URLRequest(const GURL& url, |
| 138 Delegate* delegate, | 139 Delegate* delegate, |
| 139 const URLRequestContext* context) | 140 const URLRequestContext* context) |
| 140 : context_(context), | 141 : context_(context), |
| 142 network_delegate_(context->network_delegate()), | |
| 141 net_log_(BoundNetLog::Make(context->net_log(), | 143 net_log_(BoundNetLog::Make(context->net_log(), |
| 142 NetLog::SOURCE_URL_REQUEST)), | 144 NetLog::SOURCE_URL_REQUEST)), |
| 143 url_chain_(1, url), | 145 url_chain_(1, url), |
| 146 method_("GET"), | |
| 147 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), | |
| 148 load_flags_(LOAD_NORMAL), | |
| 149 delegate_(delegate), | |
| 150 is_pending_(false), | |
| 151 redirect_limit_(kMaxRedirects), | |
| 152 final_upload_progress_(0), | |
| 153 priority_(LOWEST), | |
| 154 identifier_(GenerateURLRequestIdentifier()), | |
| 155 blocked_on_delegate_(false), | |
| 156 ALLOW_THIS_IN_INITIALIZER_LIST(before_request_callback_( | |
| 157 base::Bind(&URLRequest::BeforeRequestComplete, | |
| 158 base::Unretained(this)))), | |
| 159 has_notified_completion_(false), | |
| 160 creation_time_(base::TimeTicks::Now()) { | |
| 161 SIMPLE_STATS_COUNTER("URLRequestCount"); | |
| 162 | |
| 163 // Sanity check out environment. | |
| 164 DCHECK(MessageLoop::current()) << "The current MessageLoop must exist"; | |
| 165 | |
| 166 DCHECK(MessageLoop::current()->IsType(MessageLoop::TYPE_IO)) << "" | |
| 167 "The current MessageLoop must be TYPE_IO"; | |
| 168 | |
| 169 CHECK(context); | |
| 170 context->url_requests()->insert(this); | |
| 171 | |
| 172 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE); | |
| 173 } | |
| 174 | |
| 175 URLRequest::URLRequest(const GURL& url, | |
| 176 Delegate* delegate, | |
| 177 const URLRequestContext* context, | |
| 178 NetworkDelegate* network_delegate) | |
| 179 : context_(context), | |
| 180 network_delegate_(network_delegate), | |
| 181 net_log_(BoundNetLog::Make(context->net_log(), | |
| 182 NetLog::SOURCE_URL_REQUEST)), | |
| 183 url_chain_(1, url), | |
| 144 method_("GET"), | 184 method_("GET"), |
| 145 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), | 185 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), |
| 146 load_flags_(LOAD_NORMAL), | 186 load_flags_(LOAD_NORMAL), |
| 147 delegate_(delegate), | 187 delegate_(delegate), |
| 148 is_pending_(false), | 188 is_pending_(false), |
| 149 redirect_limit_(kMaxRedirects), | 189 redirect_limit_(kMaxRedirects), |
| 150 final_upload_progress_(0), | 190 final_upload_progress_(0), |
| 151 priority_(LOWEST), | 191 priority_(LOWEST), |
| 152 identifier_(GenerateURLRequestIdentifier()), | 192 identifier_(GenerateURLRequestIdentifier()), |
| 153 blocked_on_delegate_(false), | 193 blocked_on_delegate_(false), |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 166 | 206 |
| 167 CHECK(context); | 207 CHECK(context); |
| 168 context->url_requests()->insert(this); | 208 context->url_requests()->insert(this); |
| 169 | 209 |
| 170 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE); | 210 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE); |
| 171 } | 211 } |
| 172 | 212 |
| 173 URLRequest::~URLRequest() { | 213 URLRequest::~URLRequest() { |
| 174 Cancel(); | 214 Cancel(); |
| 175 | 215 |
| 176 if (context_->network_delegate()) { | 216 if (network_delegate_) { |
| 177 context_->network_delegate()->NotifyURLRequestDestroyed(this); | 217 network_delegate_->NotifyURLRequestDestroyed(this); |
| 178 if (job_) | 218 if (job_) |
| 179 job_->NotifyURLRequestDestroyed(); | 219 job_->NotifyURLRequestDestroyed(); |
| 180 } | 220 } |
| 181 | 221 |
| 182 if (job_) | 222 if (job_) |
| 183 OrphanJob(); | 223 OrphanJob(); |
| 184 | 224 |
| 185 int deleted = context_->url_requests()->erase(this); | 225 int deleted = context_->url_requests()->erase(this); |
| 186 CHECK_EQ(1, deleted); | 226 CHECK_EQ(1, deleted); |
| 187 | 227 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { | 446 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { |
| 407 DCHECK(!is_pending_); | 447 DCHECK(!is_pending_); |
| 408 referrer_policy_ = referrer_policy; | 448 referrer_policy_ = referrer_policy; |
| 409 } | 449 } |
| 410 | 450 |
| 411 void URLRequest::set_delegate(Delegate* delegate) { | 451 void URLRequest::set_delegate(Delegate* delegate) { |
| 412 delegate_ = delegate; | 452 delegate_ = delegate; |
| 413 } | 453 } |
| 414 | 454 |
| 415 void URLRequest::Start() { | 455 void URLRequest::Start() { |
| 456 DCHECK(network_delegate_ == context_->network_delegate()); | |
|
mmenke
2012/08/24 14:32:00
nit: DCHECK_EQ
shalev
2012/08/24 15:36:40
Done.
| |
| 457 | |
| 416 g_url_requests_started = true; | 458 g_url_requests_started = true; |
| 417 response_info_.request_time = Time::Now(); | 459 response_info_.request_time = Time::Now(); |
| 418 | 460 |
| 419 // Only notify the delegate for the initial request. | 461 // Only notify the delegate for the initial request. |
| 420 if (context_->network_delegate()) { | 462 if (network_delegate_) { |
| 421 int error = context_->network_delegate()->NotifyBeforeURLRequest( | 463 int error = network_delegate_->NotifyBeforeURLRequest( |
| 422 this, before_request_callback_, &delegate_redirect_url_); | 464 this, before_request_callback_, &delegate_redirect_url_); |
| 423 if (error == net::ERR_IO_PENDING) { | 465 if (error == net::ERR_IO_PENDING) { |
| 424 // Paused on the delegate, will invoke |before_request_callback_| later. | 466 // Paused on the delegate, will invoke |before_request_callback_| later. |
| 425 SetBlockedOnDelegate(); | 467 SetBlockedOnDelegate(); |
| 426 } else { | 468 } else { |
| 427 BeforeRequestComplete(error); | 469 BeforeRequestComplete(error); |
| 428 } | 470 } |
| 429 return; | 471 return; |
| 430 } | 472 } |
| 431 | 473 |
| 432 StartJob(URLRequestJobManager::GetInstance()->CreateJob( | 474 StartJob(URLRequestJobManager::GetInstance()->CreateJob( |
| 433 this, context_->network_delegate())); | 475 this, network_delegate_)); |
| 434 } | 476 } |
| 435 | 477 |
| 436 /////////////////////////////////////////////////////////////////////////////// | 478 /////////////////////////////////////////////////////////////////////////////// |
| 437 | 479 |
| 438 void URLRequest::BeforeRequestComplete(int error) { | 480 void URLRequest::BeforeRequestComplete(int error) { |
| 439 DCHECK(!job_); | 481 DCHECK(!job_); |
| 440 DCHECK_NE(ERR_IO_PENDING, error); | 482 DCHECK_NE(ERR_IO_PENDING, error); |
| 483 DCHECK(network_delegate_ == context_->network_delegate()); | |
|
mmenke
2012/08/24 14:32:00
DCHECK_EQ
shalev
2012/08/24 15:36:40
Done.
| |
| 441 | 484 |
| 442 // Check that there are no callbacks to already canceled requests. | 485 // Check that there are no callbacks to already canceled requests. |
| 443 DCHECK_NE(URLRequestStatus::CANCELED, status_.status()); | 486 DCHECK_NE(URLRequestStatus::CANCELED, status_.status()); |
| 444 | 487 |
| 445 if (blocked_on_delegate_) | 488 if (blocked_on_delegate_) |
| 446 SetUnblockedOnDelegate(); | 489 SetUnblockedOnDelegate(); |
| 447 | 490 |
| 448 if (error != OK) { | 491 if (error != OK) { |
| 449 std::string source("delegate"); | 492 std::string source("delegate"); |
| 450 net_log_.AddEvent(NetLog::TYPE_CANCELLED, | 493 net_log_.AddEvent(NetLog::TYPE_CANCELLED, |
| 451 NetLog::StringCallback("source", &source)); | 494 NetLog::StringCallback("source", &source)); |
| 452 StartJob(new URLRequestErrorJob(this, context_->network_delegate(), error)); | 495 StartJob(new URLRequestErrorJob(this, network_delegate_, error)); |
| 453 } else if (!delegate_redirect_url_.is_empty()) { | 496 } else if (!delegate_redirect_url_.is_empty()) { |
| 454 GURL new_url; | 497 GURL new_url; |
| 455 new_url.Swap(&delegate_redirect_url_); | 498 new_url.Swap(&delegate_redirect_url_); |
| 456 | 499 |
| 457 URLRequestRedirectJob* job = new URLRequestRedirectJob( | 500 URLRequestRedirectJob* job = new URLRequestRedirectJob( |
| 458 this, context_->network_delegate(), new_url); | 501 this, network_delegate_, new_url); |
| 459 // Use status code 307 to preserve the method, so POST requests work. | 502 // Use status code 307 to preserve the method, so POST requests work. |
| 460 job->set_redirect_code( | 503 job->set_redirect_code( |
| 461 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT); | 504 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT); |
| 462 StartJob(job); | 505 StartJob(job); |
| 463 } else { | 506 } else { |
| 464 StartJob(URLRequestJobManager::GetInstance()->CreateJob( | 507 StartJob(URLRequestJobManager::GetInstance()->CreateJob( |
| 465 this, context_->network_delegate())); | 508 this, network_delegate_)); |
| 466 } | 509 } |
| 467 } | 510 } |
| 468 | 511 |
| 469 void URLRequest::StartJob(URLRequestJob* job) { | 512 void URLRequest::StartJob(URLRequestJob* job) { |
| 470 DCHECK(!is_pending_); | 513 DCHECK(!is_pending_); |
| 471 DCHECK(!job_); | 514 DCHECK(!job_); |
| 472 | 515 |
| 473 net_log_.BeginEvent( | 516 net_log_.BeginEvent( |
| 474 NetLog::TYPE_URL_REQUEST_START_JOB, | 517 NetLog::TYPE_URL_REQUEST_START_JOB, |
| 475 base::Bind(&NetLogURLRequestStartCallback, | 518 base::Bind(&NetLogURLRequestStartCallback, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 489 // TODO(brettw) this may cause NotifyDone to be sent synchronously, | 532 // TODO(brettw) this may cause NotifyDone to be sent synchronously, |
| 490 // we probably don't want this: they should be sent asynchronously so | 533 // we probably don't want this: they should be sent asynchronously so |
| 491 // the caller does not get reentered. | 534 // the caller does not get reentered. |
| 492 job_->Start(); | 535 job_->Start(); |
| 493 } | 536 } |
| 494 | 537 |
| 495 void URLRequest::Restart() { | 538 void URLRequest::Restart() { |
| 496 // Should only be called if the original job didn't make any progress. | 539 // Should only be called if the original job didn't make any progress. |
| 497 DCHECK(job_ && !job_->has_response_started()); | 540 DCHECK(job_ && !job_->has_response_started()); |
| 498 RestartWithJob(URLRequestJobManager::GetInstance()->CreateJob( | 541 RestartWithJob(URLRequestJobManager::GetInstance()->CreateJob( |
| 499 this, context_->network_delegate())); | 542 this, network_delegate_)); |
| 500 } | 543 } |
| 501 | 544 |
| 502 void URLRequest::RestartWithJob(URLRequestJob *job) { | 545 void URLRequest::RestartWithJob(URLRequestJob *job) { |
| 503 DCHECK(job->request() == this); | 546 DCHECK(job->request() == this); |
| 504 PrepareToRestart(); | 547 PrepareToRestart(); |
| 505 StartJob(job); | 548 StartJob(job); |
| 506 } | 549 } |
| 507 | 550 |
| 508 void URLRequest::Cancel() { | 551 void URLRequest::Cancel() { |
| 509 DoCancel(ERR_ABORTED, SSLInfo()); | 552 DoCancel(ERR_ABORTED, SSLInfo()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 | 628 |
| 586 void URLRequest::StopCaching() { | 629 void URLRequest::StopCaching() { |
| 587 DCHECK(job_); | 630 DCHECK(job_); |
| 588 job_->StopCaching(); | 631 job_->StopCaching(); |
| 589 } | 632 } |
| 590 | 633 |
| 591 void URLRequest::NotifyReceivedRedirect(const GURL& location, | 634 void URLRequest::NotifyReceivedRedirect(const GURL& location, |
| 592 bool* defer_redirect) { | 635 bool* defer_redirect) { |
| 593 URLRequestJob* job = | 636 URLRequestJob* job = |
| 594 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect( | 637 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect( |
| 595 this, context_->network_delegate(), location); | 638 this, network_delegate_, location); |
| 596 if (job) { | 639 if (job) { |
| 597 RestartWithJob(job); | 640 RestartWithJob(job); |
| 598 } else if (delegate_) { | 641 } else if (delegate_) { |
| 599 delegate_->OnReceivedRedirect(this, location, defer_redirect); | 642 delegate_->OnReceivedRedirect(this, location, defer_redirect); |
| 600 } | 643 } |
| 601 } | 644 } |
| 602 | 645 |
| 603 void URLRequest::NotifyResponseStarted() { | 646 void URLRequest::NotifyResponseStarted() { |
| 604 int net_error = OK; | 647 int net_error = OK; |
| 605 if (!status_.is_success()) | 648 if (!status_.is_success()) |
| 606 net_error = status_.error(); | 649 net_error = status_.error(); |
| 607 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_URL_REQUEST_START_JOB, | 650 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_URL_REQUEST_START_JOB, |
| 608 net_error); | 651 net_error); |
| 609 | 652 |
| 610 URLRequestJob* job = | 653 URLRequestJob* job = |
| 611 URLRequestJobManager::GetInstance()->MaybeInterceptResponse( | 654 URLRequestJobManager::GetInstance()->MaybeInterceptResponse( |
| 612 this, context_->network_delegate()); | 655 this, network_delegate_); |
| 613 if (job) { | 656 if (job) { |
| 614 RestartWithJob(job); | 657 RestartWithJob(job); |
| 615 } else { | 658 } else { |
| 616 if (delegate_) { | 659 if (delegate_) { |
| 617 // In some cases (e.g. an event was canceled), we might have sent the | 660 // In some cases (e.g. an event was canceled), we might have sent the |
| 618 // completion event and receive a NotifyResponseStarted() later. | 661 // completion event and receive a NotifyResponseStarted() later. |
| 619 if (!has_notified_completion_ && status_.is_success()) { | 662 if (!has_notified_completion_ && status_.is_success()) { |
| 620 if (context_->network_delegate()) | 663 if (network_delegate_) |
| 621 context_->network_delegate()->NotifyResponseStarted(this); | 664 network_delegate_->NotifyResponseStarted(this); |
| 622 } | 665 } |
| 623 | 666 |
| 624 // Notify in case the entire URL Request has been finished. | 667 // Notify in case the entire URL Request has been finished. |
| 625 if (!has_notified_completion_ && !status_.is_success()) | 668 if (!has_notified_completion_ && !status_.is_success()) |
| 626 NotifyRequestCompleted(); | 669 NotifyRequestCompleted(); |
| 627 | 670 |
| 628 delegate_->OnResponseStarted(this); | 671 delegate_->OnResponseStarted(this); |
| 629 // Nothing may appear below this line as OnResponseStarted may delete | 672 // Nothing may appear below this line as OnResponseStarted may delete |
| 630 // |this|. | 673 // |this|. |
| 631 } | 674 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 job_ = NULL; | 737 job_ = NULL; |
| 695 } | 738 } |
| 696 | 739 |
| 697 int URLRequest::Redirect(const GURL& location, int http_status_code) { | 740 int URLRequest::Redirect(const GURL& location, int http_status_code) { |
| 698 if (net_log_.IsLoggingAllEvents()) { | 741 if (net_log_.IsLoggingAllEvents()) { |
| 699 net_log_.AddEvent( | 742 net_log_.AddEvent( |
| 700 NetLog::TYPE_URL_REQUEST_REDIRECTED, | 743 NetLog::TYPE_URL_REQUEST_REDIRECTED, |
| 701 NetLog::StringCallback("location", &location.possibly_invalid_spec())); | 744 NetLog::StringCallback("location", &location.possibly_invalid_spec())); |
| 702 } | 745 } |
| 703 | 746 |
| 704 if (context_->network_delegate()) | 747 if (network_delegate_) |
| 705 context_->network_delegate()->NotifyBeforeRedirect(this, location); | 748 network_delegate_->NotifyBeforeRedirect(this, location); |
| 706 | 749 |
| 707 if (redirect_limit_ <= 0) { | 750 if (redirect_limit_ <= 0) { |
| 708 DVLOG(1) << "disallowing redirect: exceeds limit"; | 751 DVLOG(1) << "disallowing redirect: exceeds limit"; |
| 709 return ERR_TOO_MANY_REDIRECTS; | 752 return ERR_TOO_MANY_REDIRECTS; |
| 710 } | 753 } |
| 711 | 754 |
| 712 if (!location.is_valid()) | 755 if (!location.is_valid()) |
| 713 return ERR_INVALID_URL; | 756 return ERR_INVALID_URL; |
| 714 | 757 |
| 715 if (!job_->IsSafeRedirect(location)) { | 758 if (!job_->IsSafeRedirect(location)) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 *redirect_url = url.ReplaceComponents(replacements); | 831 *redirect_url = url.ReplaceComponents(replacements); |
| 789 return true; | 832 return true; |
| 790 } | 833 } |
| 791 return false; | 834 return false; |
| 792 } | 835 } |
| 793 | 836 |
| 794 void URLRequest::NotifyAuthRequired(AuthChallengeInfo* auth_info) { | 837 void URLRequest::NotifyAuthRequired(AuthChallengeInfo* auth_info) { |
| 795 NetworkDelegate::AuthRequiredResponse rv = | 838 NetworkDelegate::AuthRequiredResponse rv = |
| 796 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 839 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
| 797 auth_info_ = auth_info; | 840 auth_info_ = auth_info; |
| 798 if (context_->network_delegate()) { | 841 if (network_delegate_) { |
| 799 rv = context_->network_delegate()->NotifyAuthRequired( | 842 rv = network_delegate_->NotifyAuthRequired( |
| 800 this, | 843 this, |
| 801 *auth_info, | 844 *auth_info, |
| 802 base::Bind(&URLRequest::NotifyAuthRequiredComplete, | 845 base::Bind(&URLRequest::NotifyAuthRequiredComplete, |
| 803 base::Unretained(this)), | 846 base::Unretained(this)), |
| 804 &auth_credentials_); | 847 &auth_credentials_); |
| 805 } | 848 } |
| 806 | 849 |
| 807 if (rv == NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING) { | 850 if (rv == NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING) { |
| 808 SetBlockedOnDelegate(); | 851 SetBlockedOnDelegate(); |
| 809 } else { | 852 } else { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 } | 898 } |
| 856 | 899 |
| 857 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, | 900 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, |
| 858 bool fatal) { | 901 bool fatal) { |
| 859 if (delegate_) | 902 if (delegate_) |
| 860 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 903 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
| 861 } | 904 } |
| 862 | 905 |
| 863 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { | 906 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { |
| 864 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); | 907 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); |
| 865 if (context_->network_delegate()) { | 908 if (network_delegate_) { |
| 866 return context_->network_delegate()->CanGetCookies(*this, | 909 return network_delegate_->CanGetCookies(*this, cookie_list); |
| 867 cookie_list); | |
| 868 } | 910 } |
| 869 return g_default_can_use_cookies; | 911 return g_default_can_use_cookies; |
| 870 } | 912 } |
| 871 | 913 |
| 872 bool URLRequest::CanSetCookie(const std::string& cookie_line, | 914 bool URLRequest::CanSetCookie(const std::string& cookie_line, |
| 873 CookieOptions* options) const { | 915 CookieOptions* options) const { |
| 874 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); | 916 DCHECK(!(load_flags_ & LOAD_DO_NOT_SAVE_COOKIES)); |
| 875 if (context_->network_delegate()) { | 917 if (network_delegate_) { |
| 876 return context_->network_delegate()->CanSetCookie(*this, | 918 return network_delegate_->CanSetCookie(*this, cookie_line, options); |
| 877 cookie_line, | |
| 878 options); | |
| 879 } | 919 } |
| 880 return g_default_can_use_cookies; | 920 return g_default_can_use_cookies; |
| 881 } | 921 } |
| 882 | 922 |
| 883 | 923 |
| 884 void URLRequest::NotifyReadCompleted(int bytes_read) { | 924 void URLRequest::NotifyReadCompleted(int bytes_read) { |
| 885 // Notify in case the entire URL Request has been finished. | 925 // Notify in case the entire URL Request has been finished. |
| 886 if (bytes_read <= 0) | 926 if (bytes_read <= 0) |
| 887 NotifyRequestCompleted(); | 927 NotifyRequestCompleted(); |
| 888 | 928 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 899 } | 939 } |
| 900 | 940 |
| 901 void URLRequest::NotifyRequestCompleted() { | 941 void URLRequest::NotifyRequestCompleted() { |
| 902 // TODO(battre): Get rid of this check, according to willchan it should | 942 // TODO(battre): Get rid of this check, according to willchan it should |
| 903 // not be needed. | 943 // not be needed. |
| 904 if (has_notified_completion_) | 944 if (has_notified_completion_) |
| 905 return; | 945 return; |
| 906 | 946 |
| 907 is_pending_ = false; | 947 is_pending_ = false; |
| 908 has_notified_completion_ = true; | 948 has_notified_completion_ = true; |
| 909 if (context_->network_delegate()) | 949 if (network_delegate_) |
| 910 context_->network_delegate()->NotifyCompleted(this, job_ != NULL); | 950 network_delegate_->NotifyCompleted(this, job_ != NULL); |
| 911 } | 951 } |
| 912 | 952 |
| 913 void URLRequest::SetBlockedOnDelegate() { | 953 void URLRequest::SetBlockedOnDelegate() { |
| 914 blocked_on_delegate_ = true; | 954 blocked_on_delegate_ = true; |
| 915 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); | 955 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); |
| 916 } | 956 } |
| 917 | 957 |
| 918 void URLRequest::SetUnblockedOnDelegate() { | 958 void URLRequest::SetUnblockedOnDelegate() { |
| 919 if (!blocked_on_delegate_) | 959 if (!blocked_on_delegate_) |
| 920 return; | 960 return; |
| 921 blocked_on_delegate_ = false; | 961 blocked_on_delegate_ = false; |
| 922 load_state_param_.clear(); | 962 load_state_param_.clear(); |
| 923 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); | 963 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); |
| 924 } | 964 } |
| 925 | 965 |
| 926 void URLRequest::set_stack_trace(const base::debug::StackTrace& stack_trace) { | 966 void URLRequest::set_stack_trace(const base::debug::StackTrace& stack_trace) { |
| 927 base::debug::StackTrace* stack_trace_copy = | 967 base::debug::StackTrace* stack_trace_copy = |
| 928 new base::debug::StackTrace(NULL, 0); | 968 new base::debug::StackTrace(NULL, 0); |
| 929 *stack_trace_copy = stack_trace; | 969 *stack_trace_copy = stack_trace; |
| 930 stack_trace_.reset(stack_trace_copy); | 970 stack_trace_.reset(stack_trace_copy); |
| 931 } | 971 } |
| 932 | 972 |
| 933 const base::debug::StackTrace* URLRequest::stack_trace() const { | 973 const base::debug::StackTrace* URLRequest::stack_trace() const { |
| 934 return stack_trace_.get(); | 974 return stack_trace_.get(); |
| 935 } | 975 } |
| 936 | 976 |
| 937 } // namespace net | 977 } // namespace net |
| OLD | NEW |