| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/http2_frame_decoder_adapter.h" | 5 #include "net/spdy/http2_frame_decoder_adapter.h" |
| 6 | 6 |
| 7 // Logging policy: If an error in the input is detected, VLOG(n) is used so that | 7 // Logging policy: If an error in the input is detected, VLOG(n) is used so that |
| 8 // the option exists to debug the situation. Otherwise, this code mostly uses | 8 // the option exists to debug the situation. Otherwise, this code mostly uses |
| 9 // DVLOG so that the logging does not slow down production code when things are | 9 // DVLOG so that the logging does not slow down production code when things are |
| 10 // working OK. | 10 // working OK. |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 463 } |
| 464 | 464 |
| 465 void OnWindowUpdate(const Http2FrameHeader& header, | 465 void OnWindowUpdate(const Http2FrameHeader& header, |
| 466 uint32_t increment) override { | 466 uint32_t increment) override { |
| 467 DVLOG(1) << "OnWindowUpdate: " << header << "; increment=" << increment; | 467 DVLOG(1) << "OnWindowUpdate: " << header << "; increment=" << increment; |
| 468 if (IsOkToStartFrame(header)) { | 468 if (IsOkToStartFrame(header)) { |
| 469 visitor()->OnWindowUpdate(header.stream_id, increment); | 469 visitor()->OnWindowUpdate(header.stream_id, increment); |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 | 472 |
| 473 // Per RFC7838, an ALTSVC frame on stream 0 with origin_length == 0, or one on |
| 474 // a stream other than stream 0 with origin_length != 0 MUST be ignored. All |
| 475 // frames are decoded by Http2DecoderAdapter, and it is left to the consumer |
| 476 // (listener) to implement this behavior. |
| 473 void OnAltSvcStart(const Http2FrameHeader& header, | 477 void OnAltSvcStart(const Http2FrameHeader& header, |
| 474 size_t origin_length, | 478 size_t origin_length, |
| 475 size_t value_length) override { | 479 size_t value_length) override { |
| 476 DVLOG(1) << "OnAltSvcStart: " << header | 480 DVLOG(1) << "OnAltSvcStart: " << header |
| 477 << "; origin_length: " << origin_length | 481 << "; origin_length: " << origin_length |
| 478 << "; value_length: " << value_length; | 482 << "; value_length: " << value_length; |
| 479 if (!IsOkToStartFrame(header)) { | 483 if (!IsOkToStartFrame(header)) { |
| 480 return; | 484 return; |
| 481 } | 485 } |
| 482 // Per RFC7838, origin_length must be zero IFF the stream id is non-zero. | |
| 483 if ((origin_length == 0 && !HasRequiredStreamId(header)) || | |
| 484 (origin_length != 0 && !HasRequiredStreamIdZero(header))) { | |
| 485 return; | |
| 486 } | |
| 487 frame_header_ = header; | 486 frame_header_ = header; |
| 488 has_frame_header_ = true; | 487 has_frame_header_ = true; |
| 489 alt_svc_origin_.clear(); | 488 alt_svc_origin_.clear(); |
| 490 alt_svc_value_.clear(); | 489 alt_svc_value_.clear(); |
| 491 } | 490 } |
| 492 | 491 |
| 493 void OnAltSvcOriginData(const char* data, size_t len) override { | 492 void OnAltSvcOriginData(const char* data, size_t len) override { |
| 494 DVLOG(1) << "OnAltSvcOriginData: len=" << len; | 493 DVLOG(1) << "OnAltSvcOriginData: len=" << len; |
| 495 alt_svc_origin_.append(data, len); | 494 alt_svc_origin_.append(data, len); |
| 496 } | 495 } |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 | 970 |
| 972 } // namespace | 971 } // namespace |
| 973 | 972 |
| 974 std::unique_ptr<SpdyFramerDecoderAdapter> CreateHttp2FrameDecoderAdapter( | 973 std::unique_ptr<SpdyFramerDecoderAdapter> CreateHttp2FrameDecoderAdapter( |
| 975 SpdyFramer* outer_framer) { | 974 SpdyFramer* outer_framer) { |
| 976 return std::unique_ptr<SpdyFramerDecoderAdapter>( | 975 return std::unique_ptr<SpdyFramerDecoderAdapter>( |
| 977 new Http2DecoderAdapter(outer_framer)); | 976 new Http2DecoderAdapter(outer_framer)); |
| 978 } | 977 } |
| 979 | 978 |
| 980 } // namespace net | 979 } // namespace net |
| OLD | NEW |