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 #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 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2961 z_stream* compressor = GetHeaderCompressor(); | 2961 z_stream* compressor = GetHeaderCompressor(); |
| 2962 // Since we'll be performing lots of flushes when compressing the data, | 2962 // Since we'll be performing lots of flushes when compressing the data, |
| 2963 // zlib's lower bounds may be insufficient. | 2963 // zlib's lower bounds may be insufficient. |
| 2964 return 2 * deflateBound(compressor, uncompressed_length); | 2964 return 2 * deflateBound(compressor, uncompressed_length); |
| 2965 } | 2965 } |
| 2966 | 2966 |
| 2967 size_t SpdyFramer::GetNumberRequiredContinuationFrames(size_t size) { | 2967 size_t SpdyFramer::GetNumberRequiredContinuationFrames(size_t size) { |
| 2968 DCHECK_GT(protocol_version(), SPDY3); | 2968 DCHECK_GT(protocol_version(), SPDY3); |
| 2969 DCHECK_GT(size, kMaxControlFrameSize); | 2969 DCHECK_GT(size, kMaxControlFrameSize); |
| 2970 size_t overflow = size - kMaxControlFrameSize; | 2970 size_t overflow = size - kMaxControlFrameSize; |
| 2971 return overflow / (kMaxControlFrameSize - GetContinuationMinimumSize()) + 1; | 2971 size_t payload_size = kMaxControlFrameSize - GetContinuationMinimumSize(); |
| 2972 // This is ceiling(overflow/payload_size) using integer arithmetics. | |
| 2973 return (overflow - 1) / payload_size + 1; | |
|
Ryan Hamilton
2015/03/09 17:50:08
Looks like this has not yet been fixed in google3'
| |
| 2972 } | 2974 } |
| 2973 | 2975 |
| 2974 void SpdyFramer::WritePayloadWithContinuation(SpdyFrameBuilder* builder, | 2976 void SpdyFramer::WritePayloadWithContinuation(SpdyFrameBuilder* builder, |
| 2975 const string& hpack_encoding, | 2977 const string& hpack_encoding, |
| 2976 SpdyStreamId stream_id, | 2978 SpdyStreamId stream_id, |
| 2977 SpdyFrameType type, | 2979 SpdyFrameType type, |
| 2978 int padding_payload_len) { | 2980 int padding_payload_len) { |
| 2979 uint8 end_flag = 0; | 2981 uint8 end_flag = 0; |
| 2980 uint8 flags = 0; | 2982 uint8 flags = 0; |
| 2981 if (type == HEADERS) { | 2983 if (type == HEADERS) { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3277 #else | 3279 #else |
| 3278 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); | 3280 WriteHeaderBlockToZ(&frame.name_value_block(), compressor); |
| 3279 #endif // defined(USE_SYSTEM_ZLIB) | 3281 #endif // defined(USE_SYSTEM_ZLIB) |
| 3280 | 3282 |
| 3281 int compressed_size = compressed_max_size - compressor->avail_out; | 3283 int compressed_size = compressed_max_size - compressor->avail_out; |
| 3282 builder->Seek(compressed_size); | 3284 builder->Seek(compressed_size); |
| 3283 builder->RewriteLength(*this); | 3285 builder->RewriteLength(*this); |
| 3284 } | 3286 } |
| 3285 | 3287 |
| 3286 } // namespace net | 3288 } // namespace net |
| OLD | NEW |