OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/spdy_test_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 | 10 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 } | 727 } |
728 | 728 |
729 void SpdySessionPoolPeer::SetSessionMaxRecvWindowSize(size_t window) { | 729 void SpdySessionPoolPeer::SetSessionMaxRecvWindowSize(size_t window) { |
730 pool_->session_max_recv_window_size_ = window; | 730 pool_->session_max_recv_window_size_ = window; |
731 } | 731 } |
732 | 732 |
733 void SpdySessionPoolPeer::SetStreamInitialRecvWindowSize(size_t window) { | 733 void SpdySessionPoolPeer::SetStreamInitialRecvWindowSize(size_t window) { |
734 pool_->stream_max_recv_window_size_ = window; | 734 pool_->stream_max_recv_window_size_ = window; |
735 } | 735 } |
736 | 736 |
737 SpdyTestUtil::SpdyTestUtil(NextProto protocol) | 737 SpdyTestUtil::SpdyTestUtil(NextProto protocol, bool dependency_priorities) |
738 : protocol_(protocol), | 738 : protocol_(protocol), |
739 spdy_version_(NextProtoToSpdyMajorVersion(protocol)), | 739 spdy_version_(NextProtoToSpdyMajorVersion(protocol)), |
740 default_url_(GURL(kDefaultURL)) { | 740 default_url_(GURL(kDefaultURL)), |
741 dependency_priorities_(dependency_priorities) { | |
741 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; | 742 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; |
742 } | 743 } |
743 | 744 |
745 SpdyTestUtil::~SpdyTestUtil() {} | |
746 | |
744 void SpdyTestUtil::AddUrlToHeaderBlock(base::StringPiece url, | 747 void SpdyTestUtil::AddUrlToHeaderBlock(base::StringPiece url, |
745 SpdyHeaderBlock* headers) const { | 748 SpdyHeaderBlock* headers) const { |
746 std::string scheme, host, path; | 749 std::string scheme, host, path; |
747 ParseUrl(url, &scheme, &host, &path); | 750 ParseUrl(url, &scheme, &host, &path); |
748 (*headers)[GetHostKey()] = host; | 751 (*headers)[GetHostKey()] = host; |
749 (*headers)[GetSchemeKey()] = scheme; | 752 (*headers)[GetSchemeKey()] = scheme; |
750 (*headers)[GetPathKey()] = path; | 753 (*headers)[GetPathKey()] = path; |
751 } | 754 } |
752 | 755 |
753 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructGetHeaderBlock( | 756 scoped_ptr<SpdyHeaderBlock> SpdyTestUtil::ConstructGetHeaderBlock( |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1128 AppendToHeaderBlock(headers, header_count, | 1131 AppendToHeaderBlock(headers, header_count, |
1129 spdy_headers.mutable_header_block()); | 1132 spdy_headers.mutable_header_block()); |
1130 return CreateFramer(false)->SerializeFrame(spdy_headers); | 1133 return CreateFramer(false)->SerializeFrame(spdy_headers); |
1131 } | 1134 } |
1132 | 1135 |
1133 SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id, | 1136 SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id, |
1134 const SpdyHeaderBlock& block, | 1137 const SpdyHeaderBlock& block, |
1135 RequestPriority priority, | 1138 RequestPriority priority, |
1136 bool compressed, | 1139 bool compressed, |
1137 bool fin) const { | 1140 bool fin) const { |
1141 // Get the stream id of the next highest priority request | |
1142 // (most recent request of the same priority, or last request of | |
1143 // an earlier priority). | |
1144 int parent_stream_id = 0; | |
1145 for (int q = priority; q >= IDLE; --q) { | |
1146 if (!priority_to_stream_id_list_[q].empty()) { | |
1147 parent_stream_id = priority_to_stream_id_list_[q].back(); | |
1148 break; | |
1149 } | |
1150 } | |
1151 | |
1152 priority_to_stream_id_list_[priority].push_back(stream_id); | |
1153 | |
1138 if (protocol_ < kProtoHTTP2) { | 1154 if (protocol_ < kProtoHTTP2) { |
1139 SpdySynStreamIR syn_stream(stream_id); | 1155 SpdySynStreamIR syn_stream(stream_id); |
1140 syn_stream.set_header_block(block); | 1156 syn_stream.set_header_block(block); |
1141 syn_stream.set_priority( | 1157 syn_stream.set_priority( |
1142 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); | 1158 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); |
1143 syn_stream.set_fin(fin); | 1159 syn_stream.set_fin(fin); |
1144 return CreateFramer(compressed)->SerializeFrame(syn_stream); | 1160 return CreateFramer(compressed)->SerializeFrame(syn_stream); |
1145 } else { | 1161 } else { |
1146 SpdyHeadersIR headers(stream_id); | 1162 SpdyHeadersIR headers(stream_id); |
1147 headers.set_header_block(block); | 1163 headers.set_header_block(block); |
1148 headers.set_has_priority(true); | 1164 headers.set_has_priority(true); |
1149 headers.set_priority( | 1165 headers.set_priority( |
1150 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); | 1166 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); |
1167 if (dependency_priorities_) { | |
1168 headers.set_parent_stream_id(parent_stream_id); | |
1169 headers.set_exclusive(true); | |
1170 } | |
1151 headers.set_fin(fin); | 1171 headers.set_fin(fin); |
1152 return CreateFramer(compressed)->SerializeFrame(headers); | 1172 return CreateFramer(compressed)->SerializeFrame(headers); |
1153 } | 1173 } |
1154 } | 1174 } |
1155 | 1175 |
1156 SpdyFrame* SpdyTestUtil::ConstructSpdyReply(int stream_id, | 1176 SpdyFrame* SpdyTestUtil::ConstructSpdyReply(int stream_id, |
1157 const SpdyHeaderBlock& headers) { | 1177 const SpdyHeaderBlock& headers) { |
1158 if (protocol_ < kProtoHTTP2) { | 1178 if (protocol_ < kProtoHTTP2) { |
1159 SpdySynReplyIR syn_reply(stream_id); | 1179 SpdySynReplyIR syn_reply(stream_id); |
1160 syn_reply.set_header_block(headers); | 1180 syn_reply.set_header_block(headers); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 return framer.SerializeData(data_ir); | 1285 return framer.SerializeData(data_ir); |
1266 } | 1286 } |
1267 | 1287 |
1268 SpdyFrame* SpdyTestUtil::ConstructWrappedSpdyFrame( | 1288 SpdyFrame* SpdyTestUtil::ConstructWrappedSpdyFrame( |
1269 const scoped_ptr<SpdyFrame>& frame, | 1289 const scoped_ptr<SpdyFrame>& frame, |
1270 int stream_id) { | 1290 int stream_id) { |
1271 return ConstructSpdyBodyFrame(stream_id, frame->data(), | 1291 return ConstructSpdyBodyFrame(stream_id, frame->data(), |
1272 frame->size(), false); | 1292 frame->size(), false); |
1273 } | 1293 } |
1274 | 1294 |
1295 void SpdyTestUtil::OnStreamDestruction(int stream_id) { | |
1296 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
| |
1297 for (auto priority_it = priority_to_stream_id_list_.begin(); | |
1298 priority_it != priority_to_stream_id_list_.end(); ++priority_it) { | |
1299 for (auto stream_it = priority_it->second.begin(); | |
1300 stream_it != priority_it->second.end(); ++stream_it) { | |
1301 if (*stream_it == stream_id) { | |
1302 LOG(ERROR) << __FUNCTION__ << ":" << __LINE__ << " vector size " | |
1303 << priority_it->second.size(); | |
1304 priority_it->second.erase(stream_it); | |
1305 LOG(ERROR) << __FUNCTION__ << ":" << __LINE__ << " vector size " | |
1306 << priority_it->second.size(); | |
1307 return; | |
1308 } | |
1309 } | |
1310 } | |
1311 LOG(ERROR) << __FUNCTION__ << "Reached end."; | |
1312 NOTREACHED(); | |
1313 } | |
1314 | |
1275 const SpdyHeaderInfo SpdyTestUtil::MakeSpdyHeader(SpdyFrameType type) { | 1315 const SpdyHeaderInfo SpdyTestUtil::MakeSpdyHeader(SpdyFrameType type) { |
1276 const SpdyHeaderInfo kHeader = { | 1316 const SpdyHeaderInfo kHeader = { |
1277 type, | 1317 type, |
1278 1, // Stream ID | 1318 1, // Stream ID |
1279 0, // Associated stream ID | 1319 0, // Associated stream ID |
1280 ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_version_), | 1320 ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_version_), |
1281 kSpdyCredentialSlotUnused, | 1321 kSpdyCredentialSlotUnused, |
1282 CONTROL_FLAG_FIN, // Control Flags | 1322 CONTROL_FLAG_FIN, // Control Flags |
1283 false, // Compressed | 1323 false, // Compressed |
1284 RST_STREAM_INVALID, | 1324 RST_STREAM_INVALID, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1356 } | 1396 } |
1357 } | 1397 } |
1358 | 1398 |
1359 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1399 void SpdyTestUtil::SetPriority(RequestPriority priority, |
1360 SpdySynStreamIR* ir) const { | 1400 SpdySynStreamIR* ir) const { |
1361 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1401 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
1362 priority, spdy_version())); | 1402 priority, spdy_version())); |
1363 } | 1403 } |
1364 | 1404 |
1365 } // namespace net | 1405 } // namespace net |
OLD | NEW |