Chromium Code Reviews| 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 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't | 5 // TODO(rtenhove) clean up frame buffer size calculations so that we aren't |
| 6 // constantly adding and subtracting header sizes; this is ugly and error- | 6 // constantly adding and subtracting header sizes; this is ugly and error- |
| 7 // prone. | 7 // prone. |
| 8 | 8 |
| 9 #include "net/spdy/spdy_framer.h" | 9 #include "net/spdy/spdy_framer.h" |
| 10 | 10 |
| (...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 return rv; | 1265 return rv; |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 // The following compression setting are based on Brian Olson's analysis. See | 1268 // The following compression setting are based on Brian Olson's analysis. See |
| 1269 // https://groups.google.com/group/spdy-dev/browse_thread/thread/dfaf498542fac79 2 | 1269 // https://groups.google.com/group/spdy-dev/browse_thread/thread/dfaf498542fac79 2 |
| 1270 // for more details. | 1270 // for more details. |
| 1271 static const int kCompressorLevel = 9; | 1271 static const int kCompressorLevel = 9; |
| 1272 static const int kCompressorWindowSizeInBits = 11; | 1272 static const int kCompressorWindowSizeInBits = 11; |
| 1273 static const int kCompressorMemLevel = 1; | 1273 static const int kCompressorMemLevel = 1; |
| 1274 | 1274 |
| 1275 SpdyFrame* SpdyFramer::CompressFrame(const SpdyFrame& frame) { | |
| 1276 if (frame.is_control_frame()) { | |
| 1277 return CompressControlFrame( | |
| 1278 reinterpret_cast<const SpdyControlFrame&>(frame)); | |
| 1279 } | |
| 1280 return NULL; | |
| 1281 } | |
| 1282 | |
| 1283 bool SpdyFramer::IsCompressible(const SpdyFrame& frame) const { | 1275 bool SpdyFramer::IsCompressible(const SpdyFrame& frame) const { |
| 1284 // The important frames to compress are those which contain large | 1276 // The important frames to compress are those which contain large |
| 1285 // amounts of compressible data - namely the headers in the SYN_STREAM | 1277 // amounts of compressible data - namely the headers in the SYN_STREAM |
| 1286 // and SYN_REPLY. | 1278 // and SYN_REPLY. |
| 1287 if (frame.is_control_frame()) { | 1279 if (frame.is_control_frame()) { |
| 1288 const SpdyControlFrame& control_frame = | 1280 const SpdyControlFrame& control_frame = |
| 1289 reinterpret_cast<const SpdyControlFrame&>(frame); | 1281 reinterpret_cast<const SpdyControlFrame&>(frame); |
| 1290 return control_frame.type() == SYN_STREAM || | 1282 return control_frame.type() == SYN_STREAM || |
| 1291 control_frame.type() == SYN_REPLY; | 1283 control_frame.type() == SYN_REPLY || |
| 1284 control_frame.type() == HEADERS; | |
|
hkhalil
2012/04/19 21:12:59
Should probably be a separate change so that it's
hkhalil
2012/04/19 21:12:59
Regression test for this bug?
Ryan Hamilton
2012/04/19 21:14:55
I added one in spdy_framer_test.cc :>
Ryan Hamilton
2012/04/19 21:14:55
I think it'll just as easy to do in a single CL si
hkhalil
2012/04/19 21:15:48
I mean in an end-to-end test...
| |
| 1292 } | 1285 } |
| 1293 | 1286 |
| 1294 // We don't compress Data frames. | 1287 // We don't compress Data frames. |
| 1295 return false; | 1288 return false; |
| 1296 } | 1289 } |
| 1297 | 1290 |
| 1298 z_stream* SpdyFramer::GetHeaderCompressor() { | 1291 z_stream* SpdyFramer::GetHeaderCompressor() { |
| 1299 if (header_compressor_.get()) | 1292 if (header_compressor_.get()) |
| 1300 return header_compressor_.get(); // Already initialized. | 1293 return header_compressor_.get(); // Already initialized. |
| 1301 | 1294 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1725 | 1718 |
| 1726 void SpdyFramer::set_validate_control_frame_sizes(bool value) { | 1719 void SpdyFramer::set_validate_control_frame_sizes(bool value) { |
| 1727 validate_control_frame_sizes_ = value; | 1720 validate_control_frame_sizes_ = value; |
| 1728 } | 1721 } |
| 1729 | 1722 |
| 1730 void SpdyFramer::set_enable_compression_default(bool value) { | 1723 void SpdyFramer::set_enable_compression_default(bool value) { |
| 1731 g_enable_compression_default = value; | 1724 g_enable_compression_default = value; |
| 1732 } | 1725 } |
| 1733 | 1726 |
| 1734 } // namespace net | 1727 } // namespace net |
| OLD | NEW |