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

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

Issue 1411383005: Initial implementation of RequestPriority-based HTTP/2 dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final round of comments. 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_stream_unittest.cc ('k') | net/spdy/spdy_test_util_common.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) 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 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 5 #ifndef NET_SPDY_SPDY_TEST_UTIL_COMMON_H_
6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 6 #define NET_SPDY_SPDY_TEST_UTIL_COMMON_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 void SetStreamInitialRecvWindowSize(size_t window); 291 void SetStreamInitialRecvWindowSize(size_t window);
292 292
293 private: 293 private:
294 SpdySessionPool* const pool_; 294 SpdySessionPool* const pool_;
295 295
296 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); 296 DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer);
297 }; 297 };
298 298
299 class SpdyTestUtil { 299 class SpdyTestUtil {
300 public: 300 public:
301 explicit SpdyTestUtil(NextProto protocol); 301 explicit SpdyTestUtil(NextProto protocol, bool dependency_priorities);
302 ~SpdyTestUtil();
302 303
303 // Add the appropriate headers to put |url| into |block|. 304 // Add the appropriate headers to put |url| into |block|.
304 void AddUrlToHeaderBlock(base::StringPiece url, 305 void AddUrlToHeaderBlock(base::StringPiece url,
305 SpdyHeaderBlock* headers) const; 306 SpdyHeaderBlock* headers) const;
306 307
307 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlock( 308 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlock(
308 base::StringPiece url) const; 309 base::StringPiece url) const;
309 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlockForProxy( 310 scoped_ptr<SpdyHeaderBlock> ConstructGetHeaderBlockForProxy(
310 base::StringPiece url) const; 311 base::StringPiece url) const;
311 scoped_ptr<SpdyHeaderBlock> ConstructHeadHeaderBlock( 312 scoped_ptr<SpdyHeaderBlock> ConstructHeadHeaderBlock(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 SpdyRstStreamStatus status) const; 407 SpdyRstStreamStatus status) const;
407 408
408 // Constructs a standard SPDY GET SYN frame, optionally compressed 409 // Constructs a standard SPDY GET SYN frame, optionally compressed
409 // for |url|. 410 // for |url|.
410 // |extra_headers| are the extra header-value pairs, which typically 411 // |extra_headers| are the extra header-value pairs, which typically
411 // will vary the most between calls. 412 // will vary the most between calls.
412 // Returns a SpdyFrame. 413 // Returns a SpdyFrame.
413 SpdyFrame* ConstructSpdyGet(const char* const url, 414 SpdyFrame* ConstructSpdyGet(const char* const url,
414 bool compressed, 415 bool compressed,
415 SpdyStreamId stream_id, 416 SpdyStreamId stream_id,
416 RequestPriority request_priority) const; 417 RequestPriority request_priority);
417 418
418 SpdyFrame* ConstructSpdyGetForProxy(const char* const url, 419 SpdyFrame* ConstructSpdyGetForProxy(const char* const url,
419 bool compressed, 420 bool compressed,
420 SpdyStreamId stream_id, 421 SpdyStreamId stream_id,
421 RequestPriority request_priority) const; 422 RequestPriority request_priority) const;
422 423
423 // Constructs a standard SPDY GET SYN frame, optionally compressed. 424 // Constructs a standard SPDY GET SYN frame, optionally compressed.
424 // |extra_headers| are the extra header-value pairs, which typically 425 // |extra_headers| are the extra header-value pairs, which typically
425 // will vary the most between calls. If |direct| is false, the 426 // will vary the most between calls. If |direct| is false, the
426 // the full url will be used instead of simply the path. 427 // the full url will be used instead of simply the path.
427 // Returns a SpdyFrame. 428 // Returns a SpdyFrame.
428 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], 429 SpdyFrame* ConstructSpdyGet(const char* const extra_headers[],
429 int extra_header_count, 430 int extra_header_count,
430 bool compressed, 431 bool compressed,
431 int stream_id, 432 int stream_id,
432 RequestPriority request_priority, 433 RequestPriority request_priority,
433 bool direct) const; 434 bool direct);
434 435
435 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. 436 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request.
436 SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[], 437 SpdyFrame* ConstructSpdyConnect(const char* const extra_headers[],
437 int extra_header_count, 438 int extra_header_count,
438 int stream_id, 439 int stream_id,
439 RequestPriority priority, 440 RequestPriority priority,
440 const HostPortPair& host_port_pair) const; 441 const HostPortPair& host_port_pair);
441 442
442 // Constructs a standard SPDY push SYN frame. 443 // Constructs a standard SPDY push SYN frame.
443 // |extra_headers| are the extra header-value pairs, which typically 444 // |extra_headers| are the extra header-value pairs, which typically
444 // will vary the most between calls. 445 // will vary the most between calls.
445 // Returns a SpdyFrame. 446 // Returns a SpdyFrame.
446 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[], 447 SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
447 int extra_header_count, 448 int extra_header_count,
448 int stream_id, 449 int stream_id,
449 int associated_stream_id, 450 int associated_stream_id,
450 const char* url); 451 const char* url);
(...skipping 16 matching lines...) Expand all
467 SpdyFrame* ConstructSpdyHeaderFrame(int stream_id, 468 SpdyFrame* ConstructSpdyHeaderFrame(int stream_id,
468 const char* const headers[], 469 const char* const headers[],
469 int header_count); 470 int header_count);
470 471
471 // Construct a SPDY syn (HEADERS or SYN_STREAM, depending on protocol 472 // Construct a SPDY syn (HEADERS or SYN_STREAM, depending on protocol
472 // version) carrying exactly the given headers and priority. 473 // version) carrying exactly the given headers and priority.
473 SpdyFrame* ConstructSpdySyn(int stream_id, 474 SpdyFrame* ConstructSpdySyn(int stream_id,
474 const SpdyHeaderBlock& headers, 475 const SpdyHeaderBlock& headers,
475 RequestPriority priority, 476 RequestPriority priority,
476 bool compressed, 477 bool compressed,
477 bool fin) const; 478 bool fin);
478 479
479 // Construct a SPDY reply (HEADERS or SYN_REPLY, depending on protocol 480 // Construct a SPDY reply (HEADERS or SYN_REPLY, depending on protocol
480 // version) carrying exactly the given headers, and the default priority 481 // version) carrying exactly the given headers, and the default priority
481 // (or no priority, depending on protocl version). 482 // (or no priority, depending on protocl version).
482 // The |headers| parameter variant is preferred. 483 // The |headers| parameter variant is preferred.
483 SpdyFrame* ConstructSpdyReply(int stream_id, const SpdyHeaderBlock& headers); 484 SpdyFrame* ConstructSpdyReply(int stream_id, const SpdyHeaderBlock& headers);
484 485
485 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET. 486 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY GET.
486 // |extra_headers| are the extra header-value pairs, which typically 487 // |extra_headers| are the extra header-value pairs, which typically
487 // will vary the most between calls. 488 // will vary the most between calls.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 SpdyFrame* ConstructSpdyBodyFrame(int stream_id, 546 SpdyFrame* ConstructSpdyBodyFrame(int stream_id,
546 const char* data, 547 const char* data,
547 uint32 len, 548 uint32 len,
548 bool fin, 549 bool fin,
549 int padding_length); 550 int padding_length);
550 551
551 // Wraps |frame| in the payload of a data frame in stream |stream_id|. 552 // Wraps |frame| in the payload of a data frame in stream |stream_id|.
552 SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame, 553 SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame,
553 int stream_id); 554 int stream_id);
554 555
556 // Called when necessary (when it will affect stream dependency specification
557 // when setting dependencies based on priorioties) to notify the utility
558 // class of stream destruction.
559 void UpdateWithStreamDestruction(int stream_id);
560
555 const SpdyHeaderInfo MakeSpdyHeader(SpdyFrameType type); 561 const SpdyHeaderInfo MakeSpdyHeader(SpdyFrameType type);
556 562
557 // For versions below SPDY4, adds the version HTTP/1.1 header. 563 // For versions below SPDY4, adds the version HTTP/1.1 header.
558 void MaybeAddVersionHeader(SpdyFrameWithHeaderBlockIR* frame_ir) const; 564 void MaybeAddVersionHeader(SpdyFrameWithHeaderBlockIR* frame_ir) const;
559 void MaybeAddVersionHeader(SpdyHeaderBlock* block) const; 565 void MaybeAddVersionHeader(SpdyHeaderBlock* block) const;
560 566
561 // Maps |priority| to SPDY version priority, and sets it on |frame_ir|. 567 // Maps |priority| to SPDY version priority, and sets it on |frame_ir|.
562 void SetPriority(RequestPriority priority, SpdySynStreamIR* frame_ir) const; 568 void SetPriority(RequestPriority priority, SpdySynStreamIR* frame_ir) const;
563 569
564 NextProto protocol() const { return protocol_; } 570 NextProto protocol() const { return protocol_; }
(...skipping 15 matching lines...) Expand all
580 // |content_length| may be NULL, in which case the content-length 586 // |content_length| may be NULL, in which case the content-length
581 // header will be omitted. 587 // header will be omitted.
582 scoped_ptr<SpdyHeaderBlock> ConstructHeaderBlock( 588 scoped_ptr<SpdyHeaderBlock> ConstructHeaderBlock(
583 base::StringPiece method, 589 base::StringPiece method,
584 base::StringPiece url, 590 base::StringPiece url,
585 int64* content_length) const; 591 int64* content_length) const;
586 592
587 const NextProto protocol_; 593 const NextProto protocol_;
588 const SpdyMajorVersion spdy_version_; 594 const SpdyMajorVersion spdy_version_;
589 GURL default_url_; 595 GURL default_url_;
596 bool dependency_priorities_;
597
598 // Track a FIFO list of the stream_id of all created requests by priority.
599 std::map<int, std::vector<int>> priority_to_stream_id_list_;
590 }; 600 };
591 601
592 } // namespace net 602 } // namespace net
593 603
594 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_ 604 #endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream_unittest.cc ('k') | net/spdy/spdy_test_util_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698