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 // The base class for streams which deliver data to/from an application. | 5 // The base class for streams which deliver data to/from an application. |
6 // In each direction, the data on such a stream first contains compressed | 6 // In each direction, the data on such a stream first contains compressed |
7 // headers then body data. | 7 // headers then body data. |
8 | 8 |
9 #ifndef NET_QUIC_QUIC_DATA_STREAM_H_ | 9 #ifndef NET_QUIC_QUIC_SPDY_STREAM_H_ |
10 #define NET_QUIC_QUIC_DATA_STREAM_H_ | 10 #define NET_QUIC_QUIC_SPDY_STREAM_H_ |
11 | 11 |
12 #include <sys/types.h> | 12 #include <sys/types.h> |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
19 #include "net/base/iovec.h" | 19 #include "net/base/iovec.h" |
20 #include "net/base/ip_endpoint.h" | 20 #include "net/base/ip_endpoint.h" |
21 #include "net/base/net_export.h" | 21 #include "net/base/net_export.h" |
22 #include "net/quic/quic_ack_notifier.h" | 22 #include "net/quic/quic_ack_notifier.h" |
23 #include "net/quic/quic_protocol.h" | 23 #include "net/quic/quic_protocol.h" |
24 #include "net/quic/quic_stream_sequencer.h" | 24 #include "net/quic/quic_stream_sequencer.h" |
25 #include "net/quic/reliable_quic_stream.h" | 25 #include "net/quic/reliable_quic_stream.h" |
26 #include "net/spdy/spdy_framer.h" | 26 #include "net/spdy/spdy_framer.h" |
27 | 27 |
28 namespace net { | 28 namespace net { |
29 | 29 |
30 namespace test { | 30 namespace test { |
31 class QuicDataStreamPeer; | 31 class QuicSpdyStreamPeer; |
32 class ReliableQuicStreamPeer; | 32 class ReliableQuicStreamPeer; |
33 } // namespace test | 33 } // namespace test |
34 | 34 |
35 class QuicSpdySession; | 35 class QuicSpdySession; |
36 | 36 |
37 // A QUIC data stream that can also send and receive headers. | 37 // A QUIC stream that can send and receive HTTP2 (SPDY) headers. |
38 class NET_EXPORT_PRIVATE QuicDataStream : public ReliableQuicStream { | 38 class NET_EXPORT_PRIVATE QuicSpdyStream : public ReliableQuicStream { |
39 public: | 39 public: |
40 // Visitor receives callbacks from the stream. | 40 // Visitor receives callbacks from the stream. |
41 class NET_EXPORT_PRIVATE Visitor { | 41 class NET_EXPORT_PRIVATE Visitor { |
42 public: | 42 public: |
43 Visitor() {} | 43 Visitor() {} |
44 | 44 |
45 // Called when the stream is closed. | 45 // Called when the stream is closed. |
46 virtual void OnClose(QuicDataStream* stream) = 0; | 46 virtual void OnClose(QuicSpdyStream* stream) = 0; |
47 | 47 |
48 protected: | 48 protected: |
49 virtual ~Visitor() {} | 49 virtual ~Visitor() {} |
50 | 50 |
51 private: | 51 private: |
52 DISALLOW_COPY_AND_ASSIGN(Visitor); | 52 DISALLOW_COPY_AND_ASSIGN(Visitor); |
53 }; | 53 }; |
54 | 54 |
55 QuicDataStream(QuicStreamId id, QuicSpdySession* spdy_session); | 55 QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session); |
56 ~QuicDataStream() override; | 56 ~QuicSpdyStream() override; |
57 | 57 |
58 // ReliableQuicStream implementation | 58 // ReliableQuicStream implementation |
59 void OnClose() override; | 59 void OnClose() override; |
60 | 60 |
61 // By default, this is the same as priority(), however it allows streams | 61 // By default, this is the same as priority(), however it allows streams |
62 // to temporarily alter effective priority. For example if a SPDY stream has | 62 // to temporarily alter effective priority. For example if a SPDY stream has |
63 // compressed but not written headers it can write the headers with a higher | 63 // compressed but not written headers it can write the headers with a higher |
64 // priority. | 64 // priority. |
65 QuicPriority EffectivePriority() const override; | 65 QuicPriority EffectivePriority() const override; |
66 | 66 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Sets priority_ to priority. This should only be called before bytes are | 111 // Sets priority_ to priority. This should only be called before bytes are |
112 // written to the server. | 112 // written to the server. |
113 void set_priority(QuicPriority priority); | 113 void set_priority(QuicPriority priority); |
114 // This is protected because external classes should use EffectivePriority | 114 // This is protected because external classes should use EffectivePriority |
115 // instead. | 115 // instead. |
116 QuicPriority priority() const { return priority_; } | 116 QuicPriority priority() const { return priority_; } |
117 | 117 |
118 bool FinishedReadingHeaders() const; | 118 bool FinishedReadingHeaders() const; |
119 | 119 |
120 private: | 120 private: |
121 friend class test::QuicDataStreamPeer; | 121 friend class test::QuicSpdyStreamPeer; |
122 friend class test::ReliableQuicStreamPeer; | 122 friend class test::ReliableQuicStreamPeer; |
123 friend class QuicStreamUtils; | 123 friend class QuicStreamUtils; |
124 | 124 |
125 QuicSpdySession* spdy_session_; | 125 QuicSpdySession* spdy_session_; |
126 | 126 |
127 Visitor* visitor_; | 127 Visitor* visitor_; |
128 // True if the headers have been completely decompressed. | 128 // True if the headers have been completely decompressed. |
129 bool headers_decompressed_; | 129 bool headers_decompressed_; |
130 // The priority of the stream, once parsed. | 130 // The priority of the stream, once parsed. |
131 QuicPriority priority_; | 131 QuicPriority priority_; |
132 // Contains a copy of the decompressed headers until they are consumed | 132 // Contains a copy of the decompressed headers until they are consumed |
133 // via ProcessData or Readv. | 133 // via ProcessData or Readv. |
134 std::string decompressed_headers_; | 134 std::string decompressed_headers_; |
135 | 135 |
136 DISALLOW_COPY_AND_ASSIGN(QuicDataStream); | 136 DISALLOW_COPY_AND_ASSIGN(QuicSpdyStream); |
137 }; | 137 }; |
138 | 138 |
139 } // namespace net | 139 } // namespace net |
140 | 140 |
141 #endif // NET_QUIC_QUIC_DATA_STREAM_H_ | 141 #endif // NET_QUIC_QUIC_SPDY_STREAM_H_ |
OLD | NEW |