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

Unified Diff: net/spdy/chromium/spdy_session_pool.cc

Issue 2932513004: Throttle HttpStreamFactoryImpl::Job to HTTP/2-supported servers (Closed)
Patch Set: address comments Created 3 years, 6 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/spdy/chromium/spdy_session_pool.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/chromium/spdy_session_pool.cc
diff --git a/net/spdy/chromium/spdy_session_pool.cc b/net/spdy/chromium/spdy_session_pool.cc
index 5b10bf84392987f7351182029a461021b49b7003..f46b4401354f1e526b14a8a62de9b23660bbf87e 100644
--- a/net/spdy/chromium/spdy_session_pool.cc
+++ b/net/spdy/chromium/spdy_session_pool.cc
@@ -439,6 +439,29 @@ void SpdySessionPool::OnNewSpdySessionReady(
// TODO(mbelshe): Alert other valid requests.
}
+bool SpdySessionPool::StartRequest(const SpdySessionKey& spdy_session_key,
+ const base::Closure& callback) {
+ auto iter = spdy_session_pending_request_map_.find(spdy_session_key);
+ if (iter == spdy_session_pending_request_map_.end()) {
+ spdy_session_pending_request_map_.emplace(spdy_session_key,
+ std::list<base::Closure>{});
+ return true;
+ }
+ iter->second.push_back(callback);
+ return false;
+}
+
+void SpdySessionPool::ResumeAllPendingRequests(
+ const SpdySessionKey& spdy_session_key) {
+ auto iter = spdy_session_pending_request_map_.find(spdy_session_key);
+ if (iter != spdy_session_pending_request_map_.end()) {
+ for (auto callback : iter->second) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
+ }
+ spdy_session_pending_request_map_.erase(iter);
+ }
+}
+
void SpdySessionPool::AddRequestToSpdySessionRequestMap(
const SpdySessionKey& spdy_session_key,
HttpStreamFactoryImpl::Request* request) {
@@ -463,6 +486,9 @@ void SpdySessionPool::RemoveRequestFromSpdySessionRequestMap(
if (request_set.empty())
spdy_session_request_map_.erase(spdy_session_key);
request->ResetSpdySessionKey();
+ // If the request failed or canceled, open the floodgate to resume all
+ // requests.
+ ResumeAllPendingRequests(spdy_session_key);
xunjieli 2017/06/13 15:23:11 I remove ResumeNextPendingRequest() to make the lo
}
void SpdySessionPool::DumpMemoryStats(
« no previous file with comments | « net/spdy/chromium/spdy_session_pool.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698