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

Side by Side Diff: net/spdy/spdy_test_util_spdy3.h

Issue 12743006: [SPDY] Refactor tests in preparation for a fix for a session flow control bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_test_util_spdy2.cc ('k') | net/spdy/spdy_test_util_spdy3.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_
6 #define NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ 6 #define NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h"
10 #include "crypto/ec_private_key.h" 11 #include "crypto/ec_private_key.h"
11 #include "crypto/ec_signature_creator.h" 12 #include "crypto/ec_signature_creator.h"
12 #include "net/base/cert_verifier.h" 13 #include "net/base/cert_verifier.h"
13 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
14 #include "net/base/mock_host_resolver.h" 15 #include "net/base/mock_host_resolver.h"
15 #include "net/base/request_priority.h" 16 #include "net/base/request_priority.h"
16 #include "net/http/http_auth_handler_factory.h" 17 #include "net/http/http_auth_handler_factory.h"
17 #include "net/http/http_cache.h" 18 #include "net/http/http_cache.h"
18 #include "net/http/http_network_layer.h" 19 #include "net/http/http_network_layer.h"
19 #include "net/http/http_network_session.h" 20 #include "net/http/http_network_session.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Chop a SpdyFrame into an array of MockReads. 109 // Chop a SpdyFrame into an array of MockReads.
109 // |frame| is the frame to chop. 110 // |frame| is the frame to chop.
110 // |num_chunks| is the number of chunks to create. 111 // |num_chunks| is the number of chunks to create.
111 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks); 112 MockRead* ChopReadFrame(const SpdyFrame& frame, int num_chunks);
112 113
113 // Adds headers and values to a map. 114 // Adds headers and values to a map.
114 // |extra_headers| is an array of { name, value } pairs, arranged as strings 115 // |extra_headers| is an array of { name, value } pairs, arranged as strings
115 // where the even entries are the header names, and the odd entries are the 116 // where the even entries are the header names, and the odd entries are the
116 // header values. 117 // header values.
117 // |headers| gets filled in from |extra_headers|. 118 // |headers| gets filled in from |extra_headers|.
118 void AppendHeadersToSpdyFrame(const char* const extra_headers[], 119 void AppendHeadersToBlock(const char* const extra_headers[],
119 int extra_header_count, 120 int extra_header_count,
120 SpdyHeaderBlock* headers); 121 SpdyHeaderBlock* headers);
122
123 // Constructs a HeaderBlock for the given URL.
124 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlock(base::StringPiece url);
125
126 // Constructs a HeaderBlock for a POST request for the given URL.
127 scoped_ptr<SpdyHeaderBlock> ConstructPostHeaderBlock(base::StringPiece url,
128 int64 content_length);
121 129
122 // Writes |str| of the given |len| to the buffer pointed to by |buffer_handle|. 130 // Writes |str| of the given |len| to the buffer pointed to by |buffer_handle|.
123 // Uses a template so buffer_handle can be a char* or an unsigned char*. 131 // Uses a template so buffer_handle can be a char* or an unsigned char*.
124 // Updates the |*buffer_handle| pointer by |len| 132 // Updates the |*buffer_handle| pointer by |len|
125 // Returns the number of bytes written into *|buffer_handle| 133 // Returns the number of bytes written into *|buffer_handle|
126 template<class T> 134 template<class T>
127 int AppendToBuffer(const char* str, 135 int AppendToBuffer(const char* str,
128 int len, 136 int len,
129 T** buffer_handle, 137 T** buffer_handle,
130 int* buffer_len_remaining) { 138 int* buffer_len_remaining) {
(...skipping 11 matching lines...) Expand all
142 150
143 // Writes |val| to a location of size |len|, in big-endian format. 151 // Writes |val| to a location of size |len|, in big-endian format.
144 // in the buffer pointed to by |buffer_handle|. 152 // in the buffer pointed to by |buffer_handle|.
145 // Updates the |*buffer_handle| pointer by |len| 153 // Updates the |*buffer_handle| pointer by |len|
146 // Returns the number of bytes written 154 // Returns the number of bytes written
147 int AppendToBuffer(int val, 155 int AppendToBuffer(int val,
148 int len, 156 int len,
149 unsigned char** buffer_handle, 157 unsigned char** buffer_handle,
150 int* buffer_len_remaining); 158 int* buffer_len_remaining);
151 159
152 // Construct a SPDY packet. 160 // Construct a SPDY frame.
153 // |head| is the start of the packet, up to but not including 161 SpdyFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info,
154 // the header value pairs. 162 scoped_ptr<SpdyHeaderBlock> headers);
163
164 // Construct a SPDY frame.
155 // |extra_headers| are the extra header-value pairs, which typically 165 // |extra_headers| are the extra header-value pairs, which typically
156 // will vary the most between calls. 166 // will vary the most between calls.
157 // |tail| is any (relatively constant) header-value pairs to add. 167 // |tail| is any (relatively constant) header-value pairs to add.
158 // |buffer| is the buffer we're filling in.
159 // Returns a SpdyFrame. 168 // Returns a SpdyFrame.
160 SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, 169 SpdyFrame* ConstructSpdyFrame(const SpdyHeaderInfo& header_info,
161 const char* const extra_headers[], 170 const char* const extra_headers[],
162 int extra_header_count, 171 int extra_header_count,
163 const char* const tail[], 172 const char* const tail[],
164 int tail_header_count); 173 int tail_header_count);
165 174
166 // Construct a generic SpdyControlFrame. 175 // Construct a generic SpdyControlFrame.
167 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[], 176 SpdyFrame* ConstructSpdyControlFrame(const char* const extra_headers[],
168 int extra_header_count, 177 int extra_header_count,
169 bool compressed, 178 bool compressed,
170 int stream_id, 179 int stream_id,
171 RequestPriority request_priority, 180 RequestPriority request_priority,
172 SpdyControlType type, 181 SpdyControlType type,
173 SpdyControlFlags flags, 182 SpdyControlFlags flags,
174 const char* const* kHeaders, 183 const char* const* kHeaders,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // |extra_headers| are the extra header-value pairs. 234 // |extra_headers| are the extra header-value pairs.
226 // |buffer| is the buffer we're filling in. 235 // |buffer| is the buffer we're filling in.
227 // |index| is the index of the header we want. 236 // |index| is the index of the header we want.
228 // Returns the number of bytes written into |buffer|. 237 // Returns the number of bytes written into |buffer|.
229 int ConstructSpdyHeader(const char* const extra_headers[], 238 int ConstructSpdyHeader(const char* const extra_headers[],
230 int extra_header_count, 239 int extra_header_count,
231 char* buffer, 240 char* buffer,
232 int buffer_length, 241 int buffer_length,
233 int index); 242 int index);
234 243
235 // Constructs a standard SPDY GET SYN packet, optionally compressed 244 // Constructs a standard SPDY GET SYN frame, optionally compressed
236 // for the url |url|. 245 // for the url |url|.
237 // |extra_headers| are the extra header-value pairs, which typically 246 // |extra_headers| are the extra header-value pairs, which typically
238 // will vary the most between calls. 247 // will vary the most between calls.
239 // Returns a SpdyFrame. 248 // Returns a SpdyFrame.
240 SpdyFrame* ConstructSpdyGet(const char* const url, 249 SpdyFrame* ConstructSpdyGet(const char* const url,
241 bool compressed, 250 bool compressed,
242 SpdyStreamId stream_id, 251 SpdyStreamId stream_id,
243 RequestPriority request_priority); 252 RequestPriority request_priority);
244 253
245 // Constructs a standard SPDY GET SYN packet, optionally compressed. 254 // Constructs a standard SPDY GET SYN frame, optionally compressed.
246 // |extra_headers| are the extra header-value pairs, which typically 255 // |extra_headers| are the extra header-value pairs, which typically
247 // will vary the most between calls. 256 // will vary the most between calls.
248 // Returns a SpdyFrame. 257 // Returns a SpdyFrame.
249 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], 258 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[],
250 int extra_header_count, 259 int extra_header_count,
251 bool compressed, 260 bool compressed,
252 int stream_id, 261 int stream_id,
253 RequestPriority request_priority); 262 RequestPriority request_priority);
254 263
255 // Constructs a standard SPDY GET SYN packet, optionally compressed. 264 // Constructs a standard SPDY GET SYN frame, optionally compressed.
256 // |extra_headers| are the extra header-value pairs, which typically 265 // |extra_headers| are the extra header-value pairs, which typically
257 // will vary the most between calls. If |direct| is false, the 266 // will vary the most between calls. If |direct| is false, the
258 // the full url will be used instead of simply the path. 267 // the full url will be used instead of simply the path.
259 // Returns a SpdyFrame. 268 // Returns a SpdyFrame.
260 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], 269 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[],
261 int extra_header_count, 270 int extra_header_count,
262 bool compressed, 271 bool compressed,
263 int stream_id, 272 int stream_id,
264 RequestPriority request_priority, 273 RequestPriority request_priority,
265 bool direct); 274 bool direct);
266 275
267 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. 276 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request.
268 SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[], 277 SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[],
269 int extra_header_count, 278 int extra_header_count,
270 int stream_id); 279 int stream_id);
271 280
272 // Constructs a standard SPDY push SYN packet. 281 // Constructs a standard SPDY push SYN frame.
273 // |extra_headers| are the extra header-value pairs, which typically 282 // |extra_headers| are the extra header-value pairs, which typically
274 // will vary the most between calls. 283 // will vary the most between calls.
275 // Returns a SpdyFrame. 284 // Returns a SpdyFrame.
276 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 285 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
277 int extra_header_count, 286 int extra_header_count,
278 int stream_id, 287 int stream_id,
279 int associated_stream_id); 288 int associated_stream_id);
280 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 289 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
281 int extra_header_count, 290 int extra_header_count,
282 int stream_id, 291 int stream_id,
283 int associated_stream_id, 292 int associated_stream_id,
284 const char* url); 293 const char* url);
285 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 294 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
286 int extra_header_count, 295 int extra_header_count,
287 int stream_id, 296 int stream_id,
288 int associated_stream_id, 297 int associated_stream_id,
289 const char* url, 298 const char* url,
290 const char* status, 299 const char* status,
291 const char* location); 300 const char* location);
292 SpdyFrame* ConstructSpdyPush(int stream_id, 301 SpdyFrame* ConstructSpdyPush(int stream_id,
293 int associated_stream_id, 302 int associated_stream_id,
294 const char* url); 303 const char* url);
295 304
296 SpdyFrame* ConstructSpdyPushHeaders(int stream_id, 305 SpdyFrame* ConstructSpdyPushHeaders(int stream_id,
297 const char* const extra_headers[], 306 const char* const extra_headers[],
298 int extra_header_count); 307 int extra_header_count);
299 308
300 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. 309 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET.
301 // |extra_headers| are the extra header-value pairs, which typically 310 // |extra_headers| are the extra header-value pairs, which typically
302 // will vary the most between calls. 311 // will vary the most between calls.
303 // Returns a SpdyFrame. 312 // Returns a SpdyFrame.
304 SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], 313 SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[],
305 int extra_header_count, 314 int extra_header_count,
306 int stream_id); 315 int stream_id);
307 316
308 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY GET. 317 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET.
309 // |extra_headers| are the extra header-value pairs, which typically 318 // |extra_headers| are the extra header-value pairs, which typically
310 // will vary the most between calls. 319 // will vary the most between calls.
311 // Returns a SpdyFrame. 320 // Returns a SpdyFrame.
312 SpdyFrame* ConstructSpdyGetSynReplyRedirect(int stream_id); 321 SpdyFrame* ConstructSpdyGetSynReplyRedirect(int stream_id);
313 322
314 // Constructs a standard SPDY SYN_REPLY packet with an Internal Server 323 // Constructs a standard SPDY SYN_REPLY frame with an Internal Server
315 // Error status code. 324 // Error status code.
316 // Returns a SpdyFrame. 325 // Returns a SpdyFrame.
317 SpdyFrame* ConstructSpdySynReplyError(int stream_id); 326 SpdyFrame* ConstructSpdySynReplyError(int stream_id);
318 327
319 // Constructs a standard SPDY SYN_REPLY packet with the specified status code. 328 // Constructs a standard SPDY SYN_REPLY frame with the specified status code.
320 // Returns a SpdyFrame. 329 // Returns a SpdyFrame.
321 SpdyFrame* ConstructSpdySynReplyError(const char* const status, 330 SpdyFrame* ConstructSpdySynReplyError(const char* const status,
322 const char* const* const extra_headers, 331 const char* const* const extra_headers,
323 int extra_header_count, 332 int extra_header_count,
324 int stream_id); 333 int stream_id);
325 334
326 // Constructs a standard SPDY POST SYN packet. 335 // Constructs a standard SPDY POST SYN frame.
327 // |extra_headers| are the extra header-value pairs, which typically 336 // |extra_headers| are the extra header-value pairs, which typically
328 // will vary the most between calls. 337 // will vary the most between calls.
329 // Returns a SpdyFrame. 338 // Returns a SpdyFrame.
330 SpdyFrame* ConstructSpdyPost(int64 content_length, 339 SpdyFrame* ConstructSpdyPost(const char* url,
340 SpdyStreamId stream_id,
341 int64 content_length,
342 RequestPriority priority,
331 const char* const extra_headers[], 343 const char* const extra_headers[],
332 int extra_header_count); 344 int extra_header_count);
333 345
334 // Constructs a chunked transfer SPDY POST SYN packet. 346 // Constructs a chunked transfer SPDY POST SYN frame.
335 // |extra_headers| are the extra header-value pairs, which typically 347 // |extra_headers| are the extra header-value pairs, which typically
336 // will vary the most between calls. 348 // will vary the most between calls.
337 // Returns a SpdyFrame. 349 // Returns a SpdyFrame.
338 SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[], 350 SpdyFrame* ConstructChunkedSpdyPost(const char* const extra_headers[],
339 int extra_header_count); 351 int extra_header_count);
340 352
341 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. 353 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY POST.
342 // |extra_headers| are the extra header-value pairs, which typically 354 // |extra_headers| are the extra header-value pairs, which typically
343 // will vary the most between calls. 355 // will vary the most between calls.
344 // Returns a SpdyFrame. 356 // Returns a SpdyFrame.
345 SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], 357 SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[],
346 int extra_header_count); 358 int extra_header_count);
347 359
348 // Constructs a single SPDY data frame with the contents "hello!" 360 // Constructs a single SPDY data frame with the contents "hello!"
349 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, 361 SpdyFrame* ConstructSpdyBodyFrame(int stream_id,
350 bool fin); 362 bool fin);
351 363
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 SpdySessionPool* const pool_; 471 SpdySessionPool* const pool_;
460 472
461 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); 473 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer);
462 }; 474 };
463 475
464 } // namespace test_spdy3 476 } // namespace test_spdy3
465 477
466 } // namespace net 478 } // namespace net
467 479
468 #endif // NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_ 480 #endif // NET_SPDY_SPDY_TEST_UTIL_SPDY3_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_spdy2.cc ('k') | net/spdy/spdy_test_util_spdy3.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698