OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_QUIC_QUIC_HEADERS_STREAM_H_ | 5 #ifndef NET_QUIC_QUIC_HEADERS_STREAM_H_ |
6 #define NET_QUIC_QUIC_HEADERS_STREAM_H_ | 6 #define NET_QUIC_QUIC_HEADERS_STREAM_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
14 #include "net/quic/quic_header_list.h" | 14 #include "net/quic/quic_header_list.h" |
15 #include "net/quic/quic_protocol.h" | 15 #include "net/quic/quic_protocol.h" |
16 #include "net/quic/reliable_quic_stream.h" | 16 #include "net/quic/reliable_quic_stream.h" |
17 #include "net/spdy/spdy_framer.h" | 17 #include "net/spdy/spdy_framer.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class QuicSpdySession; | 21 class QuicSpdySession; |
22 | 22 |
23 // Headers in QUIC are sent as HTTP/2 HEADERS or PUSH_PROMISE frames | 23 // Headers in QUIC are sent as HTTP/2 HEADERS or PUSH_PROMISE frames |
24 // over a reserved reliable stream with the id 3. Each endpoint | 24 // over a reserved reliable stream with the id 3. Each endpoint |
25 // (client and server) will allocate an instance of QuicHeadersStream | 25 // (client and server) will allocate an instance of QuicHeadersStream |
26 // to send and receive headers. | 26 // to send and receive headers. |
27 class NET_EXPORT_PRIVATE QuicHeadersStream : public ReliableQuicStream { | 27 class NET_EXPORT_PRIVATE QuicHeadersStream : public ReliableQuicStream { |
28 public: | 28 public: |
| 29 class NET_EXPORT_PRIVATE HpackDebugVisitor { |
| 30 public: |
| 31 HpackDebugVisitor(); |
| 32 |
| 33 virtual ~HpackDebugVisitor(); |
| 34 |
| 35 // For each HPACK indexed representation processed, |elapsed| is |
| 36 // the time since the corresponding entry was added to the dynamic |
| 37 // table. |
| 38 virtual void OnUseEntry(QuicTime::Delta elapsed) = 0; |
| 39 |
| 40 private: |
| 41 DISALLOW_COPY_AND_ASSIGN(HpackDebugVisitor); |
| 42 }; |
| 43 |
29 explicit QuicHeadersStream(QuicSpdySession* session); | 44 explicit QuicHeadersStream(QuicSpdySession* session); |
30 ~QuicHeadersStream() override; | 45 ~QuicHeadersStream() override; |
31 | 46 |
32 // Writes |headers| for |stream_id| in an HTTP/2 HEADERS frame to the peer. | 47 // Writes |headers| for |stream_id| in an HTTP/2 HEADERS frame to the peer. |
33 // If |fin| is true, the fin flag will be set on the HEADERS frame. Returns | 48 // If |fin| is true, the fin flag will be set on the HEADERS frame. Returns |
34 // the size, in bytes, of the resulting HEADERS frame. | 49 // the size, in bytes, of the resulting HEADERS frame. |
35 virtual size_t WriteHeaders(QuicStreamId stream_id, | 50 virtual size_t WriteHeaders(QuicStreamId stream_id, |
36 const SpdyHeaderBlock& headers, | 51 const SpdyHeaderBlock& headers, |
37 bool fin, | 52 bool fin, |
38 SpdyPriority priority, | 53 SpdyPriority priority, |
(...skipping 10 matching lines...) Expand all Loading... |
49 // ReliableQuicStream implementation | 64 // ReliableQuicStream implementation |
50 void OnDataAvailable() override; | 65 void OnDataAvailable() override; |
51 | 66 |
52 bool supports_push_promise() { return supports_push_promise_; } | 67 bool supports_push_promise() { return supports_push_promise_; } |
53 | 68 |
54 // Experimental: force HPACK to use static table and huffman coding | 69 // Experimental: force HPACK to use static table and huffman coding |
55 // only. Part of exploring improvements related to headers stream | 70 // only. Part of exploring improvements related to headers stream |
56 // induced HOL blocking in QUIC. | 71 // induced HOL blocking in QUIC. |
57 void DisableHpackDynamicTable(); | 72 void DisableHpackDynamicTable(); |
58 | 73 |
| 74 // Optional, enables instrumentation related to go/quic-hpack. |
| 75 void SetHpackEncoderDebugVisitor(std::unique_ptr<HpackDebugVisitor> visitor); |
| 76 void SetHpackDecoderDebugVisitor(std::unique_ptr<HpackDebugVisitor> visitor); |
| 77 |
59 private: | 78 private: |
60 class SpdyFramerVisitor; | 79 class SpdyFramerVisitor; |
61 | 80 |
62 // The following methods are called by the SimpleVisitor. | 81 // The following methods are called by the SimpleVisitor. |
63 | 82 |
64 // Called when a HEADERS frame has been received. | 83 // Called when a HEADERS frame has been received. |
65 void OnHeaders(SpdyStreamId stream_id, | 84 void OnHeaders(SpdyStreamId stream_id, |
66 bool has_priority, | 85 bool has_priority, |
67 SpdyPriority priority, | 86 SpdyPriority priority, |
68 bool fin); | 87 bool fin); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 137 |
119 // Either empty, or contains the complete list of headers. | 138 // Either empty, or contains the complete list of headers. |
120 QuicHeaderList header_list_; | 139 QuicHeaderList header_list_; |
121 | 140 |
122 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream); | 141 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream); |
123 }; | 142 }; |
124 | 143 |
125 } // namespace net | 144 } // namespace net |
126 | 145 |
127 #endif // NET_QUIC_QUIC_HEADERS_STREAM_H_ | 146 #endif // NET_QUIC_QUIC_HEADERS_STREAM_H_ |
OLD | NEW |