Commit a6bcc6c1 authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Change Http2PriorityDependencies to refer to parent_stream_id

instead of dependent_stream_id to match the language in the HTTP spec
and to make it clear which direction the dependency points.

Change-Id: I715b9f87a8ca614efd7d816c9f4229c52747e142
Reviewed-on: https://chromium-review.googlesource.com/917203
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Reviewed-by: default avatarRandy Smith <rdsmith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537538}
parent f7e02c7a
......@@ -912,9 +912,10 @@ void QuicChromiumClientSession::UpdateStreamPriority(
for (auto update : updates) {
QuicSpdyStream* stream = GetSpdyDataStream(update.id);
DCHECK(stream);
SpdyPriority priority = stream->QuicSpdyStream::priority();
WritePriority(update.id, update.dependent_stream_id,
Spdy3PriorityToHttp2Weight(priority), update.exclusive);
int weight =
Spdy3PriorityToHttp2Weight(stream->QuicSpdyStream::priority());
WritePriority(update.id, update.parent_stream_id, weight,
update.exclusive);
}
}
QuicSpdySession::UpdateStreamPriority(id, new_priority);
......
......@@ -11,16 +11,15 @@ Http2PriorityDependencies::Http2PriorityDependencies() = default;
Http2PriorityDependencies::~Http2PriorityDependencies() = default;
void Http2PriorityDependencies::OnStreamCreation(
SpdyStreamId id,
SpdyPriority priority,
SpdyStreamId* dependent_stream_id,
int* weight,
bool* exclusive) {
void Http2PriorityDependencies::OnStreamCreation(SpdyStreamId id,
SpdyPriority priority,
SpdyStreamId* parent_stream_id,
int* weight,
bool* exclusive) {
if (entry_by_stream_id_.find(id) != entry_by_stream_id_.end())
return;
*dependent_stream_id = 0;
*parent_stream_id = 0;
*exclusive = true;
// Since the generated dependency graph is a single linked list, the value
// of weight should not actually matter, and perhaps the default weight of 16
......@@ -33,7 +32,7 @@ void Http2PriorityDependencies::OnStreamCreation(
// Dependent on the lowest-priority stream that has a priority >= |priority|.
IdList::iterator parent;
if (PriorityLowerBound(priority, &parent)) {
*dependent_stream_id = parent->first;
*parent_stream_id = parent->first;
}
id_priority_lists_[priority].push_back(std::make_pair(id, priority));
......
......@@ -29,13 +29,13 @@ class NET_EXPORT_PRIVATE Http2PriorityDependencies {
// Called when a stream is created. This is used for both client-initiated
// and server-initiated (pushed) streams.
// On return, |*dependent_stream_id| is set to the stream id that
// this stream should be made dependent on, |*exclusive| is set to
// whether that dependency should be exclusive, and |*weight| is set to
// the relative weight for the created stream given this priority.
// On return, |*parent_stream_id| is set to the stream id that should become
// the parent of this stream, |*exclusive| is set to whether that dependency
// should be exclusive, and |*weight| is set to the relative weight for the
// created stream given this priority.
void OnStreamCreation(SpdyStreamId id,
SpdyPriority priority,
SpdyStreamId* dependent_stream_id,
SpdyStreamId* parent_stream_id,
int* weight,
bool* exclusive);
......@@ -44,7 +44,7 @@ class NET_EXPORT_PRIVATE Http2PriorityDependencies {
struct DependencyUpdate {
SpdyStreamId id;
SpdyStreamId dependent_stream_id;
SpdyStreamId parent_stream_id;
bool exclusive;
};
......
......@@ -15,7 +15,7 @@ namespace net {
bool operator==(const Http2PriorityDependencies::DependencyUpdate& a,
const Http2PriorityDependencies::DependencyUpdate& b) {
return a.id == b.id && a.dependent_stream_id == b.dependent_stream_id &&
return a.id == b.id && a.parent_stream_id == b.parent_stream_id &&
a.exclusive == b.exclusive;
}
......@@ -23,7 +23,7 @@ std::ostream& operator<<(
std::ostream& os,
const std::vector<Http2PriorityDependencies::DependencyUpdate>& v) {
for (auto e : v) {
os << "{" << e.id << "," << e.dependent_stream_id << ","
os << "{" << e.id << "," << e.parent_stream_id << ","
<< (e.exclusive ? "true" : "false") << "}";
}
return os;
......@@ -45,21 +45,21 @@ class HttpPriorityDependencyTest : public PlatformTest {
void TestStreamCreation(SpdyStreamId new_id,
SpdyPriority priority,
SpdyStreamId expected_dependent_id) {
SpdyStreamId expected_parent_id) {
int expected_weight = Spdy3PriorityToHttp2Weight(priority);
SpdyStreamId dependent_id = 999u;
SpdyStreamId parent_id = 999u;
int weight = -1;
bool exclusive = false;
dependency_state_.OnStreamCreation(new_id, priority, &dependent_id, &weight,
dependency_state_.OnStreamCreation(new_id, priority, &parent_id, &weight,
&exclusive);
if (expected_dependent_id != dependent_id || !exclusive ||
if (expected_parent_id != parent_id || !exclusive ||
expected_weight != weight) {
ADD_FAILURE() << "OnStreamCreation(" << new_id << ", " << int(priority)
<< ")\n"
<< " Got: (" << dependent_id << ", " << weight << ", "
<< " Got: (" << parent_id << ", " << weight << ", "
<< exclusive << ")\n"
<< " Want: (" << expected_dependent_id << ", "
<< " Want: (" << expected_parent_id << ", "
<< expected_weight << ", true)\n";
}
}
......
......@@ -868,7 +868,7 @@ int SpdySession::GetPushedStream(const GURL& url,
DCHECK(it != active_streams_.end());
int weight = Spdy3PriorityToHttp2Weight(
ConvertRequestPriorityToSpdyPriority(it->second->priority()));
EnqueuePriorityFrame(u.id, u.dependent_stream_id, weight, u.exclusive);
EnqueuePriorityFrame(u.id, u.parent_stream_id, weight, u.exclusive);
}
return OK;
......@@ -967,24 +967,24 @@ std::unique_ptr<SpdySerializedFrame> SpdySession::CreateHeaders(
bool has_priority = true;
int weight = 0;
SpdyStreamId dependent_stream_id = 0;
SpdyStreamId parent_stream_id = 0;
bool exclusive = false;
priority_dependency_state_.OnStreamCreation(
stream_id, spdy_priority, &dependent_stream_id, &weight, &exclusive);
stream_id, spdy_priority, &parent_stream_id, &weight, &exclusive);
if (net_log().IsCapturing()) {
net_log().AddEvent(
NetLogEventType::HTTP2_SESSION_SEND_HEADERS,
base::Bind(&NetLogSpdyHeadersSentCallback, &block,
(flags & CONTROL_FLAG_FIN) != 0, stream_id, has_priority,
weight, dependent_stream_id, exclusive, source_dependency));
weight, parent_stream_id, exclusive, source_dependency));
}
SpdyHeadersIR headers(stream_id, std::move(block));
headers.set_has_priority(has_priority);
headers.set_weight(weight);
headers.set_parent_stream_id(dependent_stream_id);
headers.set_parent_stream_id(parent_stream_id);
headers.set_exclusive(exclusive);
headers.set_fin((flags & CONTROL_FLAG_FIN) != 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment