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/spdy_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
10 #include "base/third_party/valgrind/memcheck.h" | 10 #include "base/third_party/valgrind/memcheck.h" |
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); | 1984 bool successful_read = reader.ReadUInt31(¤t_frame_stream_id_); |
1985 DCHECK(successful_read); | 1985 DCHECK(successful_read); |
1986 } | 1986 } |
1987 | 1987 |
1988 SpdyRstStreamStatus status = RST_STREAM_INVALID; | 1988 SpdyRstStreamStatus status = RST_STREAM_INVALID; |
1989 uint32 status_raw = status; | 1989 uint32 status_raw = status; |
1990 bool successful_read = reader.ReadUInt32(&status_raw); | 1990 bool successful_read = reader.ReadUInt32(&status_raw); |
1991 DCHECK(successful_read); | 1991 DCHECK(successful_read); |
1992 if (SpdyConstants::IsValidRstStreamStatus(protocol_version(), | 1992 if (SpdyConstants::IsValidRstStreamStatus(protocol_version(), |
1993 status_raw)) { | 1993 status_raw)) { |
1994 status = static_cast<SpdyRstStreamStatus>(status_raw); | 1994 status = |
| 1995 SpdyConstants::ParseRstStreamStatus(protocol_version(), status_raw); |
1995 } else { | 1996 } else { |
1996 if (protocol_version() > SPDY3) { | 1997 if (protocol_version() > SPDY3) { |
1997 // Treat unrecognized status codes as INTERNAL_ERROR as | 1998 // Treat unrecognized status codes as INTERNAL_ERROR as |
1998 // recommended by the HTTP/2 spec. | 1999 // recommended by the HTTP/2 spec. |
1999 status = RST_STREAM_INTERNAL_ERROR; | 2000 status = RST_STREAM_INTERNAL_ERROR; |
2000 } | 2001 } |
2001 } | 2002 } |
2002 // Finished parsing the RST_STREAM header, call frame handler. | 2003 // Finished parsing the RST_STREAM header, call frame handler. |
2003 visitor_->OnRstStream(current_frame_stream_id_, status); | 2004 visitor_->OnRstStream(current_frame_stream_id_, status); |
2004 } | 2005 } |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2477 SpdyFrameBuilder builder(expected_length, protocol_version()); | 2478 SpdyFrameBuilder builder(expected_length, protocol_version()); |
2478 | 2479 |
2479 // Serialize the RST_STREAM frame. | 2480 // Serialize the RST_STREAM frame. |
2480 if (protocol_version() <= SPDY3) { | 2481 if (protocol_version() <= SPDY3) { |
2481 builder.WriteControlFrameHeader(*this, RST_STREAM, 0); | 2482 builder.WriteControlFrameHeader(*this, RST_STREAM, 0); |
2482 builder.WriteUInt32(rst_stream.stream_id()); | 2483 builder.WriteUInt32(rst_stream.stream_id()); |
2483 } else { | 2484 } else { |
2484 builder.BeginNewFrame(*this, RST_STREAM, 0, rst_stream.stream_id()); | 2485 builder.BeginNewFrame(*this, RST_STREAM, 0, rst_stream.stream_id()); |
2485 } | 2486 } |
2486 | 2487 |
2487 builder.WriteUInt32(rst_stream.status()); | 2488 builder.WriteUInt32(SpdyConstants::SerializeRstStreamStatus( |
| 2489 protocol_version(), rst_stream.status())); |
2488 | 2490 |
2489 // In SPDY4 and up, RST_STREAM frames may also specify opaque data. | 2491 // In SPDY4 and up, RST_STREAM frames may also specify opaque data. |
2490 if (protocol_version() > SPDY3 && rst_stream.description().size() > 0) { | 2492 if (protocol_version() > SPDY3 && rst_stream.description().size() > 0) { |
2491 builder.WriteBytes(rst_stream.description().data(), | 2493 builder.WriteBytes(rst_stream.description().data(), |
2492 rst_stream.description().size()); | 2494 rst_stream.description().size()); |
2493 } | 2495 } |
2494 | 2496 |
2495 DCHECK_EQ(expected_length, builder.length()); | 2497 DCHECK_EQ(expected_length, builder.length()); |
2496 return builder.take(); | 2498 return builder.take(); |
2497 } | 2499 } |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3288 builder->Seek(compressed_size); | 3290 builder->Seek(compressed_size); |
3289 builder->RewriteLength(*this); | 3291 builder->RewriteLength(*this); |
3290 | 3292 |
3291 pre_compress_bytes.Add(uncompressed_len); | 3293 pre_compress_bytes.Add(uncompressed_len); |
3292 post_compress_bytes.Add(compressed_size); | 3294 post_compress_bytes.Add(compressed_size); |
3293 | 3295 |
3294 compressed_frames.Increment(); | 3296 compressed_frames.Increment(); |
3295 } | 3297 } |
3296 | 3298 |
3297 } // namespace net | 3299 } // namespace net |
OLD | NEW |