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

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

Issue 3050016: Implement prefetching in chrome (Closed)
Patch Set: merge to trunk Created 10 years, 4 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
« no previous file with comments | « net/spdy/spdy_stream_unittest.cc ('k') | net/url_request/url_request.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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.h" 5 #include "net/spdy/spdy_test_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "net/http/http_network_transaction.h"
12 #include "net/spdy/spdy_framer.h"
11 13
12 namespace net { 14 namespace net {
13 15
14 // Chop a frame into an array of MockWrites. 16 // Chop a frame into an array of MockWrites.
15 // |data| is the frame to chop. 17 // |data| is the frame to chop.
16 // |length| is the length of the frame to chop. 18 // |length| is the length of the frame to chop.
17 // |num_chunks| is the number of chunks to create. 19 // |num_chunks| is the number of chunks to create.
18 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) { 20 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) {
19 MockWrite* chunks = new MockWrite[num_chunks]; 21 MockWrite* chunks = new MockWrite[num_chunks];
20 int chunk_size = length / num_chunks; 22 int chunk_size = length / num_chunks;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // will vary the most between calls. 256 // will vary the most between calls.
255 // Returns a SpdyFrame. 257 // Returns a SpdyFrame.
256 spdy::SpdyFrame* ConstructSpdyGet(const char* const url, 258 spdy::SpdyFrame* ConstructSpdyGet(const char* const url,
257 bool compressed, 259 bool compressed,
258 int stream_id, 260 int stream_id,
259 RequestPriority request_priority) { 261 RequestPriority request_priority) {
260 const SpdyHeaderInfo kSynStartHeader = { 262 const SpdyHeaderInfo kSynStartHeader = {
261 spdy::SYN_STREAM, // Kind = Syn 263 spdy::SYN_STREAM, // Kind = Syn
262 stream_id, // Stream ID 264 stream_id, // Stream ID
263 0, // Associated stream ID 265 0, // Associated stream ID
264 request_priority, // Priority 266 net::ConvertRequestPriorityToSpdyPriority(request_priority),
267 // Priority
265 spdy::CONTROL_FLAG_FIN, // Control Flags 268 spdy::CONTROL_FLAG_FIN, // Control Flags
266 compressed, // Compressed 269 compressed, // Compressed
267 spdy::INVALID, // Status 270 spdy::INVALID, // Status
268 NULL, // Data 271 NULL, // Data
269 0, // Length 272 0, // Length
270 spdy::DATA_FLAG_NONE // Data Flags 273 spdy::DATA_FLAG_NONE // Data Flags
271 }; 274 };
272 275
273 GURL gurl(url); 276 GURL gurl(url);
274 277
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // Returns a SpdyFrame. 315 // Returns a SpdyFrame.
313 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], 316 spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[],
314 int extra_header_count, 317 int extra_header_count,
315 bool compressed, 318 bool compressed,
316 int stream_id, 319 int stream_id,
317 RequestPriority request_priority) { 320 RequestPriority request_priority) {
318 const SpdyHeaderInfo kSynStartHeader = { 321 const SpdyHeaderInfo kSynStartHeader = {
319 spdy::SYN_STREAM, // Kind = Syn 322 spdy::SYN_STREAM, // Kind = Syn
320 stream_id, // Stream ID 323 stream_id, // Stream ID
321 0, // Associated stream ID 324 0, // Associated stream ID
322 request_priority, // Priority 325 net::ConvertRequestPriorityToSpdyPriority(request_priority),
326 // Priority
323 spdy::CONTROL_FLAG_FIN, // Control Flags 327 spdy::CONTROL_FLAG_FIN, // Control Flags
324 compressed, // Compressed 328 compressed, // Compressed
325 spdy::INVALID, // Status 329 spdy::INVALID, // Status
326 NULL, // Data 330 NULL, // Data
327 0, // Length 331 0, // Length
328 spdy::DATA_FLAG_NONE // Data Flags 332 spdy::DATA_FLAG_NONE // Data Flags
329 }; 333 };
330 static const char* const kStandardGetHeaders[] = { 334 static const char* const kStandardGetHeaders[] = {
331 "method", 335 "method",
332 "GET", 336 "GET",
(...skipping 18 matching lines...) Expand all
351 // |extra_headers| are the extra header-value pairs, which typically 355 // |extra_headers| are the extra header-value pairs, which typically
352 // will vary the most between calls. 356 // will vary the most between calls.
353 // Returns a SpdyFrame. 357 // Returns a SpdyFrame.
354 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], 358 spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[],
355 int extra_header_count, 359 int extra_header_count,
356 int stream_id) { 360 int stream_id) {
357 const SpdyHeaderInfo kSynStartHeader = { 361 const SpdyHeaderInfo kSynStartHeader = {
358 spdy::SYN_REPLY, // Kind = SynReply 362 spdy::SYN_REPLY, // Kind = SynReply
359 stream_id, // Stream ID 363 stream_id, // Stream ID
360 0, // Associated stream ID 364 0, // Associated stream ID
361 SPDY_PRIORITY_LOWEST, // Priority 365 net::ConvertRequestPriorityToSpdyPriority(LOWEST),
366 // Priority
362 spdy::CONTROL_FLAG_NONE, // Control Flags 367 spdy::CONTROL_FLAG_NONE, // Control Flags
363 false, // Compressed 368 false, // Compressed
364 spdy::INVALID, // Status 369 spdy::INVALID, // Status
365 NULL, // Data 370 NULL, // Data
366 0, // Length 371 0, // Length
367 spdy::DATA_FLAG_NONE // Data Flags 372 spdy::DATA_FLAG_NONE // Data Flags
368 }; 373 };
369 static const char* const kStandardGetHeaders[] = { 374 static const char* const kStandardGetHeaders[] = {
370 "hello", 375 "hello",
371 "bye", 376 "bye",
(...skipping 15 matching lines...) Expand all
387 // Constructs a standard SPDY POST SYN packet. 392 // Constructs a standard SPDY POST SYN packet.
388 // |extra_headers| are the extra header-value pairs, which typically 393 // |extra_headers| are the extra header-value pairs, which typically
389 // will vary the most between calls. 394 // will vary the most between calls.
390 // Returns a SpdyFrame. 395 // Returns a SpdyFrame.
391 spdy::SpdyFrame* ConstructSpdyPost(const char* const extra_headers[], 396 spdy::SpdyFrame* ConstructSpdyPost(const char* const extra_headers[],
392 int extra_header_count) { 397 int extra_header_count) {
393 const SpdyHeaderInfo kSynStartHeader = { 398 const SpdyHeaderInfo kSynStartHeader = {
394 spdy::SYN_STREAM, // Kind = Syn 399 spdy::SYN_STREAM, // Kind = Syn
395 1, // Stream ID 400 1, // Stream ID
396 0, // Associated stream ID 401 0, // Associated stream ID
397 SPDY_PRIORITY_LOWEST, // Priority 402 net::ConvertRequestPriorityToSpdyPriority(LOWEST),
403 // Priority
398 spdy::CONTROL_FLAG_NONE, // Control Flags 404 spdy::CONTROL_FLAG_NONE, // Control Flags
399 false, // Compressed 405 false, // Compressed
400 spdy::INVALID, // Status 406 spdy::INVALID, // Status
401 NULL, // Data 407 NULL, // Data
402 0, // Length 408 0, // Length
403 spdy::DATA_FLAG_NONE // Data Flags 409 spdy::DATA_FLAG_NONE // Data Flags
404 }; 410 };
405 static const char* const kStandardGetHeaders[] = { 411 static const char* const kStandardGetHeaders[] = {
406 "method", 412 "method",
407 "POST", 413 "POST",
(...skipping 17 matching lines...) Expand all
425 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST. 431 // Constructs a standard SPDY SYN_REPLY packet to match the SPDY POST.
426 // |extra_headers| are the extra header-value pairs, which typically 432 // |extra_headers| are the extra header-value pairs, which typically
427 // will vary the most between calls. 433 // will vary the most between calls.
428 // Returns a SpdyFrame. 434 // Returns a SpdyFrame.
429 spdy::SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], 435 spdy::SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[],
430 int extra_header_count) { 436 int extra_header_count) {
431 const SpdyHeaderInfo kSynStartHeader = { 437 const SpdyHeaderInfo kSynStartHeader = {
432 spdy::SYN_REPLY, // Kind = SynReply 438 spdy::SYN_REPLY, // Kind = SynReply
433 1, // Stream ID 439 1, // Stream ID
434 0, // Associated stream ID 440 0, // Associated stream ID
435 SPDY_PRIORITY_LOWEST, // Priority 441 net::ConvertRequestPriorityToSpdyPriority(LOWEST),
442 // Priority
436 spdy::CONTROL_FLAG_NONE, // Control Flags 443 spdy::CONTROL_FLAG_NONE, // Control Flags
437 false, // Compressed 444 false, // Compressed
438 spdy::INVALID, // Status 445 spdy::INVALID, // Status
439 NULL, // Data 446 NULL, // Data
440 0, // Length 447 0, // Length
441 spdy::DATA_FLAG_NONE // Data Flags 448 spdy::DATA_FLAG_NONE // Data Flags
442 }; 449 };
443 static const char* const kStandardGetHeaders[] = { 450 static const char* const kStandardGetHeaders[] = {
444 "hello", 451 "hello",
445 "bye", 452 "bye",
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 char* ptr = buff; 587 char* ptr = buff;
581 for (int i = 0; i < num_frames; ++i) { 588 for (int i = 0; i < num_frames; ++i) {
582 int len = frames[i]->length() + spdy::SpdyFrame::size(); 589 int len = frames[i]->length() + spdy::SpdyFrame::size();
583 memcpy(ptr, frames[i]->data(), len); 590 memcpy(ptr, frames[i]->data(), len);
584 ptr += len; 591 ptr += len;
585 } 592 }
586 return total_len; 593 return total_len;
587 } 594 }
588 595
589 } // namespace net 596 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream_unittest.cc ('k') | net/url_request/url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698