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

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 and substantially simplified state storage. Created 4 years, 3 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 579
580 void HttpNetworkTransaction::OnQuicBroken() { 580 void HttpNetworkTransaction::OnQuicBroken() {
581 net_error_details_.quic_broken = true; 581 net_error_details_.quic_broken = true;
582 } 582 }
583 583
584 void HttpNetworkTransaction::GetConnectionAttempts( 584 void HttpNetworkTransaction::GetConnectionAttempts(
585 ConnectionAttempts* out) const { 585 ConnectionAttempts* out) const {
586 *out = connection_attempts_; 586 *out = connection_attempts_;
587 } 587 }
588 588
589 void HttpNetworkTransaction::OnThrottleStateChanged() { 589 void HttpNetworkTransaction::OnThrottleStateChanged(
590 NetworkThrottleManager::Throttle* throttle) {
590 // TODO(rdsmith): This DCHECK is dependent on the only transition 591 // TODO(rdsmith): This DCHECK is dependent on the only transition
591 // being from throttled->unthrottled. That is true right now, but may not 592 // being from blocked->unblocked. That is true right now, but may not
592 // be so in the future. 593 // be so in the future.
593 DCHECK_EQ(STATE_THROTTLE_COMPLETE, next_state_); 594 DCHECK_EQ(STATE_THROTTLE_COMPLETE, next_state_);
594 595
595 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED); 596 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED);
596 597
597 DoLoop(OK); 598 DoLoop(OK);
598 } 599 }
599 600
600 bool HttpNetworkTransaction::IsSecureRequest() const { 601 bool HttpNetworkTransaction::IsSecureRequest() const {
601 return request_->url.SchemeIsCryptographic(); 602 return request_->url.SchemeIsCryptographic();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); 785 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
785 786
786 return rv; 787 return rv;
787 } 788 }
788 789
789 int HttpNetworkTransaction::DoThrottle() { 790 int HttpNetworkTransaction::DoThrottle() {
790 throttle_ = session_->throttler()->CreateThrottle( 791 throttle_ = session_->throttler()->CreateThrottle(
791 this, priority_, (request_->load_flags & LOAD_IGNORE_LIMITS) != 0); 792 this, priority_, (request_->load_flags & LOAD_IGNORE_LIMITS) != 0);
792 next_state_ = STATE_THROTTLE_COMPLETE; 793 next_state_ = STATE_THROTTLE_COMPLETE;
793 794
794 if (throttle_->IsThrottled()) { 795 if (throttle_->IsBlocked()) {
795 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED); 796 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED);
796 return ERR_IO_PENDING; 797 return ERR_IO_PENDING;
797 } 798 }
798 799
799 return OK; 800 return OK;
800 } 801 }
801 802
802 int HttpNetworkTransaction::DoThrottleComplete() { 803 int HttpNetworkTransaction::DoThrottleComplete() {
803 DCHECK(throttle_); 804 DCHECK(throttle_);
804 DCHECK(!throttle_->IsThrottled()); 805 DCHECK(!throttle_->IsBlocked());
805 806
806 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM; 807 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM;
807 808
808 return OK; 809 return OK;
809 } 810 }
810 811
811 int HttpNetworkTransaction::DoNotifyBeforeCreateStream() { 812 int HttpNetworkTransaction::DoNotifyBeforeCreateStream() {
812 next_state_ = STATE_CREATE_STREAM; 813 next_state_ = STATE_CREATE_STREAM;
813 bool defer = false; 814 bool defer = false;
814 if (!before_network_start_callback_.is_null()) 815 if (!before_network_start_callback_.is_null())
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 DCHECK(stream_request_); 1723 DCHECK(stream_request_);
1723 1724
1724 // Since the transaction can restart with auth credentials, it may create a 1725 // Since the transaction can restart with auth credentials, it may create a
1725 // stream more than once. Accumulate all of the connection attempts across 1726 // stream more than once. Accumulate all of the connection attempts across
1726 // those streams by appending them to the vector: 1727 // those streams by appending them to the vector:
1727 for (const auto& attempt : stream_request_->connection_attempts()) 1728 for (const auto& attempt : stream_request_->connection_attempts())
1728 connection_attempts_.push_back(attempt); 1729 connection_attempts_.push_back(attempt);
1729 } 1730 }
1730 1731
1731 } // namespace net 1732 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698