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

Side by Side Diff: net/http/http_network_transaction.cc

Issue 2130493002: Implement THROTTLED priority semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NetworkStreamThrottler
Patch Set: Incorporated comments, simplified timing code. Created 4 years, 2 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
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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 573
574 void HttpNetworkTransaction::OnQuicBroken() { 574 void HttpNetworkTransaction::OnQuicBroken() {
575 net_error_details_.quic_broken = true; 575 net_error_details_.quic_broken = true;
576 } 576 }
577 577
578 void HttpNetworkTransaction::GetConnectionAttempts( 578 void HttpNetworkTransaction::GetConnectionAttempts(
579 ConnectionAttempts* out) const { 579 ConnectionAttempts* out) const {
580 *out = connection_attempts_; 580 *out = connection_attempts_;
581 } 581 }
582 582
583 void HttpNetworkTransaction::OnThrottleStateChanged() { 583 void HttpNetworkTransaction::OnThrottleUnblocked(
584 NetworkThrottleManager::Throttle* throttle) {
584 // TODO(rdsmith): This DCHECK is dependent on the only transition 585 // TODO(rdsmith): This DCHECK is dependent on the only transition
585 // being from throttled->unthrottled. That is true right now, but may not 586 // being from blocked->unblocked. That is true right now, but may not
586 // be so in the future. 587 // be so in the future.
587 DCHECK_EQ(STATE_THROTTLE_COMPLETE, next_state_); 588 DCHECK_EQ(STATE_THROTTLE_COMPLETE, next_state_);
588 589
589 net_log_.EndEvent(NetLogEventType::HTTP_TRANSACTION_THROTTLED); 590 net_log_.EndEvent(NetLogEventType::HTTP_TRANSACTION_THROTTLED);
590 591
591 DoLoop(OK); 592 DoLoop(OK);
592 } 593 }
593 594
594 bool HttpNetworkTransaction::IsSecureRequest() const { 595 bool HttpNetworkTransaction::IsSecureRequest() const {
595 return request_->url.SchemeIsCryptographic(); 596 return request_->url.SchemeIsCryptographic();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 default: 774 default:
774 NOTREACHED() << "bad state"; 775 NOTREACHED() << "bad state";
775 rv = ERR_FAILED; 776 rv = ERR_FAILED;
776 break; 777 break;
777 } 778 }
778 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); 779 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
779 780
780 return rv; 781 return rv;
781 } 782 }
782 783
783 int HttpNetworkTransaction::DoThrottle() { 784 int HttpNetworkTransaction::DoThrottle() {
mmenke 2016/10/07 16:51:47 DCHECK(!throttle_)?
Randy Smith (Not in Mondays) 2016/10/11 21:43:35 Done.
784 throttle_ = session_->throttler()->CreateThrottle( 785 throttle_ = session_->throttler()->CreateThrottle(
785 this, priority_, (request_->load_flags & LOAD_IGNORE_LIMITS) != 0); 786 this, priority_, (request_->load_flags & LOAD_IGNORE_LIMITS) != 0);
786 next_state_ = STATE_THROTTLE_COMPLETE; 787 next_state_ = STATE_THROTTLE_COMPLETE;
787 788
788 if (throttle_->IsThrottled()) { 789 if (throttle_->IsBlocked()) {
789 net_log_.BeginEvent(NetLogEventType::HTTP_TRANSACTION_THROTTLED); 790 net_log_.BeginEvent(NetLogEventType::HTTP_TRANSACTION_THROTTLED);
790 return ERR_IO_PENDING; 791 return ERR_IO_PENDING;
791 } 792 }
792 793
793 return OK; 794 return OK;
794 } 795 }
795 796
796 int HttpNetworkTransaction::DoThrottleComplete() { 797 int HttpNetworkTransaction::DoThrottleComplete() {
797 DCHECK(throttle_); 798 DCHECK(throttle_);
798 DCHECK(!throttle_->IsThrottled()); 799 DCHECK(!throttle_->IsBlocked());
799 800
800 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM; 801 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM;
801 802
802 return OK; 803 return OK;
803 } 804 }
804 805
805 int HttpNetworkTransaction::DoNotifyBeforeCreateStream() { 806 int HttpNetworkTransaction::DoNotifyBeforeCreateStream() {
806 next_state_ = STATE_CREATE_STREAM; 807 next_state_ = STATE_CREATE_STREAM;
807 bool defer = false; 808 bool defer = false;
808 if (!before_network_start_callback_.is_null()) 809 if (!before_network_start_callback_.is_null())
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 DCHECK(stream_request_); 1684 DCHECK(stream_request_);
1684 1685
1685 // Since the transaction can restart with auth credentials, it may create a 1686 // Since the transaction can restart with auth credentials, it may create a
1686 // stream more than once. Accumulate all of the connection attempts across 1687 // stream more than once. Accumulate all of the connection attempts across
1687 // those streams by appending them to the vector: 1688 // those streams by appending them to the vector:
1688 for (const auto& attempt : stream_request_->connection_attempts()) 1689 for (const auto& attempt : stream_request_->connection_attempts())
1689 connection_attempts_.push_back(attempt); 1690 connection_attempts_.push_back(attempt);
1690 } 1691 }
1691 1692
1692 } // namespace net 1693 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698