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 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 const size_t size_with_padding = num_padding_fields + | 2307 const size_t size_with_padding = num_padding_fields + |
2308 data_ir.data().length() + data_ir.padding_payload_len() + | 2308 data_ir.data().length() + data_ir.padding_payload_len() + |
2309 GetDataFrameMinimumSize(); | 2309 GetDataFrameMinimumSize(); |
2310 SpdyFrameBuilder builder(size_with_padding, protocol_version()); | 2310 SpdyFrameBuilder builder(size_with_padding, protocol_version()); |
2311 builder.WriteDataFrameHeader(*this, data_ir.stream_id(), flags); | 2311 builder.WriteDataFrameHeader(*this, data_ir.stream_id(), flags); |
2312 if (data_ir.padded()) { | 2312 if (data_ir.padded()) { |
2313 builder.WriteUInt8(data_ir.padding_payload_len() & 0xff); | 2313 builder.WriteUInt8(data_ir.padding_payload_len() & 0xff); |
2314 } | 2314 } |
2315 builder.WriteBytes(data_ir.data().data(), data_ir.data().length()); | 2315 builder.WriteBytes(data_ir.data().data(), data_ir.data().length()); |
2316 if (data_ir.padding_payload_len() > 0) { | 2316 if (data_ir.padding_payload_len() > 0) { |
2317 string padding = string(data_ir.padding_payload_len(), '0'); | 2317 string padding(data_ir.padding_payload_len(), 0); |
2318 builder.WriteBytes(padding.data(), padding.length()); | 2318 builder.WriteBytes(padding.data(), padding.length()); |
2319 } | 2319 } |
2320 DCHECK_EQ(size_with_padding, builder.length()); | 2320 DCHECK_EQ(size_with_padding, builder.length()); |
2321 return builder.take(); | 2321 return builder.take(); |
2322 } else { | 2322 } else { |
2323 const size_t size = GetDataFrameMinimumSize() + data_ir.data().length(); | 2323 const size_t size = GetDataFrameMinimumSize() + data_ir.data().length(); |
2324 SpdyFrameBuilder builder(size, protocol_version()); | 2324 SpdyFrameBuilder builder(size, protocol_version()); |
2325 builder.WriteDataFrameHeader(*this, data_ir.stream_id(), flags); | 2325 builder.WriteDataFrameHeader(*this, data_ir.stream_id(), flags); |
2326 builder.WriteBytes(data_ir.data().data(), data_ir.data().length()); | 2326 builder.WriteBytes(data_ir.data().data(), data_ir.data().length()); |
2327 DCHECK_EQ(size, builder.length()); | 2327 DCHECK_EQ(size, builder.length()); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3243 builder->Seek(compressed_size); | 3243 builder->Seek(compressed_size); |
3244 builder->RewriteLength(*this); | 3244 builder->RewriteLength(*this); |
3245 | 3245 |
3246 pre_compress_bytes.Add(uncompressed_len); | 3246 pre_compress_bytes.Add(uncompressed_len); |
3247 post_compress_bytes.Add(compressed_size); | 3247 post_compress_bytes.Add(compressed_size); |
3248 | 3248 |
3249 compressed_frames.Increment(); | 3249 compressed_frames.Increment(); |
3250 } | 3250 } |
3251 | 3251 |
3252 } // namespace net | 3252 } // namespace net |
OLD | NEW |