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 #include "net/quic/quic_headers_stream.h" | 5 #include "net/quic/quic_headers_stream.h" |
6 | 6 |
7 #include "net/quic/quic_session.h" | 7 #include "net/quic/quic_session.h" |
8 | 8 |
9 using base::StringPiece; | 9 using base::StringPiece; |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 : public SpdyFramerVisitorInterface, | 23 : public SpdyFramerVisitorInterface, |
24 public SpdyFramerDebugVisitorInterface { | 24 public SpdyFramerDebugVisitorInterface { |
25 public: | 25 public: |
26 explicit SpdyFramerVisitor(QuicHeadersStream* stream) : stream_(stream) {} | 26 explicit SpdyFramerVisitor(QuicHeadersStream* stream) : stream_(stream) {} |
27 | 27 |
28 // SpdyFramerVisitorInterface implementation | 28 // SpdyFramerVisitorInterface implementation |
29 virtual void OnSynStream(SpdyStreamId stream_id, | 29 virtual void OnSynStream(SpdyStreamId stream_id, |
30 SpdyStreamId associated_stream_id, | 30 SpdyStreamId associated_stream_id, |
31 SpdyPriority priority, | 31 SpdyPriority priority, |
32 bool fin, | 32 bool fin, |
33 bool unidirectional) OVERRIDE { | 33 bool unidirectional) override { |
34 if (!stream_->IsConnected()) { | 34 if (!stream_->IsConnected()) { |
35 return; | 35 return; |
36 } | 36 } |
37 | 37 |
38 if (associated_stream_id != 0) { | 38 if (associated_stream_id != 0) { |
39 CloseConnection("associated_stream_id != 0"); | 39 CloseConnection("associated_stream_id != 0"); |
40 return; | 40 return; |
41 } | 41 } |
42 | 42 |
43 if (unidirectional != 0) { | 43 if (unidirectional != 0) { |
44 CloseConnection("unidirectional != 0"); | 44 CloseConnection("unidirectional != 0"); |
45 return; | 45 return; |
46 } | 46 } |
47 | 47 |
48 stream_->OnSynStream(stream_id, priority, fin); | 48 stream_->OnSynStream(stream_id, priority, fin); |
49 } | 49 } |
50 | 50 |
51 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) OVERRIDE { | 51 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) override { |
52 if (!stream_->IsConnected()) { | 52 if (!stream_->IsConnected()) { |
53 return; | 53 return; |
54 } | 54 } |
55 | 55 |
56 stream_->OnSynReply(stream_id, fin); | 56 stream_->OnSynReply(stream_id, fin); |
57 } | 57 } |
58 | 58 |
59 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, | 59 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id, |
60 const char* header_data, | 60 const char* header_data, |
61 size_t len) OVERRIDE { | 61 size_t len) override { |
62 if (!stream_->IsConnected()) { | 62 if (!stream_->IsConnected()) { |
63 return false; | 63 return false; |
64 } | 64 } |
65 stream_->OnControlFrameHeaderData(stream_id, header_data, len); | 65 stream_->OnControlFrameHeaderData(stream_id, header_data, len); |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 virtual void OnStreamFrameData(SpdyStreamId stream_id, | 69 virtual void OnStreamFrameData(SpdyStreamId stream_id, |
70 const char* data, | 70 const char* data, |
71 size_t len, | 71 size_t len, |
72 bool fin) OVERRIDE { | 72 bool fin) override { |
73 if (fin && len == 0) { | 73 if (fin && len == 0) { |
74 // The framer invokes OnStreamFrameData with zero-length data and | 74 // The framer invokes OnStreamFrameData with zero-length data and |
75 // fin = true after processing a SYN_STREAM or SYN_REPLY frame | 75 // fin = true after processing a SYN_STREAM or SYN_REPLY frame |
76 // that had the fin bit set. | 76 // that had the fin bit set. |
77 return; | 77 return; |
78 } | 78 } |
79 CloseConnection("SPDY DATA frame received."); | 79 CloseConnection("SPDY DATA frame received."); |
80 } | 80 } |
81 | 81 |
82 virtual void OnError(SpdyFramer* framer) OVERRIDE { | 82 virtual void OnError(SpdyFramer* framer) override { |
83 CloseConnection("SPDY framing error."); | 83 CloseConnection("SPDY framing error."); |
84 } | 84 } |
85 | 85 |
86 virtual void OnDataFrameHeader(SpdyStreamId stream_id, | 86 virtual void OnDataFrameHeader(SpdyStreamId stream_id, |
87 size_t length, | 87 size_t length, |
88 bool fin) OVERRIDE { | 88 bool fin) override { |
89 CloseConnection("SPDY DATA frame received."); | 89 CloseConnection("SPDY DATA frame received."); |
90 } | 90 } |
91 | 91 |
92 virtual void OnRstStream(SpdyStreamId stream_id, | 92 virtual void OnRstStream(SpdyStreamId stream_id, |
93 SpdyRstStreamStatus status) OVERRIDE { | 93 SpdyRstStreamStatus status) override { |
94 CloseConnection("SPDY RST_STREAM frame received."); | 94 CloseConnection("SPDY RST_STREAM frame received."); |
95 } | 95 } |
96 | 96 |
97 virtual void OnSetting(SpdySettingsIds id, | 97 virtual void OnSetting(SpdySettingsIds id, |
98 uint8 flags, | 98 uint8 flags, |
99 uint32 value) OVERRIDE { | 99 uint32 value) override { |
100 CloseConnection("SPDY SETTINGS frame received."); | 100 CloseConnection("SPDY SETTINGS frame received."); |
101 } | 101 } |
102 | 102 |
103 virtual void OnSettingsAck() OVERRIDE { | 103 virtual void OnSettingsAck() override { |
104 CloseConnection("SPDY SETTINGS frame received."); | 104 CloseConnection("SPDY SETTINGS frame received."); |
105 } | 105 } |
106 | 106 |
107 virtual void OnSettingsEnd() OVERRIDE { | 107 virtual void OnSettingsEnd() override { |
108 CloseConnection("SPDY SETTINGS frame received."); | 108 CloseConnection("SPDY SETTINGS frame received."); |
109 } | 109 } |
110 | 110 |
111 virtual void OnPing(SpdyPingId unique_id, bool is_ack) OVERRIDE { | 111 virtual void OnPing(SpdyPingId unique_id, bool is_ack) override { |
112 CloseConnection("SPDY PING frame received."); | 112 CloseConnection("SPDY PING frame received."); |
113 } | 113 } |
114 | 114 |
115 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, | 115 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, |
116 SpdyGoAwayStatus status) OVERRIDE { | 116 SpdyGoAwayStatus status) override { |
117 CloseConnection("SPDY GOAWAY frame received."); | 117 CloseConnection("SPDY GOAWAY frame received."); |
118 } | 118 } |
119 | 119 |
120 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) OVERRIDE { | 120 virtual void OnHeaders(SpdyStreamId stream_id, bool fin, bool end) override { |
121 CloseConnection("SPDY HEADERS frame received."); | 121 CloseConnection("SPDY HEADERS frame received."); |
122 } | 122 } |
123 | 123 |
124 virtual void OnWindowUpdate(SpdyStreamId stream_id, | 124 virtual void OnWindowUpdate(SpdyStreamId stream_id, |
125 uint32 delta_window_size) OVERRIDE { | 125 uint32 delta_window_size) override { |
126 CloseConnection("SPDY WINDOW_UPDATE frame received."); | 126 CloseConnection("SPDY WINDOW_UPDATE frame received."); |
127 } | 127 } |
128 | 128 |
129 virtual void OnPushPromise(SpdyStreamId stream_id, | 129 virtual void OnPushPromise(SpdyStreamId stream_id, |
130 SpdyStreamId promised_stream_id, | 130 SpdyStreamId promised_stream_id, |
131 bool end) OVERRIDE { | 131 bool end) override { |
132 LOG(DFATAL) << "PUSH_PROMISE frame received from a SPDY/3 framer"; | 132 LOG(DFATAL) << "PUSH_PROMISE frame received from a SPDY/3 framer"; |
133 CloseConnection("SPDY PUSH_PROMISE frame received."); | 133 CloseConnection("SPDY PUSH_PROMISE frame received."); |
134 } | 134 } |
135 | 135 |
136 virtual void OnContinuation(SpdyStreamId stream_id, bool end) OVERRIDE { | 136 virtual void OnContinuation(SpdyStreamId stream_id, bool end) override { |
137 CloseConnection("SPDY CONTINUATION frame received."); | 137 CloseConnection("SPDY CONTINUATION frame received."); |
138 } | 138 } |
139 | 139 |
140 virtual bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) OVERRIDE { | 140 virtual bool OnUnknownFrame(SpdyStreamId stream_id, int frame_type) override { |
141 CloseConnection("SPDY unknown frame received."); | 141 CloseConnection("SPDY unknown frame received."); |
142 return false; | 142 return false; |
143 } | 143 } |
144 | 144 |
145 // SpdyFramerDebugVisitorInterface implementation | 145 // SpdyFramerDebugVisitorInterface implementation |
146 virtual void OnSendCompressedFrame(SpdyStreamId stream_id, | 146 virtual void OnSendCompressedFrame(SpdyStreamId stream_id, |
147 SpdyFrameType type, | 147 SpdyFrameType type, |
148 size_t payload_len, | 148 size_t payload_len, |
149 size_t frame_len) OVERRIDE {} | 149 size_t frame_len) override {} |
150 | 150 |
151 virtual void OnReceiveCompressedFrame(SpdyStreamId stream_id, | 151 virtual void OnReceiveCompressedFrame(SpdyStreamId stream_id, |
152 SpdyFrameType type, | 152 SpdyFrameType type, |
153 size_t frame_len) OVERRIDE { | 153 size_t frame_len) override { |
154 if (stream_->IsConnected()) { | 154 if (stream_->IsConnected()) { |
155 stream_->OnCompressedFrameSize(frame_len); | 155 stream_->OnCompressedFrameSize(frame_len); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 void CloseConnection(const string& details) { | 160 void CloseConnection(const string& details) { |
161 if (stream_->IsConnected()) { | 161 if (stream_->IsConnected()) { |
162 stream_->CloseConnectionWithDetails( | 162 stream_->CloseConnectionWithDetails( |
163 QUIC_INVALID_HEADERS_STREAM_DATA, details); | 163 QUIC_INVALID_HEADERS_STREAM_DATA, details); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 DCHECK_EQ(kInvalidStreamId, stream_id_); | 267 DCHECK_EQ(kInvalidStreamId, stream_id_); |
268 DCHECK_EQ(0u, frame_len_); | 268 DCHECK_EQ(0u, frame_len_); |
269 frame_len_ = frame_len; | 269 frame_len_ = frame_len; |
270 } | 270 } |
271 | 271 |
272 bool QuicHeadersStream::IsConnected() { | 272 bool QuicHeadersStream::IsConnected() { |
273 return session()->connection()->connected(); | 273 return session()->connection()->connected(); |
274 } | 274 } |
275 | 275 |
276 } // namespace net | 276 } // namespace net |
OLD | NEW |