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/third_party/valgrind/memcheck.h" | 9 #include "base/third_party/valgrind/memcheck.h" |
10 #include "net/spdy/spdy_frame_builder.h" | 10 #include "net/spdy/spdy_frame_builder.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 bool SpdyFramerVisitorInterface::OnRstStreamFrameData( | 148 bool SpdyFramerVisitorInterface::OnRstStreamFrameData( |
149 const char* rst_stream_data, | 149 const char* rst_stream_data, |
150 size_t len) { | 150 size_t len) { |
151 return true; | 151 return true; |
152 } | 152 } |
153 | 153 |
154 SpdyFramer::SpdyFramer(SpdyMajorVersion version) | 154 SpdyFramer::SpdyFramer(SpdyMajorVersion version) |
155 : current_frame_buffer_(new char[kControlFrameBufferSize]), | 155 : current_frame_buffer_(new char[kControlFrameBufferSize]), |
156 enable_compression_(true), | 156 expect_continuation_(0), |
157 visitor_(NULL), | 157 visitor_(NULL), |
158 debug_visitor_(NULL), | 158 debug_visitor_(NULL), |
159 display_protocol_("SPDY"), | 159 display_protocol_("SPDY"), |
160 protocol_version_(version), | 160 protocol_version_(version), |
| 161 enable_compression_(true), |
161 syn_frame_processed_(false), | 162 syn_frame_processed_(false), |
162 probable_http_response_(false), | 163 probable_http_response_(false), |
163 expect_continuation_(0), | |
164 end_stream_when_done_(false) { | 164 end_stream_when_done_(false) { |
165 DCHECK_GE(protocol_version_, SPDY_MIN_VERSION); | 165 DCHECK_GE(protocol_version_, SPDY_MIN_VERSION); |
166 DCHECK_LE(protocol_version_, SPDY_MAX_VERSION); | 166 DCHECK_LE(protocol_version_, SPDY_MAX_VERSION); |
167 DCHECK_LE(kMaxControlFrameSize, | 167 DCHECK_LE(kMaxControlFrameSize, |
168 SpdyConstants::GetFrameMaximumSize(protocol_version_) + | 168 SpdyConstants::GetFrameMaximumSize(protocol_version_) + |
169 SpdyConstants::GetControlFrameHeaderSize(protocol_version_)); | 169 SpdyConstants::GetControlFrameHeaderSize(protocol_version_)); |
170 Reset(); | 170 Reset(); |
171 } | 171 } |
172 | 172 |
173 SpdyFramer::~SpdyFramer() { | 173 SpdyFramer::~SpdyFramer() { |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 | 1415 |
1416 SpdyPriority priority = 0; | 1416 SpdyPriority priority = 0; |
1417 successful_read = reader.ReadUInt8(&priority); | 1417 successful_read = reader.ReadUInt8(&priority); |
1418 DCHECK(successful_read); | 1418 DCHECK(successful_read); |
1419 if (protocol_version() <= SPDY2) { | 1419 if (protocol_version() <= SPDY2) { |
1420 priority = priority >> 6; | 1420 priority = priority >> 6; |
1421 } else { | 1421 } else { |
1422 priority = priority >> 5; | 1422 priority = priority >> 5; |
1423 } | 1423 } |
1424 | 1424 |
1425 // Seek past unused byte; used to be credential slot in SPDY 3. | 1425 // Seek past unused byte; used to be credential slot in SPDY 3. |
1426 reader.Seek(1); | 1426 reader.Seek(1); |
1427 | 1427 |
1428 DCHECK(reader.IsDoneReading()); | 1428 DCHECK(reader.IsDoneReading()); |
1429 if (debug_visitor_) { | 1429 if (debug_visitor_) { |
1430 debug_visitor_->OnReceiveCompressedFrame( | 1430 debug_visitor_->OnReceiveCompressedFrame( |
1431 current_frame_stream_id_, | 1431 current_frame_stream_id_, |
1432 current_frame_type_, | 1432 current_frame_type_, |
1433 current_frame_length_); | 1433 current_frame_length_); |
1434 } | 1434 } |
1435 visitor_->OnSynStream( | 1435 visitor_->OnSynStream( |
1436 current_frame_stream_id_, | 1436 current_frame_stream_id_, |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3277 #else | 3277 #else |
3278 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); | 3278 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); |
3279 #endif // defined(USE_SYSTEM_ZLIB) | 3279 #endif // defined(USE_SYSTEM_ZLIB) |
3280 | 3280 |
3281 int compressed_size = compressed_max_size - compressor->avail_out; | 3281 int compressed_size = compressed_max_size - compressor->avail_out; |
3282 builder->Seek(compressed_size); | 3282 builder->Seek(compressed_size); |
3283 builder->RewriteLength(*this); | 3283 builder->RewriteLength(*this); |
3284 } | 3284 } |
3285 | 3285 |
3286 } // namespace net | 3286 } // namespace net |
OLD | NEW |