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

Side by Side Diff: net/spdy/core/spdy_protocol.h

Issue 2849713002: Remove one layer of abstraction from HTTP/2 frame representations. (Closed)
Patch Set: Created 3 years, 7 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/core/spdy_framer_test.cc ('k') | net/spdy/core/spdy_protocol.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 // This file contains some protocol structures for use with SPDY 3 and HTTP 2 5 // This file contains some protocol structures for use with SPDY 3 and HTTP 2
6 // The SPDY 3 spec can be found at: 6 // The SPDY 3 spec can be found at:
7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3 7 // http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3
8 8
9 #ifndef NET_SPDY_CORE_SPDY_PROTOCOL_H_ 9 #ifndef NET_SPDY_CORE_SPDY_PROTOCOL_H_
10 #define NET_SPDY_CORE_SPDY_PROTOCOL_H_ 10 #define NET_SPDY_CORE_SPDY_PROTOCOL_H_
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 class SpdyFrameVisitor; 375 class SpdyFrameVisitor;
376 376
377 // Intermediate representation for HTTP2 frames. 377 // Intermediate representation for HTTP2 frames.
378 class SPDY_EXPORT_PRIVATE SpdyFrameIR { 378 class SPDY_EXPORT_PRIVATE SpdyFrameIR {
379 public: 379 public:
380 virtual ~SpdyFrameIR() {} 380 virtual ~SpdyFrameIR() {}
381 381
382 virtual void Visit(SpdyFrameVisitor* visitor) const = 0; 382 virtual void Visit(SpdyFrameVisitor* visitor) const = 0;
383 virtual SpdyFrameType frame_type() const = 0; 383 virtual SpdyFrameType frame_type() const = 0;
384 SpdyStreamId stream_id() const { return stream_id_; }
384 385
385 protected: 386 protected:
386 SpdyFrameIR() {} 387 SpdyFrameIR() : stream_id_(0) {}
387 388 explicit SpdyFrameIR(SpdyStreamId stream_id) : stream_id_(stream_id) {}
388 private:
389 DISALLOW_COPY_AND_ASSIGN(SpdyFrameIR);
390 };
391
392 // Abstract class intended to be inherited by IRs that have a stream associated
393 // to them.
394 class SPDY_EXPORT_PRIVATE SpdyFrameWithStreamIdIR : public SpdyFrameIR {
395 public:
396 ~SpdyFrameWithStreamIdIR() override {}
397 SpdyStreamId stream_id() const { return stream_id_; }
398 void set_stream_id(SpdyStreamId stream_id) {
399 DCHECK_EQ(0u, stream_id & ~kStreamIdMask);
400 stream_id_ = stream_id;
401 }
402
403 protected:
404 explicit SpdyFrameWithStreamIdIR(SpdyStreamId stream_id) {
405 set_stream_id(stream_id);
406 }
407 389
408 private: 390 private:
409 SpdyStreamId stream_id_; 391 SpdyStreamId stream_id_;
410 392
411 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithStreamIdIR); 393 DISALLOW_COPY_AND_ASSIGN(SpdyFrameIR);
412 }; 394 };
413 395
414 // Abstract class intended to be inherited by IRs that have the option of a FIN 396 // Abstract class intended to be inherited by IRs that have the option of a FIN
415 // flag. Implies SpdyFrameWithStreamIdIR. 397 // flag.
416 class SPDY_EXPORT_PRIVATE SpdyFrameWithFinIR : public SpdyFrameWithStreamIdIR { 398 class SPDY_EXPORT_PRIVATE SpdyFrameWithFinIR : public SpdyFrameIR {
417 public: 399 public:
418 ~SpdyFrameWithFinIR() override {} 400 ~SpdyFrameWithFinIR() override {}
419 bool fin() const { return fin_; } 401 bool fin() const { return fin_; }
420 void set_fin(bool fin) { fin_ = fin; } 402 void set_fin(bool fin) { fin_ = fin; }
421 403
422 protected: 404 protected:
423 explicit SpdyFrameWithFinIR(SpdyStreamId stream_id) 405 explicit SpdyFrameWithFinIR(SpdyStreamId stream_id)
424 : SpdyFrameWithStreamIdIR(stream_id), 406 : SpdyFrameIR(stream_id), fin_(false) {}
425 fin_(false) {}
426 407
427 private: 408 private:
428 bool fin_; 409 bool fin_;
429 410
430 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithFinIR); 411 DISALLOW_COPY_AND_ASSIGN(SpdyFrameWithFinIR);
431 }; 412 };
432 413
433 // Abstract class intended to be inherited by IRs that contain a header 414 // Abstract class intended to be inherited by IRs that contain a header
434 // block. Implies SpdyFrameWithFinIR. 415 // block. Implies SpdyFrameWithFinIR.
435 class SPDY_EXPORT_PRIVATE SpdyFrameWithHeaderBlockIR 416 class SPDY_EXPORT_PRIVATE SpdyFrameWithHeaderBlockIR
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 const char* data_; 504 const char* data_;
524 size_t data_len_; 505 size_t data_len_;
525 506
526 bool padded_; 507 bool padded_;
527 // padding_payload_len_ = desired padding length - len(padding length field). 508 // padding_payload_len_ = desired padding length - len(padding length field).
528 int padding_payload_len_; 509 int padding_payload_len_;
529 510
530 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR); 511 DISALLOW_COPY_AND_ASSIGN(SpdyDataIR);
531 }; 512 };
532 513
533 class SPDY_EXPORT_PRIVATE SpdyRstStreamIR : public SpdyFrameWithStreamIdIR { 514 class SPDY_EXPORT_PRIVATE SpdyRstStreamIR : public SpdyFrameIR {
534 public: 515 public:
535 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyErrorCode error_code); 516 SpdyRstStreamIR(SpdyStreamId stream_id, SpdyErrorCode error_code);
536 517
537 ~SpdyRstStreamIR() override; 518 ~SpdyRstStreamIR() override;
538 519
539 SpdyErrorCode error_code() const { return error_code_; } 520 SpdyErrorCode error_code() const { return error_code_; }
540 void set_error_code(SpdyErrorCode error_code) { error_code_ = error_code; } 521 void set_error_code(SpdyErrorCode error_code) { error_code_ = error_code; }
541 522
542 void Visit(SpdyFrameVisitor* visitor) const override; 523 void Visit(SpdyFrameVisitor* visitor) const override;
543 524
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 bool has_priority_ = false; 654 bool has_priority_ = false;
674 int weight_ = kHttp2DefaultStreamWeight; 655 int weight_ = kHttp2DefaultStreamWeight;
675 SpdyStreamId parent_stream_id_ = 0; 656 SpdyStreamId parent_stream_id_ = 0;
676 bool exclusive_ = false; 657 bool exclusive_ = false;
677 bool padded_ = false; 658 bool padded_ = false;
678 int padding_payload_len_ = 0; 659 int padding_payload_len_ = 0;
679 660
680 DISALLOW_COPY_AND_ASSIGN(SpdyHeadersIR); 661 DISALLOW_COPY_AND_ASSIGN(SpdyHeadersIR);
681 }; 662 };
682 663
683 class SPDY_EXPORT_PRIVATE SpdyWindowUpdateIR : public SpdyFrameWithStreamIdIR { 664 class SPDY_EXPORT_PRIVATE SpdyWindowUpdateIR : public SpdyFrameIR {
684 public: 665 public:
685 SpdyWindowUpdateIR(SpdyStreamId stream_id, int32_t delta) 666 SpdyWindowUpdateIR(SpdyStreamId stream_id, int32_t delta)
686 : SpdyFrameWithStreamIdIR(stream_id) { 667 : SpdyFrameIR(stream_id) {
687 set_delta(delta); 668 set_delta(delta);
688 } 669 }
689 int32_t delta() const { return delta_; } 670 int32_t delta() const { return delta_; }
690 void set_delta(int32_t delta) { 671 void set_delta(int32_t delta) {
691 DCHECK_LE(0, delta); 672 DCHECK_LE(0, delta);
692 DCHECK_LE(delta, kSpdyMaximumWindowSize); 673 DCHECK_LE(delta, kSpdyMaximumWindowSize);
693 delta_ = delta; 674 delta_ = delta;
694 } 675 }
695 676
696 void Visit(SpdyFrameVisitor* visitor) const override; 677 void Visit(SpdyFrameVisitor* visitor) const override;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 714
734 private: 715 private:
735 SpdyStreamId promised_stream_id_; 716 SpdyStreamId promised_stream_id_;
736 717
737 bool padded_; 718 bool padded_;
738 int padding_payload_len_; 719 int padding_payload_len_;
739 720
740 DISALLOW_COPY_AND_ASSIGN(SpdyPushPromiseIR); 721 DISALLOW_COPY_AND_ASSIGN(SpdyPushPromiseIR);
741 }; 722 };
742 723
743 class SPDY_EXPORT_PRIVATE SpdyContinuationIR : public SpdyFrameWithStreamIdIR { 724 class SPDY_EXPORT_PRIVATE SpdyContinuationIR : public SpdyFrameIR {
744 public: 725 public:
745 explicit SpdyContinuationIR(SpdyStreamId stream_id); 726 explicit SpdyContinuationIR(SpdyStreamId stream_id);
746 ~SpdyContinuationIR() override; 727 ~SpdyContinuationIR() override;
747 728
748 void Visit(SpdyFrameVisitor* visitor) const override; 729 void Visit(SpdyFrameVisitor* visitor) const override;
749 730
750 SpdyFrameType frame_type() const override; 731 SpdyFrameType frame_type() const override;
751 732
752 bool end_headers() const { return end_headers_; } 733 bool end_headers() const { return end_headers_; }
753 void set_end_headers(bool end_headers) {end_headers_ = end_headers;} 734 void set_end_headers(bool end_headers) {end_headers_ = end_headers;}
754 const SpdyString& encoding() const { return *encoding_; } 735 const SpdyString& encoding() const { return *encoding_; }
755 void take_encoding(std::unique_ptr<SpdyString> encoding) { 736 void take_encoding(std::unique_ptr<SpdyString> encoding) {
756 encoding_ = std::move(encoding); 737 encoding_ = std::move(encoding);
757 } 738 }
758 739
759 private: 740 private:
760 std::unique_ptr<SpdyString> encoding_; 741 std::unique_ptr<SpdyString> encoding_;
761 bool end_headers_; 742 bool end_headers_;
762 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR); 743 DISALLOW_COPY_AND_ASSIGN(SpdyContinuationIR);
763 }; 744 };
764 745
765 class SPDY_EXPORT_PRIVATE SpdyAltSvcIR : public SpdyFrameWithStreamIdIR { 746 class SPDY_EXPORT_PRIVATE SpdyAltSvcIR : public SpdyFrameIR {
766 public: 747 public:
767 explicit SpdyAltSvcIR(SpdyStreamId stream_id); 748 explicit SpdyAltSvcIR(SpdyStreamId stream_id);
768 ~SpdyAltSvcIR() override; 749 ~SpdyAltSvcIR() override;
769 750
770 SpdyString origin() const { return origin_; } 751 SpdyString origin() const { return origin_; }
771 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector() const { 752 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector() const {
772 return altsvc_vector_; 753 return altsvc_vector_;
773 } 754 }
774 755
775 void set_origin(SpdyString origin) { origin_ = std::move(origin); } 756 void set_origin(SpdyString origin) { origin_ = std::move(origin); }
776 void add_altsvc(const SpdyAltSvcWireFormat::AlternativeService& altsvc) { 757 void add_altsvc(const SpdyAltSvcWireFormat::AlternativeService& altsvc) {
777 altsvc_vector_.push_back(altsvc); 758 altsvc_vector_.push_back(altsvc);
778 } 759 }
779 760
780 void Visit(SpdyFrameVisitor* visitor) const override; 761 void Visit(SpdyFrameVisitor* visitor) const override;
781 762
782 SpdyFrameType frame_type() const override; 763 SpdyFrameType frame_type() const override;
783 764
784 private: 765 private:
785 SpdyString origin_; 766 SpdyString origin_;
786 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector_; 767 SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector_;
787 DISALLOW_COPY_AND_ASSIGN(SpdyAltSvcIR); 768 DISALLOW_COPY_AND_ASSIGN(SpdyAltSvcIR);
788 }; 769 };
789 770
790 class SPDY_EXPORT_PRIVATE SpdyPriorityIR : public SpdyFrameWithStreamIdIR { 771 class SPDY_EXPORT_PRIVATE SpdyPriorityIR : public SpdyFrameIR {
791 public: 772 public:
792 SpdyPriorityIR(SpdyStreamId stream_id, 773 SpdyPriorityIR(SpdyStreamId stream_id,
793 SpdyStreamId parent_stream_id, 774 SpdyStreamId parent_stream_id,
794 int weight, 775 int weight,
795 bool exclusive) 776 bool exclusive)
796 : SpdyFrameWithStreamIdIR(stream_id), 777 : SpdyFrameIR(stream_id),
797 parent_stream_id_(parent_stream_id), 778 parent_stream_id_(parent_stream_id),
798 weight_(weight), 779 weight_(weight),
799 exclusive_(exclusive) {} 780 exclusive_(exclusive) {}
800 SpdyStreamId parent_stream_id() const { return parent_stream_id_; } 781 SpdyStreamId parent_stream_id() const { return parent_stream_id_; }
801 int weight() const { return weight_; } 782 int weight() const { return weight_; }
802 bool exclusive() const { return exclusive_; } 783 bool exclusive() const { return exclusive_; }
803 784
804 void Visit(SpdyFrameVisitor* visitor) const override; 785 void Visit(SpdyFrameVisitor* visitor) const override;
805 786
806 SpdyFrameType frame_type() const override; 787 SpdyFrameType frame_type() const override;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 SpdyFrameVisitor() {} 893 SpdyFrameVisitor() {}
913 virtual ~SpdyFrameVisitor() {} 894 virtual ~SpdyFrameVisitor() {}
914 895
915 private: 896 private:
916 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor); 897 DISALLOW_COPY_AND_ASSIGN(SpdyFrameVisitor);
917 }; 898 };
918 899
919 } // namespace net 900 } // namespace net
920 901
921 #endif // NET_SPDY_CORE_SPDY_PROTOCOL_H_ 902 #endif // NET_SPDY_CORE_SPDY_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/spdy/core/spdy_framer_test.cc ('k') | net/spdy/core/spdy_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698