OLD | NEW |
---|---|
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 #include "net/spdy/buffered_spdy_framer.h" | 5 #include "net/spdy/buffered_spdy_framer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 namespace { | |
12 | |
13 // GOAWAY frame debug data is only buffered up to this many bytes. | |
14 size_t kGoAwayDebugDataMaxSize = 1024; | |
15 | |
16 } // namespace | |
17 | |
11 SpdyMajorVersion NextProtoToSpdyMajorVersion(NextProto next_proto) { | 18 SpdyMajorVersion NextProtoToSpdyMajorVersion(NextProto next_proto) { |
12 switch (next_proto) { | 19 switch (next_proto) { |
13 case kProtoDeprecatedSPDY2: | 20 case kProtoDeprecatedSPDY2: |
14 return SPDY2; | 21 return SPDY2; |
15 case kProtoSPDY3: | 22 case kProtoSPDY3: |
16 case kProtoSPDY31: | 23 case kProtoSPDY31: |
17 return SPDY3; | 24 return SPDY3; |
18 case kProtoHTTP2: | 25 case kProtoHTTP2: |
19 return HTTP2; | 26 return HTTP2; |
20 case kProtoUnknown: | 27 case kProtoUnknown: |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 void BufferedSpdyFramer::OnPing(SpdyPingId unique_id, bool is_ack) { | 226 void BufferedSpdyFramer::OnPing(SpdyPingId unique_id, bool is_ack) { |
220 visitor_->OnPing(unique_id, is_ack); | 227 visitor_->OnPing(unique_id, is_ack); |
221 } | 228 } |
222 | 229 |
223 void BufferedSpdyFramer::OnRstStream(SpdyStreamId stream_id, | 230 void BufferedSpdyFramer::OnRstStream(SpdyStreamId stream_id, |
224 SpdyRstStreamStatus status) { | 231 SpdyRstStreamStatus status) { |
225 visitor_->OnRstStream(stream_id, status); | 232 visitor_->OnRstStream(stream_id, status); |
226 } | 233 } |
227 void BufferedSpdyFramer::OnGoAway(SpdyStreamId last_accepted_stream_id, | 234 void BufferedSpdyFramer::OnGoAway(SpdyStreamId last_accepted_stream_id, |
228 SpdyGoAwayStatus status) { | 235 SpdyGoAwayStatus status) { |
229 visitor_->OnGoAway(last_accepted_stream_id, status); | 236 DCHECK(!goaway_fields_); |
237 goaway_fields_.reset(new GoAwayFields()); | |
238 goaway_fields_->last_accepted_stream_id = last_accepted_stream_id; | |
239 goaway_fields_->status = status; | |
240 } | |
241 | |
242 bool BufferedSpdyFramer::OnGoAwayFrameData(const char* goaway_data, | |
243 size_t len) { | |
244 if (len > 0) { | |
245 goaway_fields_->debug_data.append( | |
246 goaway_data, std::min(len, kGoAwayDebugDataMaxSize - | |
247 goaway_fields_->debug_data.size())); | |
eroman
2015/10/07 17:00:51
This looks correct.
However when first reading it
Bence
2015/10/30 11:55:27
Done.
| |
248 return true; | |
249 } | |
250 visitor_->OnGoAway(goaway_fields_->last_accepted_stream_id, | |
251 goaway_fields_->status, goaway_fields_->debug_data); | |
252 goaway_fields_.reset(); | |
253 return true; | |
230 } | 254 } |
231 | 255 |
232 void BufferedSpdyFramer::OnWindowUpdate(SpdyStreamId stream_id, | 256 void BufferedSpdyFramer::OnWindowUpdate(SpdyStreamId stream_id, |
233 int delta_window_size) { | 257 int delta_window_size) { |
234 visitor_->OnWindowUpdate(stream_id, delta_window_size); | 258 visitor_->OnWindowUpdate(stream_id, delta_window_size); |
235 } | 259 } |
236 | 260 |
237 void BufferedSpdyFramer::OnPushPromise(SpdyStreamId stream_id, | 261 void BufferedSpdyFramer::OnPushPromise(SpdyStreamId stream_id, |
238 SpdyStreamId promised_stream_id, | 262 SpdyStreamId promised_stream_id, |
239 bool end) { | 263 bool end) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 SpdyFrame* BufferedSpdyFramer::CreatePingFrame(SpdyPingId unique_id, | 371 SpdyFrame* BufferedSpdyFramer::CreatePingFrame(SpdyPingId unique_id, |
348 bool is_ack) const { | 372 bool is_ack) const { |
349 SpdyPingIR ping_ir(unique_id); | 373 SpdyPingIR ping_ir(unique_id); |
350 ping_ir.set_is_ack(is_ack); | 374 ping_ir.set_is_ack(is_ack); |
351 return spdy_framer_.SerializePing(ping_ir); | 375 return spdy_framer_.SerializePing(ping_ir); |
352 } | 376 } |
353 | 377 |
354 // TODO(jgraettinger): Eliminate uses of this method (prefer SpdyGoAwayIR). | 378 // TODO(jgraettinger): Eliminate uses of this method (prefer SpdyGoAwayIR). |
355 SpdyFrame* BufferedSpdyFramer::CreateGoAway( | 379 SpdyFrame* BufferedSpdyFramer::CreateGoAway( |
356 SpdyStreamId last_accepted_stream_id, | 380 SpdyStreamId last_accepted_stream_id, |
357 SpdyGoAwayStatus status) const { | 381 SpdyGoAwayStatus status, |
358 SpdyGoAwayIR go_ir(last_accepted_stream_id, status, ""); | 382 base::StringPiece debug_data) const { |
383 SpdyGoAwayIR go_ir(last_accepted_stream_id, status, debug_data); | |
359 return spdy_framer_.SerializeGoAway(go_ir); | 384 return spdy_framer_.SerializeGoAway(go_ir); |
360 } | 385 } |
361 | 386 |
362 // TODO(jgraettinger): Eliminate uses of this method (prefer SpdyHeadersIR). | 387 // TODO(jgraettinger): Eliminate uses of this method (prefer SpdyHeadersIR). |
363 SpdyFrame* BufferedSpdyFramer::CreateHeaders( | 388 SpdyFrame* BufferedSpdyFramer::CreateHeaders( |
364 SpdyStreamId stream_id, | 389 SpdyStreamId stream_id, |
365 SpdyControlFlags flags, | 390 SpdyControlFlags flags, |
366 SpdyPriority priority, | 391 SpdyPriority priority, |
367 const SpdyHeaderBlock* headers) { | 392 const SpdyHeaderBlock* headers) { |
368 SpdyHeadersIR headers_ir(stream_id); | 393 SpdyHeadersIR headers_ir(stream_id); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 | 436 |
412 void BufferedSpdyFramer::InitHeaderStreaming(SpdyStreamId stream_id) { | 437 void BufferedSpdyFramer::InitHeaderStreaming(SpdyStreamId stream_id) { |
413 memset(header_buffer_, 0, kHeaderBufferSize); | 438 memset(header_buffer_, 0, kHeaderBufferSize); |
414 header_buffer_used_ = 0; | 439 header_buffer_used_ = 0; |
415 header_buffer_valid_ = true; | 440 header_buffer_valid_ = true; |
416 header_stream_id_ = stream_id; | 441 header_stream_id_ = stream_id; |
417 DCHECK_NE(header_stream_id_, SpdyFramer::kInvalidStream); | 442 DCHECK_NE(header_stream_id_, SpdyFramer::kInvalidStream); |
418 } | 443 } |
419 | 444 |
420 } // namespace net | 445 } // namespace net |
OLD | NEW |