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

Unified Diff: net/spdy/http2_priority_dependencies.cc

Issue 1779733003: Fix bug in net::RequestPriority -> HTTP/2 dependency conversion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make bi-directional stream unittests enable priority->dependency setting. Created 4 years, 9 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/http2_priority_dependencies.h ('k') | net/spdy/http2_priority_dependencies_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/http2_priority_dependencies.cc
diff --git a/net/spdy/http2_priority_dependencies.cc b/net/spdy/http2_priority_dependencies.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a09ef1d08ae7c54284c011131896aa5724985907
--- /dev/null
+++ b/net/spdy/http2_priority_dependencies.cc
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/spdy/http2_priority_dependencies.h"
+
+namespace net {
+
+Http2PriorityDependencies::Http2PriorityDependencies() {}
+
+Http2PriorityDependencies::~Http2PriorityDependencies() {}
+
+void Http2PriorityDependencies::OnStreamSynSent(
+ SpdyStreamId id,
+ SpdyPriority priority,
+ SpdyStreamId* dependent_stream_id,
+ bool* exclusive) {
+ DCHECK(entry_by_stream_id_.find(id) == entry_by_stream_id_.end());
+
+ *dependent_stream_id = 0ul;
+ *exclusive = true;
+
+ // Find the next highest entry in total order.
+ for (int i = priority; i >= kV3HighestPriority; --i) {
+ if (!id_priority_lists_[i].empty()) {
+ *dependent_stream_id = id_priority_lists_[i].back().first;
+ break;
+ }
+ }
+
+ id_priority_lists_[priority].push_back(std::make_pair(id, priority));
+ IdList::iterator it = id_priority_lists_[priority].end();
+ --it;
+ entry_by_stream_id_[id] = it;
+}
+
+void Http2PriorityDependencies::OnStreamDestruction(SpdyStreamId id) {
+ EntryMap::iterator emit = entry_by_stream_id_.find(id);
+
+ // This routine may be called without a matching call to
+ // OnStreamSynSent above, in the case of server push. In that case,
+ // it's a no-op.
+ if (emit == entry_by_stream_id_.end())
+ return;
+
+ IdList::iterator it = emit->second;
+ id_priority_lists_[it->second].erase(it);
+ entry_by_stream_id_.erase(emit);
+}
+
+} // namespace net
« no previous file with comments | « net/spdy/http2_priority_dependencies.h ('k') | net/spdy/http2_priority_dependencies_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698