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

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: Added tests and cleaned up code. Created 4 years, 5 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 600
601 void HttpNetworkTransaction::OnQuicBroken() { 601 void HttpNetworkTransaction::OnQuicBroken() {
602 net_error_details_.quic_broken = true; 602 net_error_details_.quic_broken = true;
603 } 603 }
604 604
605 void HttpNetworkTransaction::GetConnectionAttempts( 605 void HttpNetworkTransaction::GetConnectionAttempts(
606 ConnectionAttempts* out) const { 606 ConnectionAttempts* out) const {
607 *out = connection_attempts_; 607 *out = connection_attempts_;
608 } 608 }
609 609
610 void HttpNetworkTransaction::OnThrottleStateChanged() { 610 void HttpNetworkTransaction::OnThrottleStateChanged(
611 NetworkThrottleManager::Throttle* throttle) {
611 // TODO(rdsmith): This DCHECK is dependent on the only transition 612 // TODO(rdsmith): This DCHECK is dependent on the only transition
612 // being from throttled->unthrottled. That is true right now, but may not 613 // being from blocked->unblocked. That is true right now, but may not
613 // be so in the future. 614 // be so in the future.
614 DCHECK_EQ(STATE_THROTTLE_COMPLETE, next_state_); 615 DCHECK_EQ(STATE_THROTTLE_COMPLETE, next_state_);
615 616
616 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED); 617 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED);
617 618
618 DoLoop(OK); 619 DoLoop(OK);
619 } 620 }
620 621
621 bool HttpNetworkTransaction::IsSecureRequest() const { 622 bool HttpNetworkTransaction::IsSecureRequest() const {
622 return request_->url.SchemeIsCryptographic(); 623 return request_->url.SchemeIsCryptographic();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); 806 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
806 807
807 return rv; 808 return rv;
808 } 809 }
809 810
810 int HttpNetworkTransaction::DoThrottle() { 811 int HttpNetworkTransaction::DoThrottle() {
811 throttle_ = session_->throttler()->CreateThrottle( 812 throttle_ = session_->throttler()->CreateThrottle(
812 this, priority_, (request_->load_flags & LOAD_IGNORE_LIMITS) != 0); 813 this, priority_, (request_->load_flags & LOAD_IGNORE_LIMITS) != 0);
813 next_state_ = STATE_THROTTLE_COMPLETE; 814 next_state_ = STATE_THROTTLE_COMPLETE;
814 815
815 if (throttle_->IsThrottled()) { 816 if (throttle_->IsBlocked()) {
816 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED); 817 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_THROTTLED);
817 return ERR_IO_PENDING; 818 return ERR_IO_PENDING;
818 } 819 }
819 820
820 return OK; 821 return OK;
821 } 822 }
822 823
823 int HttpNetworkTransaction::DoThrottleComplete() { 824 int HttpNetworkTransaction::DoThrottleComplete() {
824 DCHECK(throttle_); 825 DCHECK(throttle_);
825 DCHECK(!throttle_->IsThrottled()); 826 DCHECK(!throttle_->IsBlocked());
826 827
827 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM; 828 next_state_ = STATE_NOTIFY_BEFORE_CREATE_STREAM;
828 829
829 return OK; 830 return OK;
830 } 831 }
831 832
832 int HttpNetworkTransaction::DoNotifyBeforeCreateStream() { 833 int HttpNetworkTransaction::DoNotifyBeforeCreateStream() {
833 next_state_ = STATE_CREATE_STREAM; 834 next_state_ = STATE_CREATE_STREAM;
834 bool defer = false; 835 bool defer = false;
835 if (!before_network_start_callback_.is_null()) 836 if (!before_network_start_callback_.is_null())
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 DCHECK(stream_request_); 1849 DCHECK(stream_request_);
1849 1850
1850 // Since the transaction can restart with auth credentials, it may create a 1851 // Since the transaction can restart with auth credentials, it may create a
1851 // stream more than once. Accumulate all of the connection attempts across 1852 // stream more than once. Accumulate all of the connection attempts across
1852 // those streams by appending them to the vector: 1853 // those streams by appending them to the vector:
1853 for (const auto& attempt : stream_request_->connection_attempts()) 1854 for (const auto& attempt : stream_request_->connection_attempts())
1854 connection_attempts_.push_back(attempt); 1855 connection_attempts_.push_back(attempt);
1855 } 1856 }
1856 1857
1857 } // namespace net 1858 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698