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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 // Check if we're done handling this SETTINGS frame. | 1869 // Check if we're done handling this SETTINGS frame. |
1870 remaining_data_length_ -= processed_bytes; | 1870 remaining_data_length_ -= processed_bytes; |
1871 if (remaining_data_length_ == 0) { | 1871 if (remaining_data_length_ == 0) { |
1872 visitor_->OnSettingsEnd(); | 1872 visitor_->OnSettingsEnd(); |
1873 CHANGE_STATE(SPDY_FRAME_COMPLETE); | 1873 CHANGE_STATE(SPDY_FRAME_COMPLETE); |
1874 } | 1874 } |
1875 | 1875 |
1876 return processed_bytes; | 1876 return processed_bytes; |
1877 } | 1877 } |
1878 | 1878 |
1879 void SpdyFramer::DeliverHpackBlockAsSpdy3Block(size_t compressed_len) { | |
1880 DCHECK_EQ(HTTP2, protocol_version_); | |
1881 DCHECK_EQ(remaining_padding_payload_length_, remaining_data_length_); | |
1882 | |
1883 const SpdyHeaderBlock& block = GetHpackDecoder()->decoded_block(); | |
1884 if (block.empty()) { | |
1885 // Special-case this to make tests happy. | |
1886 ProcessControlFrameHeaderBlock(NULL, 0, false); | |
1887 return; | |
1888 } | |
1889 size_t payload_len = GetSerializedLength(protocol_version_, &block); | |
1890 SpdyFrameBuilder builder(payload_len, SPDY3); | |
1891 | |
1892 SerializeHeaderBlockWithoutCompression(&builder, block); | |
1893 SpdySerializedFrame frame = builder.take(); | |
1894 | |
1895 // Preserve padding length, and reset it after the re-entrant call. | |
1896 size_t remaining_padding = remaining_padding_payload_length_; | |
1897 | |
1898 remaining_padding_payload_length_ = 0; | |
1899 remaining_data_length_ = frame.size(); | |
1900 | |
1901 if (payload_len != 0) { | |
1902 int compression_pct = 100 - (100 * compressed_len) / payload_len; | |
1903 DVLOG(1) << "Net.SpdyHpackDecompressionPercentage: " << compression_pct; | |
1904 UMA_HISTOGRAM_PERCENTAGE("Net.SpdyHpackDecompressionPercentage", | |
1905 compression_pct); | |
1906 } | |
1907 | |
1908 ProcessControlFrameHeaderBlock(frame.data(), frame.size(), false); | |
1909 | |
1910 remaining_padding_payload_length_ = remaining_padding; | |
1911 remaining_data_length_ = remaining_padding; | |
1912 } | |
1913 | |
1914 bool SpdyFramer::ProcessSetting(const char* data) { | 1879 bool SpdyFramer::ProcessSetting(const char* data) { |
1915 int id_field; | 1880 int id_field; |
1916 SpdySettingsIds id; | 1881 SpdySettingsIds id; |
1917 uint8_t flags = 0; | 1882 uint8_t flags = 0; |
1918 uint32_t value; | 1883 uint32_t value; |
1919 | 1884 |
1920 // Extract fields. | 1885 // Extract fields. |
1921 // Maintain behavior of old SPDY 2 bug with byte ordering of flags/id. | 1886 // Maintain behavior of old SPDY 2 bug with byte ordering of flags/id. |
1922 if (protocol_version_ == SPDY3) { | 1887 if (protocol_version_ == SPDY3) { |
1923 const uint32_t id_and_flags_wire = | 1888 const uint32_t id_and_flags_wire = |
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3434 #else | 3399 #else |
3435 WriteHeaderBlockToZ(&frame.header_block(), compressor); | 3400 WriteHeaderBlockToZ(&frame.header_block(), compressor); |
3436 #endif // defined(USE_SYSTEM_ZLIB) | 3401 #endif // defined(USE_SYSTEM_ZLIB) |
3437 | 3402 |
3438 int compressed_size = compressed_max_size - compressor->avail_out; | 3403 int compressed_size = compressed_max_size - compressor->avail_out; |
3439 builder->Seek(compressed_size); | 3404 builder->Seek(compressed_size); |
3440 builder->RewriteLength(*this); | 3405 builder->RewriteLength(*this); |
3441 } | 3406 } |
3442 | 3407 |
3443 } // namespace net | 3408 } // namespace net |
OLD | NEW |