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

Unified Diff: net/http/http_network_transaction.cc

Issue 1901533002: Implementation of network level throttler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction.cc
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 120436443e4128f972a61b6982c5d308275e4459..906a30a479b0a40c0e093e348ad19145ad352d1d 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -120,7 +120,8 @@ HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority,
next_state_(STATE_NONE),
establishing_tunnel_(false),
websocket_handshake_stream_base_create_helper_(NULL),
- net_error_details_() {
+ net_error_details_(),
+ throttle_(session->throttler()->CreateThrottle(priority)) {
mmenke 2016/04/18 14:57:55 Also, making this part of the HttpNetworkSession s
mmenke 2016/04/18 14:57:55 BUG: Needs load_flags & LOAD_IGNORE_LIMITS as an
Randy Smith (Not in Mondays) 2016/04/19 11:37:05 Hmmm. I'm not sure I see a lot of good alternativ
Randy Smith (Not in Mondays) 2016/04/19 11:37:05 Acknowledged.
mmenke 2016/04/19 13:52:10 I'll think a bit about it - this may be the best p
Randy Smith (Not in Mondays) 2016/04/20 21:57:38 Done.
session->ssl_config_service()->GetSSLConfig(&server_ssl_config_);
session->GetAlpnProtos(&server_ssl_config_.alpn_protos);
session->GetNpnProtos(&server_ssl_config_.npn_protos);
@@ -605,6 +606,15 @@ void HttpNetworkTransaction::GetConnectionAttempts(
*out = connection_attempts_;
}
+void HttpNetworkTransaction::OnThrottleStateChanged() {
+ // TODO(rdsmith): This DCHECK is dependent on the throttle state
+ // initializing as throttled only transition from throttled->unthrottled.
+ // That is true right now, but may not be so in the future.
+ DCHECK_EQ(STATE_NOTIFY_BEFORE_CREATE_STREAM, next_state_);
mmenke 2016/04/18 14:57:55 This seems fragile to me, as it requires a transac
Randy Smith (Not in Mondays) 2016/04/19 11:37:05 So I agree in the abstract, and am happy to change
mmenke 2016/04/19 13:52:10 It was actually more a comment about the correctne
Randy Smith (Not in Mondays) 2016/04/20 21:57:38 Done.
+
+ DoLoop(OK);
+}
+
bool HttpNetworkTransaction::IsSecureRequest() const {
return request_->url.SchemeIsCryptographic();
}
@@ -787,6 +797,11 @@ int HttpNetworkTransaction::DoLoop(int result) {
}
int HttpNetworkTransaction::DoNotifyBeforeCreateStream() {
+ // If this transaction is currently throttled, the throttler will notify
+ // when it is unthrottled through OnThrottleStateChanged().
+ if (throttle_->throttled())
+ return ERR_IO_PENDING;
+
next_state_ = STATE_CREATE_STREAM;
bool defer = false;
if (!before_network_start_callback_.is_null())
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698