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

Side by Side Diff: net/spdy/spdy_test_util_common.cc

Issue 1466493002: Remove unused SpdyTestUtil methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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 unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 NextProtoVector SpdyNextProtos() { 57 NextProtoVector SpdyNextProtos() {
58 NextProtoVector next_protos; 58 NextProtoVector next_protos;
59 next_protos.push_back(kProtoHTTP11); 59 next_protos.push_back(kProtoHTTP11);
60 next_protos.push_back(kProtoSPDY31); 60 next_protos.push_back(kProtoSPDY31);
61 next_protos.push_back(kProtoHTTP2); 61 next_protos.push_back(kProtoHTTP2);
62 next_protos.push_back(kProtoQUIC1SPDY3); 62 next_protos.push_back(kProtoQUIC1SPDY3);
63 return next_protos; 63 return next_protos;
64 } 64 }
65 65
66 // Chop a frame into an array of MockWrites. 66 // Chop a frame into an array of MockWrites.
67 // |data| is the frame to chop. 67 // |frame| is the frame to chop.
68 // |length| is the length of the frame to chop.
69 // |num_chunks| is the number of chunks to create. 68 // |num_chunks| is the number of chunks to create.
70 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) { 69 MockWrite* ChopWriteFrame(const SpdyFrame& frame, int num_chunks) {
71 MockWrite* chunks = new MockWrite[num_chunks]; 70 MockWrite* chunks = new MockWrite[num_chunks];
72 int chunk_size = length / num_chunks; 71 int chunk_size = frame.size() / num_chunks;
73 for (int index = 0; index < num_chunks; index++) { 72 for (int index = 0; index < num_chunks; index++) {
74 const char* ptr = data + (index * chunk_size); 73 const char* ptr = frame.data() + (index * chunk_size);
75 if (index == num_chunks - 1) 74 if (index == num_chunks - 1)
76 chunk_size += length % chunk_size; // The last chunk takes the remainder. 75 chunk_size +=
76 frame.size() % chunk_size; // The last chunk takes the remainder.
77 chunks[index] = MockWrite(ASYNC, ptr, chunk_size); 77 chunks[index] = MockWrite(ASYNC, ptr, chunk_size);
78 } 78 }
79 return chunks; 79 return chunks;
80 } 80 }
81 81
82 // Chop a SpdyFrame into an array of MockWrites.
83 // |frame| is the frame to chop.
84 // |num_chunks| is the number of chunks to create.
85 MockWrite* ChopWriteFrame(const SpdyFrame& frame, int num_chunks) {
86 return ChopWriteFrame(frame.data(), frame.size(), num_chunks);
87 }
88
89 // Chop a frame into an array of MockReads.
90 // |data| is the frame to chop.
91 // |length| is the length of the frame to chop.
92 // |num_chunks| is the number of chunks to create.
93 MockRead* ChopReadFrame(const char* data, int length, int num_chunks) {
94 MockRead* chunks = new MockRead[num_chunks];
95 int chunk_size = length / num_chunks;
96 for (int index = 0; index < num_chunks; index++) {
97 const char* ptr = data + (index * chunk_size);
98 if (index == num_chunks - 1)
99 chunk_size += length % chunk_size; // The last chunk takes the remainder.
100 chunks[index] = MockRead(ASYNC, ptr, chunk_size);
101 }
102 return chunks;
103 }
104
105 // Chop a SpdyFrame into an array of MockReads.
106 // |frame| is the frame to chop.
107 // |num_chunks| is the number of chunks to create.
108 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks) {
109 return ChopReadFrame(frame.data(), frame.size(), num_chunks);
110 }
111
112 // Adds headers and values to a map. 82 // Adds headers and values to a map.
113 // |extra_headers| is an array of { name, value } pairs, arranged as strings 83 // |extra_headers| is an array of { name, value } pairs, arranged as strings
114 // where the even entries are the header names, and the odd entries are the 84 // where the even entries are the header names, and the odd entries are the
115 // header values. 85 // header values.
116 // |headers| gets filled in from |extra_headers|. 86 // |headers| gets filled in from |extra_headers|.
117 void AppendToHeaderBlock(const char* const extra_headers[], 87 void AppendToHeaderBlock(const char* const extra_headers[],
118 int extra_header_count, 88 int extra_header_count,
119 SpdyHeaderBlock* headers) { 89 SpdyHeaderBlock* headers) {
120 std::string this_header; 90 std::string this_header;
121 std::string this_value; 91 std::string this_value;
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 stream_it != priority_it->second.end(); ++stream_it) { 1269 stream_it != priority_it->second.end(); ++stream_it) {
1300 if (*stream_it == stream_id) { 1270 if (*stream_it == stream_id) {
1301 priority_it->second.erase(stream_it); 1271 priority_it->second.erase(stream_it);
1302 return; 1272 return;
1303 } 1273 }
1304 } 1274 }
1305 } 1275 }
1306 NOTREACHED(); 1276 NOTREACHED();
1307 } 1277 }
1308 1278
1309 const SpdyHeaderInfo SpdyTestUtil::MakeSpdyHeader(SpdyFrameType type) {
1310 const SpdyHeaderInfo kHeader = {
1311 type,
1312 1, // Stream ID
1313 0, // Associated stream ID
1314 ConvertRequestPriorityToSpdyPriority(LOWEST, spdy_version_),
1315 CONTROL_FLAG_FIN, // Control Flags
1316 false, // Compressed
1317 RST_STREAM_INVALID,
1318 NULL, // Data
1319 0, // Length
1320 DATA_FLAG_NONE
1321 };
1322 return kHeader;
1323 }
1324
1325 scoped_ptr<SpdyFramer> SpdyTestUtil::CreateFramer(bool compressed) const { 1279 scoped_ptr<SpdyFramer> SpdyTestUtil::CreateFramer(bool compressed) const {
1326 scoped_ptr<SpdyFramer> framer(new SpdyFramer(spdy_version_)); 1280 scoped_ptr<SpdyFramer> framer(new SpdyFramer(spdy_version_));
1327 framer->set_enable_compression(compressed); 1281 framer->set_enable_compression(compressed);
1328 return framer.Pass(); 1282 return framer.Pass();
1329 } 1283 }
1330 1284
1331 const char* SpdyTestUtil::GetMethodKey() const { 1285 const char* SpdyTestUtil::GetMethodKey() const {
1332 return ":method"; 1286 return ":method";
1333 } 1287 }
1334 1288
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 } 1343 }
1390 } 1344 }
1391 1345
1392 void SpdyTestUtil::SetPriority(RequestPriority priority, 1346 void SpdyTestUtil::SetPriority(RequestPriority priority,
1393 SpdySynStreamIR* ir) const { 1347 SpdySynStreamIR* ir) const {
1394 ir->set_priority(ConvertRequestPriorityToSpdyPriority( 1348 ir->set_priority(ConvertRequestPriorityToSpdyPriority(
1395 priority, spdy_version())); 1349 priority, spdy_version()));
1396 } 1350 }
1397 1351
1398 } // namespace net 1352 } // namespace net
OLDNEW
« no previous file with comments | « 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