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

Unified Diff: net/spdy/spdy_test_util_common.cc

Issue 1411383005: Initial implementation of RequestPriority-based HTTP/2 dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated tests. Created 5 years, 1 month 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
« net/spdy/spdy_test_util_common.h ('K') | « net/spdy/spdy_test_util_common.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_test_util_common.cc
diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc
index d442a474fc1a42cf71bc14e8045e33d23d2a294c..77597df5ef70381cb83b275962dc1149fdf39262 100644
--- a/net/spdy/spdy_test_util_common.cc
+++ b/net/spdy/spdy_test_util_common.cc
@@ -734,13 +734,16 @@ void SpdySessionPoolPeer::SetStreamInitialRecvWindowSize(size_t window) {
pool_->stream_max_recv_window_size_ = window;
}
-SpdyTestUtil::SpdyTestUtil(NextProto protocol)
+SpdyTestUtil::SpdyTestUtil(NextProto protocol, bool dependency_priorities)
: protocol_(protocol),
spdy_version_(NextProtoToSpdyMajorVersion(protocol)),
- default_url_(GURL(kDefaultURL)) {
+ default_url_(GURL(kDefaultURL)),
+ dependency_priorities_(dependency_priorities) {
DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol;
}
+SpdyTestUtil::~SpdyTestUtil() {}
+
void SpdyTestUtil::AddUrlToHeaderBlock(base::StringPiece url,
SpdyHeaderBlock* headers) const {
std::string scheme, host, path;
@@ -1135,6 +1138,19 @@ SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id,
RequestPriority priority,
bool compressed,
bool fin) const {
+ // Get the stream id of the next highest priority request
+ // (most recent request of the same priority, or last request of
+ // an earlier priority).
+ int parent_stream_id = 0;
+ for (int q = priority; q >= IDLE; --q) {
+ if (!priority_to_stream_id_list_[q].empty()) {
+ parent_stream_id = priority_to_stream_id_list_[q].back();
+ break;
+ }
+ }
+
+ priority_to_stream_id_list_[priority].push_back(stream_id);
+
if (protocol_ < kProtoHTTP2) {
SpdySynStreamIR syn_stream(stream_id);
syn_stream.set_header_block(block);
@@ -1148,6 +1164,10 @@ SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id,
headers.set_has_priority(true);
headers.set_priority(
ConvertRequestPriorityToSpdyPriority(priority, spdy_version()));
+ if (dependency_priorities_) {
+ headers.set_parent_stream_id(parent_stream_id);
+ headers.set_exclusive(true);
+ }
headers.set_fin(fin);
return CreateFramer(compressed)->SerializeFrame(headers);
}
@@ -1272,6 +1292,26 @@ SpdyFrame* SpdyTestUtil::ConstructWrappedSpdyFrame(
frame->size(), false);
}
+void SpdyTestUtil::OnStreamDestruction(int stream_id) {
+ LOG(ERROR) << __FUNCTION__ << " stream_id " << stream_id;
Bence 2015/11/11 18:47:15 I assume you do not intend to keep these LOG state
Randy Smith (Not in Mondays) 2015/11/11 23:25:59 Whoops, I was trying to keep these in the git stas
+ for (auto priority_it = priority_to_stream_id_list_.begin();
+ priority_it != priority_to_stream_id_list_.end(); ++priority_it) {
+ for (auto stream_it = priority_it->second.begin();
+ stream_it != priority_it->second.end(); ++stream_it) {
+ if (*stream_it == stream_id) {
+ LOG(ERROR) << __FUNCTION__ << ":" << __LINE__ << " vector size "
+ << priority_it->second.size();
+ priority_it->second.erase(stream_it);
+ LOG(ERROR) << __FUNCTION__ << ":" << __LINE__ << " vector size "
+ << priority_it->second.size();
+ return;
+ }
+ }
+ }
+ LOG(ERROR) << __FUNCTION__ << "Reached end.";
+ NOTREACHED();
+}
+
const SpdyHeaderInfo SpdyTestUtil::MakeSpdyHeader(SpdyFrameType type) {
const SpdyHeaderInfo kHeader = {
type,
« net/spdy/spdy_test_util_common.h ('K') | « net/spdy/spdy_test_util_common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698