diff options
author | bnc <bnc@chromium.org> | 2015-08-03 18:05:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-04 01:06:14 +0000 |
commit | 1c7061b646e6e1975e101ec4283db3f5836d45bb (patch) | |
tree | 14d9374c7fb587067080311a85b1f7a88b173d9d | |
parent | 46483baa6c11d8d883cbbf877e197721801add2f (diff) | |
download | chromium_src-1c7061b646e6e1975e101ec4283db3f5836d45bb.zip chromium_src-1c7061b646e6e1975e101ec4283db3f5836d45bb.tar.gz chromium_src-1c7061b646e6e1975e101ec4283db3f5836d45bb.tar.bz2 |
Move HPACK implementation to net/spdy/hpack directory.
This CL lands internal change 99030754 by rjshade.
BUG=488484
Review URL: https://codereview.chromium.org/1264253004
Cr-Commit-Position: refs/heads/master@{#341659}
-rw-r--r-- | net/net.gypi | 60 | ||||
-rw-r--r-- | net/spdy/fuzzing/hpack_example_generator.cc | 4 | ||||
-rw-r--r-- | net/spdy/fuzzing/hpack_fuzz_util.cc | 2 | ||||
-rw-r--r-- | net/spdy/fuzzing/hpack_fuzz_util.h | 4 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_constants.cc | 415 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_constants.h (renamed from net/spdy/hpack_constants.h) | 14 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_decoder.cc (renamed from net/spdy/hpack_decoder.cc) | 55 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_decoder.h (renamed from net/spdy/hpack_decoder.h) | 4 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_decoder_test.cc (renamed from net/spdy/hpack_decoder_test.cc) | 180 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_encoder.cc (renamed from net/spdy/hpack_encoder.cc) | 19 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_encoder.h (renamed from net/spdy/hpack_encoder.h) | 4 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_encoder_test.cc (renamed from net/spdy/hpack_encoder_test.cc) | 30 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_entry.cc (renamed from net/spdy/hpack_entry.cc) | 20 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_entry.h (renamed from net/spdy/hpack_entry.h) | 0 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_entry_test.cc (renamed from net/spdy/hpack_entry_test.cc) | 2 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_header_table.cc (renamed from net/spdy/hpack_header_table.cc) | 28 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_header_table.h (renamed from net/spdy/hpack_header_table.h) | 4 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_header_table_test.cc (renamed from net/spdy/hpack_header_table_test.cc) | 60 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_huffman_table.cc (renamed from net/spdy/hpack_huffman_table.cc) | 31 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_huffman_table.h (renamed from net/spdy/hpack_huffman_table.h) | 5 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_huffman_table_test.cc (renamed from net/spdy/hpack_huffman_table_test.cc) | 236 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_input_stream.cc (renamed from net/spdy/hpack_input_stream.cc) | 7 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_input_stream.h (renamed from net/spdy/hpack_input_stream.h) | 8 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_input_stream_test.cc (renamed from net/spdy/hpack_input_stream_test.cc) | 21 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_output_stream.cc (renamed from net/spdy/hpack_output_stream.cc) | 6 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_output_stream.h (renamed from net/spdy/hpack_output_stream.h) | 2 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_output_stream_test.cc (renamed from net/spdy/hpack_output_stream_test.cc) | 2 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_round_trip_test.cc (renamed from net/spdy/hpack_round_trip_test.cc) | 16 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_static_table.cc (renamed from net/spdy/hpack_static_table.cc) | 6 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_static_table.h (renamed from net/spdy/hpack_static_table.h) | 2 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_static_table_test.cc (renamed from net/spdy/hpack_static_table_test.cc) | 4 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_string_util.cc (renamed from net/spdy/hpack_string_util.cc) | 2 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_string_util.h (renamed from net/spdy/hpack_string_util.h) | 5 | ||||
-rw-r--r-- | net/spdy/hpack/hpack_string_util_test.cc (renamed from net/spdy/hpack_string_util_test.cc) | 2 | ||||
-rw-r--r-- | net/spdy/hpack_constants.cc | 418 | ||||
-rw-r--r-- | net/spdy/spdy_framer.cc | 2 | ||||
-rw-r--r-- | net/spdy/spdy_framer.h | 4 | ||||
-rw-r--r-- | net/spdy/spdy_framer_test.cc | 2 | ||||
-rwxr-xr-x | net/tools/build_hpack_constants.py | 5 |
39 files changed, 828 insertions, 863 deletions
diff --git a/net/net.gypi b/net/net.gypi index 1b00762..bb0b63d 100644 --- a/net/net.gypi +++ b/net/net.gypi @@ -1067,26 +1067,26 @@ 'spdy/buffered_spdy_framer.h', 'spdy/fuzzing/hpack_fuzz_util.cc', 'spdy/fuzzing/hpack_fuzz_util.h', - 'spdy/hpack_constants.cc', - 'spdy/hpack_constants.h', - 'spdy/hpack_decoder.cc', - 'spdy/hpack_decoder.h', - 'spdy/hpack_encoder.cc', - 'spdy/hpack_encoder.h', - 'spdy/hpack_entry.cc', - 'spdy/hpack_entry.h', - 'spdy/hpack_header_table.cc', - 'spdy/hpack_header_table.h', - 'spdy/hpack_huffman_table.cc', - 'spdy/hpack_huffman_table.h', - 'spdy/hpack_input_stream.cc', - 'spdy/hpack_input_stream.h', - 'spdy/hpack_output_stream.cc', - 'spdy/hpack_output_stream.h', - 'spdy/hpack_static_table.cc', - 'spdy/hpack_static_table.h', - 'spdy/hpack_string_util.cc', - 'spdy/hpack_string_util.h', + 'spdy/hpack/hpack_constants.cc', + 'spdy/hpack/hpack_constants.h', + 'spdy/hpack/hpack_decoder.cc', + 'spdy/hpack/hpack_decoder.h', + 'spdy/hpack/hpack_encoder.cc', + 'spdy/hpack/hpack_encoder.h', + 'spdy/hpack/hpack_entry.cc', + 'spdy/hpack/hpack_entry.h', + 'spdy/hpack/hpack_header_table.cc', + 'spdy/hpack/hpack_header_table.h', + 'spdy/hpack/hpack_huffman_table.cc', + 'spdy/hpack/hpack_huffman_table.h', + 'spdy/hpack/hpack_input_stream.cc', + 'spdy/hpack/hpack_input_stream.h', + 'spdy/hpack/hpack_output_stream.cc', + 'spdy/hpack/hpack_output_stream.h', + 'spdy/hpack/hpack_static_table.cc', + 'spdy/hpack/hpack_static_table.h', + 'spdy/hpack/hpack_string_util.cc', + 'spdy/hpack/hpack_string_util.h', 'spdy/spdy_bitmasks.h', 'spdy/spdy_alt_svc_wire_format.h', 'spdy/spdy_alt_svc_wire_format.cc', @@ -1694,16 +1694,16 @@ 'socket/websocket_transport_client_socket_pool_unittest.cc', 'spdy/buffered_spdy_framer_unittest.cc', 'spdy/fuzzing/hpack_fuzz_util_test.cc', - 'spdy/hpack_decoder_test.cc', - 'spdy/hpack_encoder_test.cc', - 'spdy/hpack_entry_test.cc', - 'spdy/hpack_header_table_test.cc', - 'spdy/hpack_huffman_table_test.cc', - 'spdy/hpack_input_stream_test.cc', - 'spdy/hpack_output_stream_test.cc', - 'spdy/hpack_round_trip_test.cc', - 'spdy/hpack_static_table_test.cc', - 'spdy/hpack_string_util_test.cc', + 'spdy/hpack/hpack_decoder_test.cc', + 'spdy/hpack/hpack_encoder_test.cc', + 'spdy/hpack/hpack_entry_test.cc', + 'spdy/hpack/hpack_header_table_test.cc', + 'spdy/hpack/hpack_huffman_table_test.cc', + 'spdy/hpack/hpack_input_stream_test.cc', + 'spdy/hpack/hpack_output_stream_test.cc', + 'spdy/hpack/hpack_round_trip_test.cc', + 'spdy/hpack/hpack_static_table_test.cc', + 'spdy/hpack/hpack_string_util_test.cc', 'spdy/mock_spdy_framer_visitor.cc', 'spdy/mock_spdy_framer_visitor.h', 'spdy/spdy_alt_svc_wire_format_test.cc', diff --git a/net/spdy/fuzzing/hpack_example_generator.cc b/net/spdy/fuzzing/hpack_example_generator.cc index aeebcf2..e73681b 100644 --- a/net/spdy/fuzzing/hpack_example_generator.cc +++ b/net/spdy/fuzzing/hpack_example_generator.cc @@ -8,8 +8,8 @@ #include "base/files/file_util.h" #include "base/strings/string_number_conversions.h" #include "net/spdy/fuzzing/hpack_fuzz_util.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_encoder.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_encoder.h" #include "net/spdy/spdy_protocol.h" namespace { diff --git a/net/spdy/fuzzing/hpack_fuzz_util.cc b/net/spdy/fuzzing/hpack_fuzz_util.cc index b12e9ba..6a7caf7 100644 --- a/net/spdy/fuzzing/hpack_fuzz_util.cc +++ b/net/spdy/fuzzing/hpack_fuzz_util.cc @@ -9,7 +9,7 @@ #include "base/rand_util.h" #include "base/sys_byteorder.h" -#include "net/spdy/hpack_constants.h" +#include "net/spdy/hpack/hpack_constants.h" namespace net { diff --git a/net/spdy/fuzzing/hpack_fuzz_util.h b/net/spdy/fuzzing/hpack_fuzz_util.h index df33a93..a15a3fd 100644 --- a/net/spdy/fuzzing/hpack_fuzz_util.h +++ b/net/spdy/fuzzing/hpack_fuzz_util.h @@ -11,8 +11,8 @@ #include "base/memory/scoped_ptr.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_decoder.h" -#include "net/spdy/hpack_encoder.h" +#include "net/spdy/hpack/hpack_decoder.h" +#include "net/spdy/hpack/hpack_encoder.h" namespace net { diff --git a/net/spdy/hpack/hpack_constants.cc b/net/spdy/hpack/hpack_constants.cc new file mode 100644 index 0000000..28385f9 --- /dev/null +++ b/net/spdy/hpack/hpack_constants.cc @@ -0,0 +1,415 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/spdy/hpack/hpack_constants.h" + +#include <vector> + +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/singleton.h" +#include "net/spdy/hpack/hpack_huffman_table.h" +#include "net/spdy/hpack/hpack_static_table.h" + +namespace net { + +namespace { + +// SharedHpackHuffmanTable is a Singleton wrapping a HpackHuffmanTable +// instance initialized with |kHpackHuffmanCode|. +struct SharedHpackHuffmanTable { + public: + SharedHpackHuffmanTable() { + std::vector<HpackHuffmanSymbol> code = HpackHuffmanCode(); + scoped_ptr<HpackHuffmanTable> mutable_table(new HpackHuffmanTable()); + CHECK(mutable_table->Initialize(&code[0], code.size())); + CHECK(mutable_table->IsInitialized()); + table.reset(mutable_table.release()); + } + + static SharedHpackHuffmanTable* GetInstance() { + return Singleton<SharedHpackHuffmanTable>::get(); + } + + scoped_ptr<const HpackHuffmanTable> table; +}; + +// SharedHpackStaticTable is a Singleton wrapping a HpackStaticTable +// instance initialized with |kHpackStaticTable|. +struct SharedHpackStaticTable { + public: + SharedHpackStaticTable() { + std::vector<HpackStaticEntry> static_table = HpackStaticTableVector(); + scoped_ptr<HpackStaticTable> mutable_table(new HpackStaticTable()); + mutable_table->Initialize(&static_table[0], static_table.size()); + CHECK(mutable_table->IsInitialized()); + table.reset(mutable_table.release()); + } + + static SharedHpackStaticTable* GetInstance() { + return Singleton<SharedHpackStaticTable>::get(); + } + + scoped_ptr<const HpackStaticTable> table; +}; + +} // namespace + +// Produced by applying the python program [1] with tables +// provided by [2] (inserted into the source of the python program) +// and copy-paste them into this file. +// +// [1] net/tools/build_hpack_constants.py +// [2] http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 + +// HpackHuffmanSymbol entries are initialized as {code, length, id}. +// Codes are specified in the |length| most-significant bits of |code|. +std::vector<HpackHuffmanSymbol> HpackHuffmanCode() { + static const HpackHuffmanSymbol kHpackHuffmanCode[] = { + {0xffc00000ul, 13, 0}, // 11111111|11000 + {0xffffb000ul, 23, 1}, // 11111111|11111111|1011000 + {0xfffffe20ul, 28, 2}, // 11111111|11111111|11111110|0010 + {0xfffffe30ul, 28, 3}, // 11111111|11111111|11111110|0011 + {0xfffffe40ul, 28, 4}, // 11111111|11111111|11111110|0100 + {0xfffffe50ul, 28, 5}, // 11111111|11111111|11111110|0101 + {0xfffffe60ul, 28, 6}, // 11111111|11111111|11111110|0110 + {0xfffffe70ul, 28, 7}, // 11111111|11111111|11111110|0111 + {0xfffffe80ul, 28, 8}, // 11111111|11111111|11111110|1000 + {0xffffea00ul, 24, 9}, // 11111111|11111111|11101010 + {0xfffffff0ul, 30, 10}, // 11111111|11111111|11111111|111100 + {0xfffffe90ul, 28, 11}, // 11111111|11111111|11111110|1001 + {0xfffffea0ul, 28, 12}, // 11111111|11111111|11111110|1010 + {0xfffffff4ul, 30, 13}, // 11111111|11111111|11111111|111101 + {0xfffffeb0ul, 28, 14}, // 11111111|11111111|11111110|1011 + {0xfffffec0ul, 28, 15}, // 11111111|11111111|11111110|1100 + {0xfffffed0ul, 28, 16}, // 11111111|11111111|11111110|1101 + {0xfffffee0ul, 28, 17}, // 11111111|11111111|11111110|1110 + {0xfffffef0ul, 28, 18}, // 11111111|11111111|11111110|1111 + {0xffffff00ul, 28, 19}, // 11111111|11111111|11111111|0000 + {0xffffff10ul, 28, 20}, // 11111111|11111111|11111111|0001 + {0xffffff20ul, 28, 21}, // 11111111|11111111|11111111|0010 + {0xfffffff8ul, 30, 22}, // 11111111|11111111|11111111|111110 + {0xffffff30ul, 28, 23}, // 11111111|11111111|11111111|0011 + {0xffffff40ul, 28, 24}, // 11111111|11111111|11111111|0100 + {0xffffff50ul, 28, 25}, // 11111111|11111111|11111111|0101 + {0xffffff60ul, 28, 26}, // 11111111|11111111|11111111|0110 + {0xffffff70ul, 28, 27}, // 11111111|11111111|11111111|0111 + {0xffffff80ul, 28, 28}, // 11111111|11111111|11111111|1000 + {0xffffff90ul, 28, 29}, // 11111111|11111111|11111111|1001 + {0xffffffa0ul, 28, 30}, // 11111111|11111111|11111111|1010 + {0xffffffb0ul, 28, 31}, // 11111111|11111111|11111111|1011 + {0x50000000ul, 6, 32}, // ' ' 010100 + {0xfe000000ul, 10, 33}, // '!' 11111110|00 + {0xfe400000ul, 10, 34}, // '"' 11111110|01 + {0xffa00000ul, 12, 35}, // '#' 11111111|1010 + {0xffc80000ul, 13, 36}, // '$' 11111111|11001 + {0x54000000ul, 6, 37}, // '%' 010101 + {0xf8000000ul, 8, 38}, // '&' 11111000 + {0xff400000ul, 11, 39}, // ''' 11111111|010 + {0xfe800000ul, 10, 40}, // '(' 11111110|10 + {0xfec00000ul, 10, 41}, // ')' 11111110|11 + {0xf9000000ul, 8, 42}, // '*' 11111001 + {0xff600000ul, 11, 43}, // '+' 11111111|011 + {0xfa000000ul, 8, 44}, // ',' 11111010 + {0x58000000ul, 6, 45}, // '-' 010110 + {0x5c000000ul, 6, 46}, // '.' 010111 + {0x60000000ul, 6, 47}, // '/' 011000 + {0x00000000ul, 5, 48}, // '0' 00000 + {0x08000000ul, 5, 49}, // '1' 00001 + {0x10000000ul, 5, 50}, // '2' 00010 + {0x64000000ul, 6, 51}, // '3' 011001 + {0x68000000ul, 6, 52}, // '4' 011010 + {0x6c000000ul, 6, 53}, // '5' 011011 + {0x70000000ul, 6, 54}, // '6' 011100 + {0x74000000ul, 6, 55}, // '7' 011101 + {0x78000000ul, 6, 56}, // '8' 011110 + {0x7c000000ul, 6, 57}, // '9' 011111 + {0xb8000000ul, 7, 58}, // ':' 1011100 + {0xfb000000ul, 8, 59}, // ';' 11111011 + {0xfff80000ul, 15, 60}, // '<' 11111111|1111100 + {0x80000000ul, 6, 61}, // '=' 100000 + {0xffb00000ul, 12, 62}, // '>' 11111111|1011 + {0xff000000ul, 10, 63}, // '?' 11111111|00 + {0xffd00000ul, 13, 64}, // '@' 11111111|11010 + {0x84000000ul, 6, 65}, // 'A' 100001 + {0xba000000ul, 7, 66}, // 'B' 1011101 + {0xbc000000ul, 7, 67}, // 'C' 1011110 + {0xbe000000ul, 7, 68}, // 'D' 1011111 + {0xc0000000ul, 7, 69}, // 'E' 1100000 + {0xc2000000ul, 7, 70}, // 'F' 1100001 + {0xc4000000ul, 7, 71}, // 'G' 1100010 + {0xc6000000ul, 7, 72}, // 'H' 1100011 + {0xc8000000ul, 7, 73}, // 'I' 1100100 + {0xca000000ul, 7, 74}, // 'J' 1100101 + {0xcc000000ul, 7, 75}, // 'K' 1100110 + {0xce000000ul, 7, 76}, // 'L' 1100111 + {0xd0000000ul, 7, 77}, // 'M' 1101000 + {0xd2000000ul, 7, 78}, // 'N' 1101001 + {0xd4000000ul, 7, 79}, // 'O' 1101010 + {0xd6000000ul, 7, 80}, // 'P' 1101011 + {0xd8000000ul, 7, 81}, // 'Q' 1101100 + {0xda000000ul, 7, 82}, // 'R' 1101101 + {0xdc000000ul, 7, 83}, // 'S' 1101110 + {0xde000000ul, 7, 84}, // 'T' 1101111 + {0xe0000000ul, 7, 85}, // 'U' 1110000 + {0xe2000000ul, 7, 86}, // 'V' 1110001 + {0xe4000000ul, 7, 87}, // 'W' 1110010 + {0xfc000000ul, 8, 88}, // 'X' 11111100 + {0xe6000000ul, 7, 89}, // 'Y' 1110011 + {0xfd000000ul, 8, 90}, // 'Z' 11111101 + {0xffd80000ul, 13, 91}, // '[' 11111111|11011 + {0xfffe0000ul, 19, 92}, // '\' 11111111|11111110|000 + {0xffe00000ul, 13, 93}, // ']' 11111111|11100 + {0xfff00000ul, 14, 94}, // '^' 11111111|111100 + {0x88000000ul, 6, 95}, // '_' 100010 + {0xfffa0000ul, 15, 96}, // '`' 11111111|1111101 + {0x18000000ul, 5, 97}, // 'a' 00011 + {0x8c000000ul, 6, 98}, // 'b' 100011 + {0x20000000ul, 5, 99}, // 'c' 00100 + {0x90000000ul, 6, 100}, // 'd' 100100 + {0x28000000ul, 5, 101}, // 'e' 00101 + {0x94000000ul, 6, 102}, // 'f' 100101 + {0x98000000ul, 6, 103}, // 'g' 100110 + {0x9c000000ul, 6, 104}, // 'h' 100111 + {0x30000000ul, 5, 105}, // 'i' 00110 + {0xe8000000ul, 7, 106}, // 'j' 1110100 + {0xea000000ul, 7, 107}, // 'k' 1110101 + {0xa0000000ul, 6, 108}, // 'l' 101000 + {0xa4000000ul, 6, 109}, // 'm' 101001 + {0xa8000000ul, 6, 110}, // 'n' 101010 + {0x38000000ul, 5, 111}, // 'o' 00111 + {0xac000000ul, 6, 112}, // 'p' 101011 + {0xec000000ul, 7, 113}, // 'q' 1110110 + {0xb0000000ul, 6, 114}, // 'r' 101100 + {0x40000000ul, 5, 115}, // 's' 01000 + {0x48000000ul, 5, 116}, // 't' 01001 + {0xb4000000ul, 6, 117}, // 'u' 101101 + {0xee000000ul, 7, 118}, // 'v' 1110111 + {0xf0000000ul, 7, 119}, // 'w' 1111000 + {0xf2000000ul, 7, 120}, // 'x' 1111001 + {0xf4000000ul, 7, 121}, // 'y' 1111010 + {0xf6000000ul, 7, 122}, // 'z' 1111011 + {0xfffc0000ul, 15, 123}, // '{' 11111111|1111110 + {0xff800000ul, 11, 124}, // '|' 11111111|100 + {0xfff40000ul, 14, 125}, // '}' 11111111|111101 + {0xffe80000ul, 13, 126}, // '~' 11111111|11101 + {0xffffffc0ul, 28, 127}, // 11111111|11111111|11111111|1100 + {0xfffe6000ul, 20, 128}, // 11111111|11111110|0110 + {0xffff4800ul, 22, 129}, // 11111111|11111111|010010 + {0xfffe7000ul, 20, 130}, // 11111111|11111110|0111 + {0xfffe8000ul, 20, 131}, // 11111111|11111110|1000 + {0xffff4c00ul, 22, 132}, // 11111111|11111111|010011 + {0xffff5000ul, 22, 133}, // 11111111|11111111|010100 + {0xffff5400ul, 22, 134}, // 11111111|11111111|010101 + {0xffffb200ul, 23, 135}, // 11111111|11111111|1011001 + {0xffff5800ul, 22, 136}, // 11111111|11111111|010110 + {0xffffb400ul, 23, 137}, // 11111111|11111111|1011010 + {0xffffb600ul, 23, 138}, // 11111111|11111111|1011011 + {0xffffb800ul, 23, 139}, // 11111111|11111111|1011100 + {0xffffba00ul, 23, 140}, // 11111111|11111111|1011101 + {0xffffbc00ul, 23, 141}, // 11111111|11111111|1011110 + {0xffffeb00ul, 24, 142}, // 11111111|11111111|11101011 + {0xffffbe00ul, 23, 143}, // 11111111|11111111|1011111 + {0xffffec00ul, 24, 144}, // 11111111|11111111|11101100 + {0xffffed00ul, 24, 145}, // 11111111|11111111|11101101 + {0xffff5c00ul, 22, 146}, // 11111111|11111111|010111 + {0xffffc000ul, 23, 147}, // 11111111|11111111|1100000 + {0xffffee00ul, 24, 148}, // 11111111|11111111|11101110 + {0xffffc200ul, 23, 149}, // 11111111|11111111|1100001 + {0xffffc400ul, 23, 150}, // 11111111|11111111|1100010 + {0xffffc600ul, 23, 151}, // 11111111|11111111|1100011 + {0xffffc800ul, 23, 152}, // 11111111|11111111|1100100 + {0xfffee000ul, 21, 153}, // 11111111|11111110|11100 + {0xffff6000ul, 22, 154}, // 11111111|11111111|011000 + {0xffffca00ul, 23, 155}, // 11111111|11111111|1100101 + {0xffff6400ul, 22, 156}, // 11111111|11111111|011001 + {0xffffcc00ul, 23, 157}, // 11111111|11111111|1100110 + {0xffffce00ul, 23, 158}, // 11111111|11111111|1100111 + {0xffffef00ul, 24, 159}, // 11111111|11111111|11101111 + {0xffff6800ul, 22, 160}, // 11111111|11111111|011010 + {0xfffee800ul, 21, 161}, // 11111111|11111110|11101 + {0xfffe9000ul, 20, 162}, // 11111111|11111110|1001 + {0xffff6c00ul, 22, 163}, // 11111111|11111111|011011 + {0xffff7000ul, 22, 164}, // 11111111|11111111|011100 + {0xffffd000ul, 23, 165}, // 11111111|11111111|1101000 + {0xffffd200ul, 23, 166}, // 11111111|11111111|1101001 + {0xfffef000ul, 21, 167}, // 11111111|11111110|11110 + {0xffffd400ul, 23, 168}, // 11111111|11111111|1101010 + {0xffff7400ul, 22, 169}, // 11111111|11111111|011101 + {0xffff7800ul, 22, 170}, // 11111111|11111111|011110 + {0xfffff000ul, 24, 171}, // 11111111|11111111|11110000 + {0xfffef800ul, 21, 172}, // 11111111|11111110|11111 + {0xffff7c00ul, 22, 173}, // 11111111|11111111|011111 + {0xffffd600ul, 23, 174}, // 11111111|11111111|1101011 + {0xffffd800ul, 23, 175}, // 11111111|11111111|1101100 + {0xffff0000ul, 21, 176}, // 11111111|11111111|00000 + {0xffff0800ul, 21, 177}, // 11111111|11111111|00001 + {0xffff8000ul, 22, 178}, // 11111111|11111111|100000 + {0xffff1000ul, 21, 179}, // 11111111|11111111|00010 + {0xffffda00ul, 23, 180}, // 11111111|11111111|1101101 + {0xffff8400ul, 22, 181}, // 11111111|11111111|100001 + {0xffffdc00ul, 23, 182}, // 11111111|11111111|1101110 + {0xffffde00ul, 23, 183}, // 11111111|11111111|1101111 + {0xfffea000ul, 20, 184}, // 11111111|11111110|1010 + {0xffff8800ul, 22, 185}, // 11111111|11111111|100010 + {0xffff8c00ul, 22, 186}, // 11111111|11111111|100011 + {0xffff9000ul, 22, 187}, // 11111111|11111111|100100 + {0xffffe000ul, 23, 188}, // 11111111|11111111|1110000 + {0xffff9400ul, 22, 189}, // 11111111|11111111|100101 + {0xffff9800ul, 22, 190}, // 11111111|11111111|100110 + {0xffffe200ul, 23, 191}, // 11111111|11111111|1110001 + {0xfffff800ul, 26, 192}, // 11111111|11111111|11111000|00 + {0xfffff840ul, 26, 193}, // 11111111|11111111|11111000|01 + {0xfffeb000ul, 20, 194}, // 11111111|11111110|1011 + {0xfffe2000ul, 19, 195}, // 11111111|11111110|001 + {0xffff9c00ul, 22, 196}, // 11111111|11111111|100111 + {0xffffe400ul, 23, 197}, // 11111111|11111111|1110010 + {0xffffa000ul, 22, 198}, // 11111111|11111111|101000 + {0xfffff600ul, 25, 199}, // 11111111|11111111|11110110|0 + {0xfffff880ul, 26, 200}, // 11111111|11111111|11111000|10 + {0xfffff8c0ul, 26, 201}, // 11111111|11111111|11111000|11 + {0xfffff900ul, 26, 202}, // 11111111|11111111|11111001|00 + {0xfffffbc0ul, 27, 203}, // 11111111|11111111|11111011|110 + {0xfffffbe0ul, 27, 204}, // 11111111|11111111|11111011|111 + {0xfffff940ul, 26, 205}, // 11111111|11111111|11111001|01 + {0xfffff100ul, 24, 206}, // 11111111|11111111|11110001 + {0xfffff680ul, 25, 207}, // 11111111|11111111|11110110|1 + {0xfffe4000ul, 19, 208}, // 11111111|11111110|010 + {0xffff1800ul, 21, 209}, // 11111111|11111111|00011 + {0xfffff980ul, 26, 210}, // 11111111|11111111|11111001|10 + {0xfffffc00ul, 27, 211}, // 11111111|11111111|11111100|000 + {0xfffffc20ul, 27, 212}, // 11111111|11111111|11111100|001 + {0xfffff9c0ul, 26, 213}, // 11111111|11111111|11111001|11 + {0xfffffc40ul, 27, 214}, // 11111111|11111111|11111100|010 + {0xfffff200ul, 24, 215}, // 11111111|11111111|11110010 + {0xffff2000ul, 21, 216}, // 11111111|11111111|00100 + {0xffff2800ul, 21, 217}, // 11111111|11111111|00101 + {0xfffffa00ul, 26, 218}, // 11111111|11111111|11111010|00 + {0xfffffa40ul, 26, 219}, // 11111111|11111111|11111010|01 + {0xffffffd0ul, 28, 220}, // 11111111|11111111|11111111|1101 + {0xfffffc60ul, 27, 221}, // 11111111|11111111|11111100|011 + {0xfffffc80ul, 27, 222}, // 11111111|11111111|11111100|100 + {0xfffffca0ul, 27, 223}, // 11111111|11111111|11111100|101 + {0xfffec000ul, 20, 224}, // 11111111|11111110|1100 + {0xfffff300ul, 24, 225}, // 11111111|11111111|11110011 + {0xfffed000ul, 20, 226}, // 11111111|11111110|1101 + {0xffff3000ul, 21, 227}, // 11111111|11111111|00110 + {0xffffa400ul, 22, 228}, // 11111111|11111111|101001 + {0xffff3800ul, 21, 229}, // 11111111|11111111|00111 + {0xffff4000ul, 21, 230}, // 11111111|11111111|01000 + {0xffffe600ul, 23, 231}, // 11111111|11111111|1110011 + {0xffffa800ul, 22, 232}, // 11111111|11111111|101010 + {0xffffac00ul, 22, 233}, // 11111111|11111111|101011 + {0xfffff700ul, 25, 234}, // 11111111|11111111|11110111|0 + {0xfffff780ul, 25, 235}, // 11111111|11111111|11110111|1 + {0xfffff400ul, 24, 236}, // 11111111|11111111|11110100 + {0xfffff500ul, 24, 237}, // 11111111|11111111|11110101 + {0xfffffa80ul, 26, 238}, // 11111111|11111111|11111010|10 + {0xffffe800ul, 23, 239}, // 11111111|11111111|1110100 + {0xfffffac0ul, 26, 240}, // 11111111|11111111|11111010|11 + {0xfffffcc0ul, 27, 241}, // 11111111|11111111|11111100|110 + {0xfffffb00ul, 26, 242}, // 11111111|11111111|11111011|00 + {0xfffffb40ul, 26, 243}, // 11111111|11111111|11111011|01 + {0xfffffce0ul, 27, 244}, // 11111111|11111111|11111100|111 + {0xfffffd00ul, 27, 245}, // 11111111|11111111|11111101|000 + {0xfffffd20ul, 27, 246}, // 11111111|11111111|11111101|001 + {0xfffffd40ul, 27, 247}, // 11111111|11111111|11111101|010 + {0xfffffd60ul, 27, 248}, // 11111111|11111111|11111101|011 + {0xffffffe0ul, 28, 249}, // 11111111|11111111|11111111|1110 + {0xfffffd80ul, 27, 250}, // 11111111|11111111|11111101|100 + {0xfffffda0ul, 27, 251}, // 11111111|11111111|11111101|101 + {0xfffffdc0ul, 27, 252}, // 11111111|11111111|11111101|110 + {0xfffffde0ul, 27, 253}, // 11111111|11111111|11111101|111 + {0xfffffe00ul, 27, 254}, // 11111111|11111111|11111110|000 + {0xfffffb80ul, 26, 255}, // 11111111|11111111|11111011|10 + {0xfffffffcul, 30, 256}, // EOS 11111111|11111111|11111111|111111 + }; + return std::vector<HpackHuffmanSymbol>( + kHpackHuffmanCode, kHpackHuffmanCode + arraysize(kHpackHuffmanCode)); +} + +// The "constructor" for a HpackStaticEntry that computes the lengths at +// compile time. +#define STATIC_ENTRY(name, value) \ + { name, arraysize(name) - 1, value, arraysize(value) - 1 } + +std::vector<HpackStaticEntry> HpackStaticTableVector() { + static const HpackStaticEntry kHpackStaticTable[] = { + STATIC_ENTRY(":authority", ""), // 1 + STATIC_ENTRY(":method", "GET"), // 2 + STATIC_ENTRY(":method", "POST"), // 3 + STATIC_ENTRY(":path", "/"), // 4 + STATIC_ENTRY(":path", "/index.html"), // 5 + STATIC_ENTRY(":scheme", "http"), // 6 + STATIC_ENTRY(":scheme", "https"), // 7 + STATIC_ENTRY(":status", "200"), // 8 + STATIC_ENTRY(":status", "204"), // 9 + STATIC_ENTRY(":status", "206"), // 10 + STATIC_ENTRY(":status", "304"), // 11 + STATIC_ENTRY(":status", "400"), // 12 + STATIC_ENTRY(":status", "404"), // 13 + STATIC_ENTRY(":status", "500"), // 14 + STATIC_ENTRY("accept-charset", ""), // 15 + STATIC_ENTRY("accept-encoding", "gzip, deflate"), // 16 + STATIC_ENTRY("accept-language", ""), // 17 + STATIC_ENTRY("accept-ranges", ""), // 18 + STATIC_ENTRY("accept", ""), // 19 + STATIC_ENTRY("access-control-allow-origin", ""), // 20 + STATIC_ENTRY("age", ""), // 21 + STATIC_ENTRY("allow", ""), // 22 + STATIC_ENTRY("authorization", ""), // 23 + STATIC_ENTRY("cache-control", ""), // 24 + STATIC_ENTRY("content-disposition", ""), // 25 + STATIC_ENTRY("content-encoding", ""), // 26 + STATIC_ENTRY("content-language", ""), // 27 + STATIC_ENTRY("content-length", ""), // 28 + STATIC_ENTRY("content-location", ""), // 29 + STATIC_ENTRY("content-range", ""), // 30 + STATIC_ENTRY("content-type", ""), // 31 + STATIC_ENTRY("cookie", ""), // 32 + STATIC_ENTRY("date", ""), // 33 + STATIC_ENTRY("etag", ""), // 34 + STATIC_ENTRY("expect", ""), // 35 + STATIC_ENTRY("expires", ""), // 36 + STATIC_ENTRY("from", ""), // 37 + STATIC_ENTRY("host", ""), // 38 + STATIC_ENTRY("if-match", ""), // 39 + STATIC_ENTRY("if-modified-since", ""), // 40 + STATIC_ENTRY("if-none-match", ""), // 41 + STATIC_ENTRY("if-range", ""), // 42 + STATIC_ENTRY("if-unmodified-since", ""), // 43 + STATIC_ENTRY("last-modified", ""), // 44 + STATIC_ENTRY("link", ""), // 45 + STATIC_ENTRY("location", ""), // 46 + STATIC_ENTRY("max-forwards", ""), // 47 + STATIC_ENTRY("proxy-authenticate", ""), // 48 + STATIC_ENTRY("proxy-authorization", ""), // 49 + STATIC_ENTRY("range", ""), // 50 + STATIC_ENTRY("referer", ""), // 51 + STATIC_ENTRY("refresh", ""), // 52 + STATIC_ENTRY("retry-after", ""), // 53 + STATIC_ENTRY("server", ""), // 54 + STATIC_ENTRY("set-cookie", ""), // 55 + STATIC_ENTRY("strict-transport-security", ""), // 56 + STATIC_ENTRY("transfer-encoding", ""), // 57 + STATIC_ENTRY("user-agent", ""), // 58 + STATIC_ENTRY("vary", ""), // 59 + STATIC_ENTRY("via", ""), // 60 + STATIC_ENTRY("www-authenticate", ""), // 61 + }; + return std::vector<HpackStaticEntry>( + kHpackStaticTable, kHpackStaticTable + arraysize(kHpackStaticTable)); +} + +#undef STATIC_ENTRY + +const HpackHuffmanTable& ObtainHpackHuffmanTable() { + return *SharedHpackHuffmanTable::GetInstance()->table; +} + +const HpackStaticTable& ObtainHpackStaticTable() { + return *SharedHpackStaticTable::GetInstance()->table; +} + +} // namespace net diff --git a/net/spdy/hpack_constants.h b/net/spdy/hpack/hpack_constants.h index 16fccfe..4110260 100644 --- a/net/spdy/hpack_constants.h +++ b/net/spdy/hpack/hpack_constants.h @@ -54,26 +54,26 @@ const uint32 kMaxDecodeBufferSize = 32 * 1024; // 6.2: Flag for a string literal that is stored unmodified (i.e., // without Huffman encoding). -const HpackPrefix kStringLiteralIdentityEncoded = { 0x0, 1 }; +const HpackPrefix kStringLiteralIdentityEncoded = {0x0, 1}; // 6.2: Flag for a Huffman-coded string literal. -const HpackPrefix kStringLiteralHuffmanEncoded = { 0x1, 1 }; +const HpackPrefix kStringLiteralHuffmanEncoded = {0x1, 1}; // 7.1: Opcode for an indexed header field. -const HpackPrefix kIndexedOpcode = { 0x1, 1 }; +const HpackPrefix kIndexedOpcode = {0x1, 1}; // 7.2.1: Opcode for a literal header field with incremental indexing. -const HpackPrefix kLiteralIncrementalIndexOpcode = { 0x1, 2 }; +const HpackPrefix kLiteralIncrementalIndexOpcode = {0x1, 2}; // 7.2.2: Opcode for a literal header field without indexing. -const HpackPrefix kLiteralNoIndexOpcode = { 0x0, 4 }; +const HpackPrefix kLiteralNoIndexOpcode = {0x0, 4}; // 7.2.3: Opcode for a literal header field which is never indexed. -const HpackPrefix kLiteralNeverIndexOpcode = { 0x1, 4 }; +const HpackPrefix kLiteralNeverIndexOpcode = {0x1, 4}; // 7.3: Opcode for maximum header table size update. Begins a varint-encoded // table size with a 5-bit prefix. -const HpackPrefix kHeaderTableSizeUpdateOpcode = { 0x1, 3 }; +const HpackPrefix kHeaderTableSizeUpdateOpcode = {0x1, 3}; // Returns symbol code table from "Appendix C. Huffman Code". NET_EXPORT_PRIVATE std::vector<HpackHuffmanSymbol> HpackHuffmanCode(); diff --git a/net/spdy/hpack_decoder.cc b/net/spdy/hpack/hpack_decoder.cc index 8c59437..f82cb76 100644 --- a/net/spdy/hpack_decoder.cc +++ b/net/spdy/hpack/hpack_decoder.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_decoder.h" +#include "net/spdy/hpack/hpack_decoder.h" #include <utility> #include "base/basictypes.h" #include "base/logging.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_output_stream.h" namespace net { @@ -38,8 +38,7 @@ bool HpackDecoder::HandleControlFrameHeadersData(SpdyStreamId id, if (new_size > kMaxDecodeBufferSize) { return false; } - headers_block_buffer_.insert(headers_block_buffer_.end(), - headers_data, + headers_block_buffer_.insert(headers_block_buffer_.end(), headers_data, headers_data + headers_data_length); return true; } @@ -75,7 +74,9 @@ bool HpackDecoder::HandleHeaderRepresentation(StringPiece name, // Fail if pseudo-header follows regular header. if (name.size() > 0) { if (name[0] == kPseudoHeaderPrefix) { - if (regular_header_seen_) return false; + if (regular_header_seen_) { + return false; + } } else { regular_header_seen_ = true; } @@ -93,8 +94,7 @@ bool HpackDecoder::HandleHeaderRepresentation(StringPiece name, std::make_pair(name.as_string(), value.as_string())); if (!result.second) { result.first->second.push_back('\0'); - result.first->second.insert(result.first->second.end(), - value.begin(), + result.first->second.insert(result.first->second.end(), value.begin(), value.end()); } } @@ -142,12 +142,14 @@ bool HpackDecoder::DecodeNextHeaderTableSizeUpdate( bool HpackDecoder::DecodeNextIndexedHeader(HpackInputStream* input_stream) { uint32 index = 0; - if (!input_stream->DecodeNextUint32(&index)) + if (!input_stream->DecodeNextUint32(&index)) { return false; + } const HpackEntry* entry = header_table_.GetByIndex(index); - if (entry == NULL) + if (entry == NULL) { return false; + } return HandleHeaderRepresentation(entry->name(), entry->value()); } @@ -155,35 +157,43 @@ bool HpackDecoder::DecodeNextIndexedHeader(HpackInputStream* input_stream) { bool HpackDecoder::DecodeNextLiteralHeader(HpackInputStream* input_stream, bool should_index) { StringPiece name; - if (!DecodeNextName(input_stream, &name)) + if (!DecodeNextName(input_stream, &name)) { return false; + } StringPiece value; - if (!DecodeNextStringLiteral(input_stream, false, &value)) + if (!DecodeNextStringLiteral(input_stream, false, &value)) { return false; + } - if (!HandleHeaderRepresentation(name, value)) return false; + if (!HandleHeaderRepresentation(name, value)) { + return false; + } - if (!should_index) + if (!should_index) { return true; + } ignore_result(header_table_.TryAddEntry(name, value)); return true; } -bool HpackDecoder::DecodeNextName( - HpackInputStream* input_stream, StringPiece* next_name) { +bool HpackDecoder::DecodeNextName(HpackInputStream* input_stream, + StringPiece* next_name) { uint32 index_or_zero = 0; - if (!input_stream->DecodeNextUint32(&index_or_zero)) + if (!input_stream->DecodeNextUint32(&index_or_zero)) { return false; + } - if (index_or_zero == 0) + if (index_or_zero == 0) { return DecodeNextStringLiteral(input_stream, true, next_name); + } const HpackEntry* entry = header_table_.GetByIndex(index_or_zero); if (entry == NULL) { return false; - } else if (entry->IsStatic()) { + } + if (entry->IsStatic()) { *next_name = entry->name(); } else { // |entry| could be evicted as part of this insertion. Preemptively copy. @@ -201,12 +211,11 @@ bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream, bool result = input_stream->DecodeNextHuffmanString(huffman_table_, buffer); *output = StringPiece(*buffer); return result; - } else if (input_stream->MatchPrefixAndConsume( - kStringLiteralIdentityEncoded)) { + } + if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { return input_stream->DecodeNextIdentityString(output); - } else { - return false; } + return false; } } // namespace net diff --git a/net/spdy/hpack_decoder.h b/net/spdy/hpack/hpack_decoder.h index 5bc6bae..cf78b6d 100644 --- a/net/spdy/hpack_decoder.h +++ b/net/spdy/hpack/hpack_decoder.h @@ -13,8 +13,8 @@ #include "base/macros.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_header_table.h" -#include "net/spdy/hpack_input_stream.h" +#include "net/spdy/hpack/hpack_header_table.h" +#include "net/spdy/hpack/hpack_input_stream.h" #include "net/spdy/spdy_protocol.h" // An HpackDecoder decodes header sets as outlined in diff --git a/net/spdy/hpack_decoder_test.cc b/net/spdy/hpack/hpack_decoder_test.cc index 8b6f48b..b20a9b2 100644 --- a/net/spdy/hpack_decoder_test.cc +++ b/net/spdy/hpack/hpack_decoder_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_decoder.h" +#include "net/spdy/hpack/hpack_decoder.h" #include <map> #include <string> @@ -10,9 +10,9 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/strings/string_piece.h" -#include "net/spdy/hpack_encoder.h" -#include "net/spdy/hpack_input_stream.h" -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_encoder.h" +#include "net/spdy/hpack/hpack_input_stream.h" +#include "net/spdy/hpack/hpack_output_stream.h" #include "net/spdy/spdy_test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -26,8 +26,7 @@ using std::string; class HpackDecoderPeer { public: - explicit HpackDecoderPeer(HpackDecoder* decoder) - : decoder_(decoder) {} + explicit HpackDecoderPeer(HpackDecoder* decoder) : decoder_(decoder) {} void HandleHeaderRepresentation(StringPiece name, StringPiece value) { decoder_->HandleHeaderRepresentation(name, value); @@ -35,15 +34,9 @@ class HpackDecoderPeer { bool DecodeNextName(HpackInputStream* in, StringPiece* out) { return decoder_->DecodeNextName(in, out); } - HpackHeaderTable* header_table() { - return &decoder_->header_table_; - } - void set_cookie_value(string value) { - decoder_->cookie_value_ = value; - } - string cookie_value() { - return decoder_->cookie_value_; - } + HpackHeaderTable* header_table() { return &decoder_->header_table_; } + void set_cookie_value(string value) { decoder_->cookie_value_ = value; } + string cookie_value() { return decoder_->cookie_value_; } const SpdyHeaderBlock& decoded_block() const { return decoder_->decoded_block_; } @@ -71,8 +64,7 @@ const size_t kLiteralBound = 1024; class HpackDecoderTest : public ::testing::Test { protected: HpackDecoderTest() - : decoder_(ObtainHpackHuffmanTable()), - decoder_peer_(&decoder_) {} + : decoder_(ObtainHpackHuffmanTable()), decoder_peer_(&decoder_) {} bool DecodeHeaderBlock(StringPiece str) { return decoder_.HandleControlFrameHeadersData(0, str.data(), str.size()) && @@ -90,7 +82,9 @@ class HpackDecoderTest : public ::testing::Test { return decoded_block(); } - void expectEntry(size_t index, size_t size, const string& name, + void expectEntry(size_t index, + size_t size, + const string& name, const string& value) { const HpackEntry* entry = decoder_peer_.header_table()->GetByIndex(index); EXPECT_EQ(name, entry->name()) << "index " << index; @@ -105,10 +99,10 @@ class HpackDecoderTest : public ::testing::Test { TEST_F(HpackDecoderTest, HandleControlFrameHeadersData) { // Strings under threshold are concatenated in the buffer. - EXPECT_TRUE(decoder_.HandleControlFrameHeadersData( - 0, "small string one", 16)); - EXPECT_TRUE(decoder_.HandleControlFrameHeadersData( - 0, "small string two", 16)); + EXPECT_TRUE( + decoder_.HandleControlFrameHeadersData(0, "small string one", 16)); + EXPECT_TRUE( + decoder_.HandleControlFrameHeadersData(0, "small string two", 16)); // A string which would push the buffer over the threshold is refused. EXPECT_FALSE(decoder_.HandleControlFrameHeadersData( 0, "fails", kMaxDecodeBufferSize - 32 + 1)); @@ -124,10 +118,9 @@ TEST_F(HpackDecoderTest, HandleControlFrameHeadersComplete) { decoder_.HandleControlFrameHeadersData(0, "\x82\x85", 2); decoder_.HandleControlFrameHeadersComplete(0, nullptr); - EXPECT_THAT(decoded_block(), ElementsAre( - Pair(":method", "GET"), - Pair(":path", "/index.html"), - Pair("cookie", "foobar=baz"))); + EXPECT_THAT(decoded_block(), + ElementsAre(Pair(":method", "GET"), Pair(":path", "/index.html"), + Pair("cookie", "foobar=baz"))); EXPECT_EQ(decoder_peer_.cookie_value(), ""); } @@ -161,13 +154,13 @@ TEST_F(HpackDecoderTest, HandleHeaderRepresentation) { // Finish and emit all headers. decoder_.HandleControlFrameHeadersComplete(0, nullptr); - EXPECT_THAT(decoded_block(), ElementsAre( - Pair("cookie", " part 1; part 2 ; part3; fin!"), - Pair("empty", ""), - Pair("empty-joined", string("\0foo\0\0", 6)), - Pair("joineD", string("value 1\0value 2", 15)), - Pair("joined", "not joined"), - Pair("passed-through", string("foo\0baz", 7)))); + EXPECT_THAT(decoded_block(), + ElementsAre(Pair("cookie", " part 1; part 2 ; part3; fin!"), + Pair("empty", ""), + Pair("empty-joined", string("\0foo\0\0", 6)), + Pair("joineD", string("value 1\0value 2", 15)), + Pair("joined", "not joined"), + Pair("passed-through", string("foo\0baz", 7)))); } // Decoding an encoded name with a valid string literal should work. @@ -227,15 +220,21 @@ TEST_F(HpackDecoderTest, IndexedHeaderStatic) { TEST_F(HpackDecoderTest, IndexedHeaderDynamic) { // First header block: add an entry to header table. - SpdyHeaderBlock header_set1 = - DecodeBlockExpectingSuccess("\x40\x03" "foo" "\x03" "bar"); + SpdyHeaderBlock header_set1 = DecodeBlockExpectingSuccess( + "\x40\x03" + "foo" + "\x03" + "bar"); SpdyHeaderBlock expected_header_set1; expected_header_set1["foo"] = "bar"; EXPECT_EQ(expected_header_set1, header_set1); // Second header block: add another entry to header table. - SpdyHeaderBlock header_set2 = - DecodeBlockExpectingSuccess("\xbe\x40\x04" "spam" "\x04" "eggs"); + SpdyHeaderBlock header_set2 = DecodeBlockExpectingSuccess( + "\xbe\x40\x04" + "spam" + "\x04" + "eggs"); SpdyHeaderBlock expected_header_set2; expected_header_set2["foo"] = "bar"; expected_header_set2["spam"] = "eggs"; @@ -371,8 +370,8 @@ TEST_F(HpackDecoderTest, BasicE21) { expected_header_set[":authority"] = "www.example.com"; string encoded_header_set; - EXPECT_TRUE(encoder.EncodeHeaderSet( - expected_header_set, &encoded_header_set)); + EXPECT_TRUE( + encoder.EncodeHeaderSet(expected_header_set, &encoded_header_set)); EXPECT_TRUE(DecodeHeaderBlock(encoded_header_set)); EXPECT_EQ(expected_header_set, decoded_block()); @@ -399,15 +398,15 @@ TEST_F(HpackDecoderTest, SectionD4RequestHuffmanExamples) { // | Decoded: // | www.example.com // | -> :authority: www.example.com - string first = a2b_hex("828684418cf1e3c2e5f23a6ba0ab90f4" - "ff"); + string first = a2b_hex( + "828684418cf1e3c2e5f23a6ba0ab90f4" + "ff"); header_set = DecodeBlockExpectingSuccess(first); - EXPECT_THAT(header_set, ElementsAre( - Pair(":authority", "www.example.com"), - Pair(":method", "GET"), - Pair(":path", "/"), - Pair(":scheme", "http"))); + EXPECT_THAT( + header_set, + ElementsAre(Pair(":authority", "www.example.com"), Pair(":method", "GET"), + Pair(":path", "/"), Pair(":scheme", "http"))); expectEntry(62, 57, ":authority", "www.example.com"); EXPECT_EQ(57u, decoder_peer_.header_table()->size()); @@ -437,12 +436,11 @@ TEST_F(HpackDecoderTest, SectionD4RequestHuffmanExamples) { string second = a2b_hex("828684be5886a8eb10649cbf"); header_set = DecodeBlockExpectingSuccess(second); - EXPECT_THAT(header_set, ElementsAre( - Pair(":authority", "www.example.com"), - Pair(":method", "GET"), - Pair(":path", "/"), - Pair(":scheme", "http"), - Pair("cache-control", "no-cache"))); + EXPECT_THAT( + header_set, + ElementsAre(Pair(":authority", "www.example.com"), Pair(":method", "GET"), + Pair(":path", "/"), Pair(":scheme", "http"), + Pair("cache-control", "no-cache"))); expectEntry(62, 53, "cache-control", "no-cache"); expectEntry(63, 57, ":authority", "www.example.com"); @@ -472,16 +470,16 @@ TEST_F(HpackDecoderTest, SectionD4RequestHuffmanExamples) { // | Decoded: // | custom-value // | -> custom-key: custom-value - string third = a2b_hex("828785bf408825a849e95ba97d7f89" - "25a849e95bb8e8b4bf"); + string third = a2b_hex( + "828785bf408825a849e95ba97d7f89" + "25a849e95bb8e8b4bf"); header_set = DecodeBlockExpectingSuccess(third); - EXPECT_THAT(header_set, ElementsAre( - Pair(":authority", "www.example.com"), - Pair(":method", "GET"), - Pair(":path", "/index.html"), - Pair(":scheme", "https"), - Pair("custom-key", "custom-value"))); + EXPECT_THAT( + header_set, + ElementsAre(Pair(":authority", "www.example.com"), Pair(":method", "GET"), + Pair(":path", "/index.html"), Pair(":scheme", "https"), + Pair("custom-key", "custom-value"))); expectEntry(62, 54, "custom-key", "custom-value"); expectEntry(63, 53, "cache-control", "no-cache"); @@ -535,17 +533,18 @@ TEST_F(HpackDecoderTest, SectionD6ResponseHuffmanExamples) { // | -> location: https://www.e // | xample.com - string first = a2b_hex("488264025885aec3771a4b6196d07abe" - "941054d444a8200595040b8166e082a6" - "2d1bff6e919d29ad171863c78f0b97c8" - "e9ae82ae43d3"); + string first = a2b_hex( + "488264025885aec3771a4b6196d07abe" + "941054d444a8200595040b8166e082a6" + "2d1bff6e919d29ad171863c78f0b97c8" + "e9ae82ae43d3"); header_set = DecodeBlockExpectingSuccess(first); - EXPECT_THAT(header_set, ElementsAre( - Pair(":status", "302"), - Pair("cache-control", "private"), - Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - Pair("location", "https://www.example.com"))); + EXPECT_THAT( + header_set, + ElementsAre(Pair(":status", "302"), Pair("cache-control", "private"), + Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), + Pair("location", "https://www.example.com"))); expectEntry(62, 63, "location", "https://www.example.com"); expectEntry(63, 65, "date", "Mon, 21 Oct 2013 20:13:21 GMT"); @@ -577,11 +576,11 @@ TEST_F(HpackDecoderTest, SectionD6ResponseHuffmanExamples) { string second = a2b_hex("4883640effc1c0bf"); header_set = DecodeBlockExpectingSuccess(second); - EXPECT_THAT(header_set, ElementsAre( - Pair(":status", "307"), - Pair("cache-control", "private"), - Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - Pair("location", "https://www.example.com"))); + EXPECT_THAT( + header_set, + ElementsAre(Pair(":status", "307"), Pair("cache-control", "private"), + Pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), + Pair("location", "https://www.example.com"))); expectEntry(62, 42, ":status", "307"); expectEntry(63, 63, "location", "https://www.example.com"); @@ -642,23 +641,26 @@ TEST_F(HpackDecoderTest, SectionD6ResponseHuffmanExamples) { // | -> set-cookie: foo=ASDJKHQ // | KBZXOQWEOPIUAXQWEOIU; // | max-age=3600; version=1 - string third = a2b_hex("88c16196d07abe941054d444a8200595" - "040b8166e084a62d1bffc05a839bd9ab" - "77ad94e7821dd7f2e6c7b335dfdfcd5b" - "3960d5af27087f3672c1ab270fb5291f" - "9587316065c003ed4ee5b1063d5007"); + string third = a2b_hex( + "88c16196d07abe941054d444a8200595" + "040b8166e084a62d1bffc05a839bd9ab" + "77ad94e7821dd7f2e6c7b335dfdfcd5b" + "3960d5af27087f3672c1ab270fb5291f" + "9587316065c003ed4ee5b1063d5007"); header_set = DecodeBlockExpectingSuccess(third); - EXPECT_THAT(header_set, ElementsAre( - Pair(":status", "200"), - Pair("cache-control", "private"), - Pair("content-encoding", "gzip"), - Pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - Pair("location", "https://www.example.com"), - Pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" - " max-age=3600; version=1"))); - - expectEntry(62, 98, "set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" + EXPECT_THAT( + header_set, + ElementsAre(Pair(":status", "200"), Pair("cache-control", "private"), + Pair("content-encoding", "gzip"), + Pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), + Pair("location", "https://www.example.com"), + Pair("set-cookie", + "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" + " max-age=3600; version=1"))); + + expectEntry(62, 98, "set-cookie", + "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" " max-age=3600; version=1"); expectEntry(63, 52, "content-encoding", "gzip"); expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); diff --git a/net/spdy/hpack_encoder.cc b/net/spdy/hpack/hpack_encoder.cc index 10fbb86..4509127 100644 --- a/net/spdy/hpack_encoder.cc +++ b/net/spdy/hpack/hpack_encoder.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_encoder.h" +#include "net/spdy/hpack/hpack_encoder.h" #include <algorithm> #include "base/logging.h" -#include "net/spdy/hpack_header_table.h" -#include "net/spdy/hpack_huffman_table.h" -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_header_table.h" +#include "net/spdy/hpack/hpack_huffman_table.h" +#include "net/spdy/hpack/hpack_output_stream.h" namespace net { @@ -101,8 +101,7 @@ void HpackEncoder::EmitIndexedLiteral(const Representation& representation) { header_table_.TryAddEntry(representation.first, representation.second); } -void HpackEncoder::EmitNonIndexedLiteral( - const Representation& representation) { +void HpackEncoder::EmitNonIndexedLiteral(const Representation& representation) { output_stream_.AppendPrefix(kLiteralNoIndexOpcode); output_stream_.AppendUint32(0); EmitString(representation.first); @@ -121,8 +120,9 @@ void HpackEncoder::EmitLiteral(const Representation& representation) { } void HpackEncoder::EmitString(StringPiece str) { - size_t encoded_size = (!allow_huffman_compression_ ? str.size() - : huffman_table_.EncodedSize(str)); + size_t encoded_size = + (!allow_huffman_compression_ ? str.size() + : huffman_table_.EncodedSize(str)); if (encoded_size < str.size()) { output_stream_.AppendPrefix(kStringLiteralHuffmanEncoded); output_stream_.AppendUint32(encoded_size); @@ -178,8 +178,7 @@ void HpackEncoder::CookieToCrumbs(const Representation& cookie, } // Sort crumbs and remove duplicates. std::sort(out->begin() + prior_size, out->end()); - out->erase(std::unique(out->begin() + prior_size, out->end()), - out->end()); + out->erase(std::unique(out->begin() + prior_size, out->end()), out->end()); } // static diff --git a/net/spdy/hpack_encoder.h b/net/spdy/hpack/hpack_encoder.h index 07e7088..fc85603 100644 --- a/net/spdy/hpack_encoder.h +++ b/net/spdy/hpack/hpack_encoder.h @@ -14,8 +14,8 @@ #include "base/macros.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_header_table.h" -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_header_table.h" +#include "net/spdy/hpack/hpack_output_stream.h" #include "net/spdy/spdy_protocol.h" // An HpackEncoder encodes header sets as outlined in diff --git a/net/spdy/hpack_encoder_test.cc b/net/spdy/hpack/hpack_encoder_test.cc index 5abe49f..02867cc 100644 --- a/net/spdy/hpack_encoder_test.cc +++ b/net/spdy/hpack/hpack_encoder_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_encoder.h" +#include "net/spdy/hpack/hpack_encoder.h" #include <map> #include <string> @@ -20,8 +20,7 @@ namespace test { class HpackHeaderTablePeer { public: - explicit HpackHeaderTablePeer(HpackHeaderTable* table) - : table_(table) {} + explicit HpackHeaderTablePeer(HpackHeaderTable* table) : table_(table) {} HpackHeaderTable::EntryTable* dynamic_entries() { return &table_->dynamic_entries_; @@ -36,24 +35,15 @@ class HpackEncoderPeer { typedef HpackEncoder::Representation Representation; typedef HpackEncoder::Representations Representations; - explicit HpackEncoderPeer(HpackEncoder* encoder) - : encoder_(encoder) {} + explicit HpackEncoderPeer(HpackEncoder* encoder) : encoder_(encoder) {} - HpackHeaderTable* table() { - return &encoder_->header_table_; - } - HpackHeaderTablePeer table_peer() { - return HpackHeaderTablePeer(table()); - } + HpackHeaderTable* table() { return &encoder_->header_table_; } + HpackHeaderTablePeer table_peer() { return HpackHeaderTablePeer(table()); } void set_allow_huffman_compression(bool allow) { encoder_->allow_huffman_compression_ = allow; } - void EmitString(StringPiece str) { - encoder_->EmitString(str); - } - void TakeString(string* out) { - encoder_->output_stream_.TakeString(out); - } + void EmitString(StringPiece str) { encoder_->EmitString(str); } + void TakeString(string* out) { encoder_->output_stream_.TakeString(out); } void UpdateCharacterCounts(StringPiece str) { encoder_->UpdateCharacterCounts(str); } @@ -262,7 +252,7 @@ TEST_F(HpackEncoderTest, StringsDynamicallySelectHuffmanCoding) { peer_.EmitString("feedbeef"); expected_.AppendPrefix(kStringLiteralHuffmanEncoded); expected_.AppendUint32(6); - expected_.AppendBytes("\x94\xA5\x92""2\x96_"); + expected_.AppendBytes("\x94\xA5\x92\x32\x96_"); // Non-compactable. Uses identity coding. peer_.EmitString("@@@@@@"); @@ -406,7 +396,9 @@ TEST_F(HpackEncoderTest, UpdateCharacterCounts) { size_t total_counts = 0; encoder_.SetCharCountsStorage(&counts, &total_counts); - char kTestString[] = "foo\0\1\xff""boo"; + char kTestString[] = + "foo\0\1\xff" + "boo"; peer_.UpdateCharacterCounts( StringPiece(kTestString, arraysize(kTestString) - 1)); diff --git a/net/spdy/hpack_entry.cc b/net/spdy/hpack/hpack_entry.cc index 169298e..c4c51ba 100644 --- a/net/spdy/hpack_entry.cc +++ b/net/spdy/hpack/hpack_entry.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_entry.h" +#include "net/spdy/hpack/hpack_entry.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" -#include "net/spdy/hpack_string_util.h" +#include "net/spdy/hpack/hpack_string_util.h" namespace net { @@ -21,20 +21,15 @@ HpackEntry::HpackEntry(StringPiece name, : name_(name.data(), name.size()), value_(value.data(), value.size()), insertion_index_(insertion_index), - type_(is_static ? STATIC : DYNAMIC) { -} + type_(is_static ? STATIC : DYNAMIC) {} HpackEntry::HpackEntry(StringPiece name, StringPiece value) : name_(name.data(), name.size()), value_(value.data(), value.size()), insertion_index_(0), - type_(LOOKUP) { -} + type_(LOOKUP) {} -HpackEntry::HpackEntry() - : insertion_index_(0), - type_(LOOKUP) { -} +HpackEntry::HpackEntry() : insertion_index_(0), type_(LOOKUP) {} HpackEntry::~HpackEntry() {} @@ -47,9 +42,8 @@ size_t HpackEntry::Size() const { } std::string HpackEntry::GetDebugString() const { - return "{ name: \"" + name_ + - "\", value: \"" + value_ + - "\", " + (IsStatic() ? "static" : "dynamic") + " }"; + return "{ name: \"" + name_ + "\", value: \"" + value_ + "\", " + + (IsStatic() ? "static" : "dynamic") + " }"; } } // namespace net diff --git a/net/spdy/hpack_entry.h b/net/spdy/hpack/hpack_entry.h index 887b515..887b515 100644 --- a/net/spdy/hpack_entry.h +++ b/net/spdy/hpack/hpack_entry.h diff --git a/net/spdy/hpack_entry_test.cc b/net/spdy/hpack/hpack_entry_test.cc index 0a9a0a2..eb7de1c 100644 --- a/net/spdy/hpack_entry_test.cc +++ b/net/spdy/hpack/hpack_entry_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_entry.h" +#include "net/spdy/hpack/hpack_entry.h" #include <string> diff --git a/net/spdy/hpack_header_table.cc b/net/spdy/hpack/hpack_header_table.cc index 044c59d..b80116e 100644 --- a/net/spdy/hpack_header_table.cc +++ b/net/spdy/hpack/hpack_header_table.cc @@ -2,21 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_header_table.h" +#include "net/spdy/hpack/hpack_header_table.h" #include <algorithm> #include "base/logging.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_static_table.h" -#include "net/spdy/hpack_string_util.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_static_table.h" +#include "net/spdy/hpack/hpack_string_util.h" namespace net { using base::StringPiece; -bool HpackHeaderTable::EntryComparator::operator() ( - const HpackEntry* lhs, const HpackEntry* rhs) const { +bool HpackHeaderTable::EntryComparator::operator()( + const HpackEntry* lhs, + const HpackEntry* rhs) const { int result = lhs->name().compare(rhs->name()); if (result != 0) return result < 0; @@ -79,16 +80,14 @@ const HpackEntry* HpackHeaderTable::GetByNameAndValue(StringPiece name, HpackEntry query(name, value); { OrderedEntrySet::const_iterator it = static_index_.lower_bound(&query); - if (it != static_index_.end() && - (*it)->name() == name && + if (it != static_index_.end() && (*it)->name() == name && (*it)->value() == value) { return *it; } } { OrderedEntrySet::const_iterator it = dynamic_index_.lower_bound(&query); - if (it != dynamic_index_.end() && - (*it)->name() == name && + if (it != dynamic_index_.end() && (*it)->name() == name && (*it)->value() == value) { return *it; } @@ -175,8 +174,7 @@ const HpackEntry* HpackHeaderTable::TryAddEntry(StringPiece name, DCHECK_EQ(0u, size_); return NULL; } - dynamic_entries_.push_front(HpackEntry(name, - value, + dynamic_entries_.push_front(HpackEntry(name, value, false, // is_static total_insertions_)); CHECK(dynamic_index_.insert(&dynamic_entries_.front()).second); @@ -190,17 +188,17 @@ const HpackEntry* HpackHeaderTable::TryAddEntry(StringPiece name, void HpackHeaderTable::DebugLogTableState() const { DVLOG(2) << "Dynamic table:"; for (EntryTable::const_iterator it = dynamic_entries_.begin(); - it != dynamic_entries_.end(); ++it) { + it != dynamic_entries_.end(); ++it) { DVLOG(2) << " " << it->GetDebugString(); } DVLOG(2) << "Full Static Index:"; for (OrderedEntrySet::const_iterator it = static_index_.begin(); - it != static_index_.end(); ++it) { + it != static_index_.end(); ++it) { DVLOG(2) << " " << (*it)->GetDebugString(); } DVLOG(2) << "Full Dynamic Index:"; for (OrderedEntrySet::const_iterator it = dynamic_index_.begin(); - it != dynamic_index_.end(); ++it) { + it != dynamic_index_.end(); ++it) { DVLOG(2) << " " << (*it)->GetDebugString(); } } diff --git a/net/spdy/hpack_header_table.h b/net/spdy/hpack/hpack_header_table.h index def42af..57c41db 100644 --- a/net/spdy/hpack_header_table.h +++ b/net/spdy/hpack/hpack_header_table.h @@ -12,7 +12,7 @@ #include "base/basictypes.h" #include "base/macros.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_entry.h" +#include "net/spdy/hpack/hpack_entry.h" // All section references below are to // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 @@ -43,7 +43,7 @@ class NET_EXPORT_PRIVATE HpackHeaderTable { // composed with the 'lookup' HpackEntry constructor to allow for efficient // lower-bounding of matching entries. struct NET_EXPORT_PRIVATE EntryComparator { - bool operator() (const HpackEntry* lhs, const HpackEntry* rhs) const; + bool operator()(const HpackEntry* lhs, const HpackEntry* rhs) const; }; typedef std::set<HpackEntry*, EntryComparator> OrderedEntrySet; diff --git a/net/spdy/hpack_header_table_test.cc b/net/spdy/hpack/hpack_header_table_test.cc index 647cd03..dc73010 100644 --- a/net/spdy/hpack_header_table_test.cc +++ b/net/spdy/hpack/hpack_header_table_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_header_table.h" +#include "net/spdy/hpack/hpack_header_table.h" #include <algorithm> #include <set> @@ -11,8 +11,8 @@ #include "base/basictypes.h" #include "base/macros.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_entry.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_entry.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { @@ -25,8 +25,7 @@ namespace test { class HpackHeaderTablePeer { public: - explicit HpackHeaderTablePeer(HpackHeaderTable* table) - : table_(table) {} + explicit HpackHeaderTablePeer(HpackHeaderTable* table) : table_(table) {} const HpackHeaderTable::EntryTable& dynamic_entries() { return table_->dynamic_entries_; @@ -46,21 +45,15 @@ class HpackHeaderTablePeer { } return result; } - size_t total_insertions() { - return table_->total_insertions_; - } - size_t dynamic_entries_count() { - return table_->dynamic_entries_.size(); - } + size_t total_insertions() { return table_->total_insertions_; } + size_t dynamic_entries_count() { return table_->dynamic_entries_.size(); } size_t EvictionCountForEntry(StringPiece name, StringPiece value) { return table_->EvictionCountForEntry(name, value); } size_t EvictionCountToReclaim(size_t reclaim_size) { return table_->EvictionCountToReclaim(reclaim_size); } - void Evict(size_t count) { - return table_->Evict(count); - } + void Evict(size_t count) { return table_->Evict(count); } void AddDynamicEntry(StringPiece name, StringPiece value) { table_->dynamic_entries_.push_back( @@ -203,8 +196,9 @@ TEST_F(HpackHeaderTableTest, EntryIndexing) { // Static entries are queryable by name & value. EXPECT_EQ(first_static_entry, table_.GetByName(first_static_entry->name())); - EXPECT_EQ(first_static_entry, table_.GetByNameAndValue( - first_static_entry->name(), first_static_entry->value())); + EXPECT_EQ(first_static_entry, + table_.GetByNameAndValue(first_static_entry->name(), + first_static_entry->value())); // Create a mix of entries which duplicate names, and names & values of both // dynamic and static entries. @@ -244,8 +238,8 @@ TEST_F(HpackHeaderTableTest, EntryIndexing) { EXPECT_EQ(first_static_entry, table_.GetByNameAndValue(first_static_entry->name(), first_static_entry->value())); - EXPECT_EQ(entry2, table_.GetByNameAndValue(first_static_entry->name(), - "Value Four")); + EXPECT_EQ(entry2, + table_.GetByNameAndValue(first_static_entry->name(), "Value Four")); EXPECT_EQ(NULL, table_.GetByNameAndValue("key-1", "Not Present")); EXPECT_EQ(NULL, table_.GetByNameAndValue("not-present", "Value One")); @@ -253,15 +247,15 @@ TEST_F(HpackHeaderTableTest, EntryIndexing) { // |entry2| remains queryable. peer_.Evict(1); EXPECT_EQ(first_static_entry, - table_.GetByNameAndValue(first_static_entry->name(), - first_static_entry->value())); - EXPECT_EQ(entry2, table_.GetByNameAndValue(first_static_entry->name(), - "Value Four")); + table_.GetByNameAndValue(first_static_entry->name(), + first_static_entry->value())); + EXPECT_EQ(entry2, + table_.GetByNameAndValue(first_static_entry->name(), "Value Four")); // Evict |entry2|. Queries by its name & value are not found. peer_.Evict(1); - EXPECT_EQ(NULL, table_.GetByNameAndValue(first_static_entry->name(), - "Value Four")); + EXPECT_EQ(NULL, + table_.GetByNameAndValue(first_static_entry->name(), "Value Four")); } TEST_F(HpackHeaderTableTest, SetSizes) { @@ -283,7 +277,7 @@ TEST_F(HpackHeaderTableTest, SetSizes) { // Changing SETTINGS_HEADER_TABLE_SIZE doesn't affect table_.max_size(), // iff SETTINGS_HEADER_TABLE_SIZE >= |max_size|. EXPECT_EQ(kDefaultHeaderTableSizeSetting, table_.settings_size_bound()); - table_.SetSettingsHeaderTableSize(kDefaultHeaderTableSizeSetting*2); + table_.SetSettingsHeaderTableSize(kDefaultHeaderTableSizeSetting * 2); EXPECT_EQ(max_size, table_.max_size()); table_.SetSettingsHeaderTableSize(max_size + 1); EXPECT_EQ(max_size, table_.max_size()); @@ -344,12 +338,12 @@ TEST_F(HpackHeaderTableTest, TryAddEntryBasic) { // size down to evict an entry one at a time. Make sure the eviction // happens as expected. TEST_F(HpackHeaderTableTest, SetMaxSize) { - HpackEntryVector entries = MakeEntriesOfTotalSize( - kDefaultHeaderTableSizeSetting / 2); + HpackEntryVector entries = + MakeEntriesOfTotalSize(kDefaultHeaderTableSizeSetting / 2); AddEntriesExpectNoEviction(entries); - for (HpackEntryVector::iterator it = entries.begin(); - it != entries.end(); ++it) { + for (HpackEntryVector::iterator it = entries.begin(); it != entries.end(); + ++it) { size_t expected_count = distance(it, entries.end()); EXPECT_EQ(expected_count, peer_.dynamic_entries().size()); @@ -379,8 +373,8 @@ TEST_F(HpackHeaderTableTest, TryAddEntryEviction) { MakeEntryOfSize(table_.max_size() - survivor_entry->Size()); // All dynamic entries but the first are to be evicted. - EXPECT_EQ(peer_.dynamic_entries().size() - 1, peer_.EvictionSet( - long_entry.name(), long_entry.value()).size()); + EXPECT_EQ(peer_.dynamic_entries().size() - 1, + peer_.EvictionSet(long_entry.name(), long_entry.value()).size()); const HpackEntry* new_entry = table_.TryAddEntry(long_entry.name(), long_entry.value()); @@ -399,8 +393,8 @@ TEST_F(HpackHeaderTableTest, TryAddTooLargeEntry) { const HpackEntry long_entry = MakeEntryOfSize(table_.max_size() + 1); // All entries are to be evicted. - EXPECT_EQ(peer_.dynamic_entries().size(), peer_.EvictionSet( - long_entry.name(), long_entry.value()).size()); + EXPECT_EQ(peer_.dynamic_entries().size(), + peer_.EvictionSet(long_entry.name(), long_entry.value()).size()); const HpackEntry* new_entry = table_.TryAddEntry(long_entry.name(), long_entry.value()); diff --git a/net/spdy/hpack_huffman_table.cc b/net/spdy/hpack/hpack_huffman_table.cc index d9cff25..8815e60 100644 --- a/net/spdy/hpack_huffman_table.cc +++ b/net/spdy/hpack/hpack_huffman_table.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_huffman_table.h" +#include "net/spdy/hpack/hpack_huffman_table.h" #include <algorithm> #include <cmath> #include "base/logging.h" #include "base/numerics/safe_conversions.h" -#include "net/spdy/hpack_input_stream.h" -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_input_stream.h" +#include "net/spdy/hpack/hpack_output_stream.h" namespace net { @@ -31,21 +31,20 @@ bool SymbolLengthAndIdCompare(const HpackHuffmanSymbol& a, } return a.length < b.length; } -bool SymbolIdCompare(const HpackHuffmanSymbol& a, - const HpackHuffmanSymbol& b) { +bool SymbolIdCompare(const HpackHuffmanSymbol& a, const HpackHuffmanSymbol& b) { return a.id < b.id; } } // namespace HpackHuffmanTable::DecodeEntry::DecodeEntry() - : next_table_index(0), length(0), symbol_id(0) { -} + : next_table_index(0), length(0), symbol_id(0) {} HpackHuffmanTable::DecodeEntry::DecodeEntry(uint8 next_table_index, uint8 length, uint16 symbol_id) - : next_table_index(next_table_index), length(length), symbol_id(symbol_id) { -} + : next_table_index(next_table_index), + length(length), + symbol_id(symbol_id) {} size_t HpackHuffmanTable::DecodeTable::size() const { return size_t(1) << indexed_length; } @@ -75,14 +74,14 @@ bool HpackHuffmanTable::Initialize(const HpackHuffmanSymbol* input_symbols, return false; } for (size_t i = 1; i != symbols.size(); i++) { - unsigned code_shift = 32 - symbols[i-1].length; - uint32 code = symbols[i-1].code + (1 << code_shift); + unsigned code_shift = 32 - symbols[i - 1].length; + uint32 code = symbols[i - 1].code + (1 << code_shift); if (code != symbols[i].code) { failed_symbol_id_ = symbols[i].id; return false; } - if (code < symbols[i-1].code) { + if (code < symbols[i - 1].code) { // An integer overflow occurred. This implies the input // lengths do not represent a valid Huffman code. failed_symbol_id_ = symbols[i].id; @@ -148,10 +147,10 @@ void HpackHuffmanTable::BuildDecodeTables(const std::vector<Symbol>& symbols) { // First visit to this placeholder. We need to create a new table. CHECK_EQ(entry.next_table_index, 0); entry.length = it->length; - entry.next_table_index = AddDecodeTable( - total_indexed, // Becomes the new table prefix. - std::min<uint8>(kDecodeTableBranchBits, - entry.length - total_indexed)); + entry.next_table_index = + AddDecodeTable(total_indexed, // Becomes the new table prefix. + std::min<uint8>(kDecodeTableBranchBits, + entry.length - total_indexed)); SetEntry(table, index, entry); } CHECK_NE(entry.next_table_index, table_index); diff --git a/net/spdy/hpack_huffman_table.h b/net/spdy/hpack/hpack_huffman_table.h index 55352d4..1904a7b 100644 --- a/net/spdy/hpack_huffman_table.h +++ b/net/spdy/hpack/hpack_huffman_table.h @@ -12,7 +12,7 @@ #include "base/basictypes.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_constants.h" +#include "net/spdy/hpack/hpack_constants.h" namespace net { @@ -103,7 +103,8 @@ class NET_EXPORT_PRIVATE HpackHuffmanTable { const DecodeEntry& Entry(const DecodeTable& table, uint32 index) const; - void SetEntry(const DecodeTable& table, uint32 index, + void SetEntry(const DecodeTable& table, + uint32 index, const DecodeEntry& entry); std::vector<DecodeTable> decode_tables_; diff --git a/net/spdy/hpack_huffman_table_test.cc b/net/spdy/hpack/hpack_huffman_table_test.cc index a8dc196..a48ccb4 100644 --- a/net/spdy/hpack_huffman_table_test.cc +++ b/net/spdy/hpack/hpack_huffman_table_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_huffman_table.h" +#include "net/spdy/hpack/hpack_huffman_table.h" #include <bitset> #include <string> #include "base/logging.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_input_stream.h" -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_input_stream.h" +#include "net/spdy/hpack/hpack_output_stream.h" #include "net/spdy/spdy_test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -30,11 +30,9 @@ typedef HpackHuffmanTable::DecodeTable DecodeTable; class HpackHuffmanTablePeer { public: explicit HpackHuffmanTablePeer(const HpackHuffmanTable& table) - : table_(table) { } + : table_(table) {} - const std::vector<uint32>& code_by_id() const { - return table_.code_by_id_; - } + const std::vector<uint32>& code_by_id() const { return table_.code_by_id_; } const std::vector<uint8>& length_by_id() const { return table_.length_by_id_; } @@ -45,9 +43,7 @@ class HpackHuffmanTablePeer { // Cast to match signed-ness of bits8(). return static_cast<char>(table_.pad_bits_); } - uint16 failed_symbol_id() const { - return table_.failed_symbol_id_; - } + uint16 failed_symbol_id() const { return table_.failed_symbol_id_; } std::vector<DecodeEntry> decode_entries(const DecodeTable& decode_table) { std::vector<DecodeEntry>::const_iterator begin = table_.decode_entries_.begin() + decode_table.entries_offset; @@ -62,9 +58,7 @@ namespace { class HpackHuffmanTableTest : public ::testing::Test { protected: - HpackHuffmanTableTest() - : table_(), - peer_(table_) {} + HpackHuffmanTableTest() : table_(), peer_(table_) {} string EncodeString(StringPiece input) { string result; @@ -85,8 +79,7 @@ MATCHER(DecodeEntryEq, "") { const DecodeEntry& lhs = std::tr1::get<0>(arg); const DecodeEntry& rhs = std::tr1::get<1>(arg); return lhs.next_table_index == rhs.next_table_index && - lhs.length == rhs.length && - lhs.symbol_id == rhs.symbol_id; + lhs.length == rhs.length && lhs.symbol_id == rhs.symbol_id; } uint32 bits32(const string& bitstring) { @@ -107,28 +100,28 @@ TEST_F(HpackHuffmanTableTest, InitializeEdgeCases) { { // Verify eight symbols can be encoded with 3 bits per symbol. HpackHuffmanSymbol code[] = { - {bits32("00000000000000000000000000000000"), 3, 0}, - {bits32("00100000000000000000000000000000"), 3, 1}, - {bits32("01000000000000000000000000000000"), 3, 2}, - {bits32("01100000000000000000000000000000"), 3, 3}, - {bits32("10000000000000000000000000000000"), 3, 4}, - {bits32("10100000000000000000000000000000"), 3, 5}, - {bits32("11000000000000000000000000000000"), 3, 6}, - {bits32("11100000000000000000000000000000"), 8, 7}}; + {bits32("00000000000000000000000000000000"), 3, 0}, + {bits32("00100000000000000000000000000000"), 3, 1}, + {bits32("01000000000000000000000000000000"), 3, 2}, + {bits32("01100000000000000000000000000000"), 3, 3}, + {bits32("10000000000000000000000000000000"), 3, 4}, + {bits32("10100000000000000000000000000000"), 3, 5}, + {bits32("11000000000000000000000000000000"), 3, 6}, + {bits32("11100000000000000000000000000000"), 8, 7}}; HpackHuffmanTable table; EXPECT_TRUE(table.Initialize(code, arraysize(code))); } { // But using 2 bits with one symbol overflows the code. HpackHuffmanSymbol code[] = { - {bits32("01000000000000000000000000000000"), 3, 0}, - {bits32("01100000000000000000000000000000"), 3, 1}, - {bits32("00000000000000000000000000000000"), 2, 2}, - {bits32("10000000000000000000000000000000"), 3, 3}, - {bits32("10100000000000000000000000000000"), 3, 4}, - {bits32("11000000000000000000000000000000"), 3, 5}, - {bits32("11100000000000000000000000000000"), 3, 6}, - {bits32("00000000000000000000000000000000"), 8, 7}}; // Overflow. + {bits32("01000000000000000000000000000000"), 3, 0}, + {bits32("01100000000000000000000000000000"), 3, 1}, + {bits32("00000000000000000000000000000000"), 2, 2}, + {bits32("10000000000000000000000000000000"), 3, 3}, + {bits32("10100000000000000000000000000000"), 3, 4}, + {bits32("11000000000000000000000000000000"), 3, 5}, + {bits32("11100000000000000000000000000000"), 3, 6}, + {bits32("00000000000000000000000000000000"), 8, 7}}; // Overflow. HpackHuffmanTable table; EXPECT_FALSE(table.Initialize(code, arraysize(code))); EXPECT_EQ(7, HpackHuffmanTablePeer(table).failed_symbol_id()); @@ -136,20 +129,20 @@ TEST_F(HpackHuffmanTableTest, InitializeEdgeCases) { { // Verify four symbols can be encoded with incremental bits per symbol. HpackHuffmanSymbol code[] = { - {bits32("00000000000000000000000000000000"), 1, 0}, - {bits32("10000000000000000000000000000000"), 2, 1}, - {bits32("11000000000000000000000000000000"), 3, 2}, - {bits32("11100000000000000000000000000000"), 8, 3}}; + {bits32("00000000000000000000000000000000"), 1, 0}, + {bits32("10000000000000000000000000000000"), 2, 1}, + {bits32("11000000000000000000000000000000"), 3, 2}, + {bits32("11100000000000000000000000000000"), 8, 3}}; HpackHuffmanTable table; EXPECT_TRUE(table.Initialize(code, arraysize(code))); } { // But repeating a length overflows the code. HpackHuffmanSymbol code[] = { - {bits32("00000000000000000000000000000000"), 1, 0}, - {bits32("10000000000000000000000000000000"), 2, 1}, - {bits32("11000000000000000000000000000000"), 2, 2}, - {bits32("00000000000000000000000000000000"), 8, 3}}; // Overflow. + {bits32("00000000000000000000000000000000"), 1, 0}, + {bits32("10000000000000000000000000000000"), 2, 1}, + {bits32("11000000000000000000000000000000"), 2, 2}, + {bits32("00000000000000000000000000000000"), 8, 3}}; // Overflow. HpackHuffmanTable table; EXPECT_FALSE(table.Initialize(code, arraysize(code))); EXPECT_EQ(3, HpackHuffmanTablePeer(table).failed_symbol_id()); @@ -157,10 +150,10 @@ TEST_F(HpackHuffmanTableTest, InitializeEdgeCases) { { // Symbol IDs must be assigned sequentially with no gaps. HpackHuffmanSymbol code[] = { - {bits32("00000000000000000000000000000000"), 1, 0}, - {bits32("10000000000000000000000000000000"), 2, 1}, - {bits32("11000000000000000000000000000000"), 3, 1}, // Repeat. - {bits32("11100000000000000000000000000000"), 8, 3}}; + {bits32("00000000000000000000000000000000"), 1, 0}, + {bits32("10000000000000000000000000000000"), 2, 1}, + {bits32("11000000000000000000000000000000"), 3, 1}, // Repeat. + {bits32("11100000000000000000000000000000"), 8, 3}}; HpackHuffmanTable table; EXPECT_FALSE(table.Initialize(code, arraysize(code))); EXPECT_EQ(2, HpackHuffmanTablePeer(table).failed_symbol_id()); @@ -168,10 +161,10 @@ TEST_F(HpackHuffmanTableTest, InitializeEdgeCases) { { // Canonical codes must begin with zero. HpackHuffmanSymbol code[] = { - {bits32("10000000000000000000000000000000"), 4, 0}, - {bits32("10010000000000000000000000000000"), 4, 1}, - {bits32("10100000000000000000000000000000"), 4, 2}, - {bits32("10110000000000000000000000000000"), 8, 3}}; + {bits32("10000000000000000000000000000000"), 4, 0}, + {bits32("10010000000000000000000000000000"), 4, 1}, + {bits32("10100000000000000000000000000000"), 4, 2}, + {bits32("10110000000000000000000000000000"), 8, 3}}; HpackHuffmanTable table; EXPECT_FALSE(table.Initialize(code, arraysize(code))); EXPECT_EQ(0, HpackHuffmanTablePeer(table).failed_symbol_id()); @@ -179,10 +172,10 @@ TEST_F(HpackHuffmanTableTest, InitializeEdgeCases) { { // Codes must match the expected canonical sequence. HpackHuffmanSymbol code[] = { - {bits32("00000000000000000000000000000000"), 2, 0}, - {bits32("01000000000000000000000000000000"), 2, 1}, - {bits32("11000000000000000000000000000000"), 2, 2}, // Not canonical. - {bits32("10000000000000000000000000000000"), 8, 3}}; + {bits32("00000000000000000000000000000000"), 2, 0}, + {bits32("01000000000000000000000000000000"), 2, 1}, + {bits32("11000000000000000000000000000000"), 2, 2}, // Not canonical. + {bits32("10000000000000000000000000000000"), 8, 3}}; HpackHuffmanTable table; EXPECT_FALSE(table.Initialize(code, arraysize(code))); EXPECT_EQ(2, HpackHuffmanTablePeer(table).failed_symbol_id()); @@ -190,10 +183,10 @@ TEST_F(HpackHuffmanTableTest, InitializeEdgeCases) { { // At least one code must have a length of 8 bits (to ensure pad-ability). HpackHuffmanSymbol code[] = { - {bits32("00000000000000000000000000000000"), 1, 0}, - {bits32("10000000000000000000000000000000"), 2, 1}, - {bits32("11000000000000000000000000000000"), 3, 2}, - {bits32("11100000000000000000000000000000"), 7, 3}}; + {bits32("00000000000000000000000000000000"), 1, 0}, + {bits32("10000000000000000000000000000000"), 2, 1}, + {bits32("11000000000000000000000000000000"), 3, 2}, + {bits32("11100000000000000000000000000000"), 7, 3}}; HpackHuffmanTable table; EXPECT_FALSE(table.Initialize(code, arraysize(code))); } @@ -201,14 +194,14 @@ TEST_F(HpackHuffmanTableTest, InitializeEdgeCases) { TEST_F(HpackHuffmanTableTest, ValidateInternalsWithSmallCode) { HpackHuffmanSymbol code[] = { - {bits32("01100000000000000000000000000000"), 4, 0}, // 3rd. - {bits32("01110000000000000000000000000000"), 4, 1}, // 4th. - {bits32("00000000000000000000000000000000"), 2, 2}, // 1st assigned code. - {bits32("01000000000000000000000000000000"), 3, 3}, // 2nd. - {bits32("10000000000000000000000000000000"), 5, 4}, // 5th. - {bits32("10001000000000000000000000000000"), 5, 5}, // 6th. - {bits32("10011000000000000000000000000000"), 8, 6}, // 8th. - {bits32("10010000000000000000000000000000"), 5, 7}}; // 7th. + {bits32("01100000000000000000000000000000"), 4, 0}, // 3rd. + {bits32("01110000000000000000000000000000"), 4, 1}, // 4th. + {bits32("00000000000000000000000000000000"), 2, 2}, // 1st assigned code. + {bits32("01000000000000000000000000000000"), 3, 3}, // 2nd. + {bits32("10000000000000000000000000000000"), 5, 4}, // 5th. + {bits32("10001000000000000000000000000000"), 5, 5}, // 6th. + {bits32("10011000000000000000000000000000"), 8, 6}, // 8th. + {bits32("10010000000000000000000000000000"), 5, 7}}; // 7th. EXPECT_TRUE(table_.Initialize(code, arraysize(code))); ASSERT_EQ(arraysize(code), peer_.code_by_id().size()); ASSERT_EQ(arraysize(code), peer_.length_by_id().size()); @@ -228,7 +221,7 @@ TEST_F(HpackHuffmanTableTest, ValidateInternalsWithSmallCode) { expected.resize(288, DecodeEntry(0, 5, 5)); // Fills 16. expected.resize(304, DecodeEntry(0, 5, 7)); // Fills 16. expected.resize(306, DecodeEntry(0, 8, 6)); // Fills 2. - expected.resize(512, DecodeEntry()); // Remainder is empty. + expected.resize(512, DecodeEntry()); // Remainder is empty. EXPECT_THAT(peer_.decode_entries(peer_.decode_tables()[0]), Pointwise(DecodeEntryEq(), expected)); @@ -238,10 +231,8 @@ TEST_F(HpackHuffmanTableTest, ValidateInternalsWithSmallCode) { char input_storage[] = {2, 3, 2, 7, 4}; StringPiece input(input_storage, arraysize(input_storage)); // By symbol: (2) 00 (3) 010 (2) 00 (7) 10010 (4) 10000 (6 as pad) 1001100. - char expect_storage[] = { - bits8("00010001"), - bits8("00101000"), - bits8("01001100")}; + char expect_storage[] = {bits8("00010001"), bits8("00101000"), + bits8("01001100")}; StringPiece expect(expect_storage, arraysize(expect_storage)); string buffer_in = EncodeString(input); @@ -249,27 +240,27 @@ TEST_F(HpackHuffmanTableTest, ValidateInternalsWithSmallCode) { string buffer_out; HpackInputStream input_stream(kuint32max, buffer_in); - EXPECT_TRUE(table_.DecodeString(&input_stream, input.size(), &buffer_out)); + EXPECT_TRUE(table_.DecodeString(&input_stream, input.size(), &buffer_out)); EXPECT_EQ(buffer_out, input); } TEST_F(HpackHuffmanTableTest, ValidateMultiLevelDecodeTables) { HpackHuffmanSymbol code[] = { - {bits32("00000000000000000000000000000000"), 6, 0}, - {bits32("00000100000000000000000000000000"), 6, 1}, - {bits32("00001000000000000000000000000000"), 11, 2}, - {bits32("00001000001000000000000000000000"), 11, 3}, - {bits32("00001000010000000000000000000000"), 12, 4}, + {bits32("00000000000000000000000000000000"), 6, 0}, + {bits32("00000100000000000000000000000000"), 6, 1}, + {bits32("00001000000000000000000000000000"), 11, 2}, + {bits32("00001000001000000000000000000000"), 11, 3}, + {bits32("00001000010000000000000000000000"), 12, 4}, }; EXPECT_TRUE(table_.Initialize(code, arraysize(code))); EXPECT_EQ(2u, peer_.decode_tables().size()); { std::vector<DecodeEntry> expected; - expected.resize(8, DecodeEntry(0, 6, 0)); // Fills 8. - expected.resize(16, DecodeEntry(0, 6, 1)); // Fills 8. + expected.resize(8, DecodeEntry(0, 6, 0)); // Fills 8. + expected.resize(16, DecodeEntry(0, 6, 1)); // Fills 8. expected.resize(17, DecodeEntry(1, 12, 0)); // Pointer. Fills 1. - expected.resize(512, DecodeEntry()); // Remainder is empty. + expected.resize(512, DecodeEntry()); // Remainder is empty. const DecodeTable& decode_table = peer_.decode_tables()[0]; EXPECT_EQ(decode_table.prefix_length, 0); @@ -282,7 +273,7 @@ TEST_F(HpackHuffmanTableTest, ValidateMultiLevelDecodeTables) { expected.resize(2, DecodeEntry(1, 11, 2)); // Fills 2. expected.resize(4, DecodeEntry(1, 11, 3)); // Fills 2. expected.resize(5, DecodeEntry(1, 12, 4)); // Fills 1. - expected.resize(8, DecodeEntry()); // Remainder is empty. + expected.resize(8, DecodeEntry()); // Remainder is empty. const DecodeTable& decode_table = peer_.decode_tables()[1]; EXPECT_EQ(decode_table.prefix_length, 9); @@ -295,15 +286,15 @@ TEST_F(HpackHuffmanTableTest, ValidateMultiLevelDecodeTables) { TEST_F(HpackHuffmanTableTest, DecodeWithBadInput) { HpackHuffmanSymbol code[] = { - {bits32("01100000000000000000000000000000"), 4, 0}, - {bits32("01110000000000000000000000000000"), 4, 1}, - {bits32("00000000000000000000000000000000"), 2, 2}, - {bits32("01000000000000000000000000000000"), 3, 3}, - {bits32("10000000000000000000000000000000"), 5, 4}, - {bits32("10001000000000000000000000000000"), 5, 5}, - {bits32("10011000000000000000000000000000"), 6, 6}, - {bits32("10010000000000000000000000000000"), 5, 7}, - {bits32("10011100000000000000000000000000"), 16, 8}}; + {bits32("01100000000000000000000000000000"), 4, 0}, + {bits32("01110000000000000000000000000000"), 4, 1}, + {bits32("00000000000000000000000000000000"), 2, 2}, + {bits32("01000000000000000000000000000000"), 3, 3}, + {bits32("10000000000000000000000000000000"), 5, 4}, + {bits32("10001000000000000000000000000000"), 5, 5}, + {bits32("10011000000000000000000000000000"), 6, 6}, + {bits32("10010000000000000000000000000000"), 5, 7}, + {bits32("10011100000000000000000000000000"), 16, 8}}; EXPECT_TRUE(table_.Initialize(code, arraysize(code))); string buffer; @@ -357,23 +348,23 @@ TEST_F(HpackHuffmanTableTest, SpecRequestExamples) { string buffer; string test_table[] = { - a2b_hex("f1e3c2e5f23a6ba0ab90f4ff"), - "www.example.com", - a2b_hex("a8eb10649cbf"), - "no-cache", - a2b_hex("25a849e95ba97d7f"), - "custom-key", - a2b_hex("25a849e95bb8e8b4bf"), - "custom-value", + a2b_hex("f1e3c2e5f23a6ba0ab90f4ff"), + "www.example.com", + a2b_hex("a8eb10649cbf"), + "no-cache", + a2b_hex("25a849e95ba97d7f"), + "custom-key", + a2b_hex("25a849e95bb8e8b4bf"), + "custom-value", }; // Round-trip each test example. for (size_t i = 0; i != arraysize(test_table); i += 2) { const string& encodedFixture(test_table[i]); - const string& decodedFixture(test_table[i+1]); + const string& decodedFixture(test_table[i + 1]); HpackInputStream input_stream(kuint32max, encodedFixture); - EXPECT_TRUE(table_.DecodeString(&input_stream, decodedFixture.size(), - &buffer)); + EXPECT_TRUE( + table_.DecodeString(&input_stream, decodedFixture.size(), &buffer)); EXPECT_EQ(decodedFixture, buffer); buffer = EncodeString(decodedFixture); EXPECT_EQ(encodedFixture, buffer); @@ -386,29 +377,25 @@ TEST_F(HpackHuffmanTableTest, SpecResponseExamples) { string buffer; string test_table[] = { - a2b_hex("6402"), - "302", - a2b_hex("aec3771a4b"), - "private", - a2b_hex("d07abe941054d444a8200595040b8166" - "e082a62d1bff"), - "Mon, 21 Oct 2013 20:13:21 GMT", - a2b_hex("9d29ad171863c78f0b97c8e9ae82ae43" - "d3"), - "https://www.example.com", - a2b_hex("94e7821dd7f2e6c7b335dfdfcd5b3960" - "d5af27087f3672c1ab270fb5291f9587" - "316065c003ed4ee5b1063d5007"), - "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", + a2b_hex("6402"), "302", a2b_hex("aec3771a4b"), "private", + a2b_hex("d07abe941054d444a8200595040b8166" + "e082a62d1bff"), + "Mon, 21 Oct 2013 20:13:21 GMT", + a2b_hex("9d29ad171863c78f0b97c8e9ae82ae43" + "d3"), + "https://www.example.com", a2b_hex("94e7821dd7f2e6c7b335dfdfcd5b3960" + "d5af27087f3672c1ab270fb5291f9587" + "316065c003ed4ee5b1063d5007"), + "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", }; // Round-trip each test example. for (size_t i = 0; i != arraysize(test_table); i += 2) { const string& encodedFixture(test_table[i]); - const string& decodedFixture(test_table[i+1]); + const string& decodedFixture(test_table[i + 1]); HpackInputStream input_stream(kuint32max, encodedFixture); - EXPECT_TRUE(table_.DecodeString(&input_stream, decodedFixture.size(), - &buffer)); + EXPECT_TRUE( + table_.DecodeString(&input_stream, decodedFixture.size(), &buffer)); EXPECT_EQ(decodedFixture, buffer); buffer = EncodeString(decodedFixture); EXPECT_EQ(encodedFixture, buffer); @@ -437,7 +424,6 @@ TEST_F(HpackHuffmanTableTest, RoundTripSymbolSequence) { std::vector<HpackHuffmanSymbol> code = HpackHuffmanCode(); EXPECT_TRUE(table_.Initialize(&code[0], code.size())); - char storage[512]; for (size_t i = 0; i != 256; i++) { storage[i] = static_cast<char>(i); @@ -458,17 +444,17 @@ TEST_F(HpackHuffmanTableTest, EncodedSizeAgreesWithEncodeString) { EXPECT_TRUE(table_.Initialize(&code[0], code.size())); string test_table[] = { - "", - "Mon, 21 Oct 2013 20:13:21 GMT", - "https://www.example.com", - "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", - string(1, '\0'), - string("foo\0bar", 7), - string(256, '\0'), + "", + "Mon, 21 Oct 2013 20:13:21 GMT", + "https://www.example.com", + "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", + string(1, '\0'), + string("foo\0bar", 7), + string(256, '\0'), }; for (size_t i = 0; i != 256; ++i) { // Expand last |test_table| entry to cover all codes. - test_table[arraysize(test_table)-1][i] = static_cast<char>(i); + test_table[arraysize(test_table) - 1][i] = static_cast<char>(i); } HpackOutputStream output_stream; diff --git a/net/spdy/hpack_input_stream.cc b/net/spdy/hpack/hpack_input_stream.cc index 87a3af4..255509e6 100644 --- a/net/spdy/hpack_input_stream.cc +++ b/net/spdy/hpack/hpack_input_stream.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_input_stream.h" +#include "net/spdy/hpack/hpack_input_stream.h" #include <algorithm> @@ -119,9 +119,8 @@ bool HpackInputStream::DecodeNextHuffmanString(const HpackHuffmanTable& table, if (encoded_size > buffer_.size()) return false; - HpackInputStream bounded_reader( - max_string_literal_size_, - StringPiece(buffer_.data(), encoded_size)); + HpackInputStream bounded_reader(max_string_literal_size_, + StringPiece(buffer_.data(), encoded_size)); buffer_.remove_prefix(encoded_size); // HpackHuffmanTable will not decode beyond |max_string_literal_size_|. diff --git a/net/spdy/hpack_input_stream.h b/net/spdy/hpack/hpack_input_stream.h index 72b637c3..c640223 100644 --- a/net/spdy/hpack_input_stream.h +++ b/net/spdy/hpack/hpack_input_stream.h @@ -11,8 +11,8 @@ #include "base/macros.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_huffman_table.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_huffman_table.h" // All section references below are to // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 @@ -59,9 +59,7 @@ class NET_EXPORT_PRIVATE HpackInputStream { // Accessors for testing. - void SetBitOffsetForTest(size_t bit_offset) { - bit_offset_ = bit_offset; - } + void SetBitOffsetForTest(size_t bit_offset) { bit_offset_ = bit_offset; } private: const uint32 max_string_literal_size_; diff --git a/net/spdy/hpack_input_stream_test.cc b/net/spdy/hpack/hpack_input_stream_test.cc index a88acb2..002c170 100644 --- a/net/spdy/hpack_input_stream_test.cc +++ b/net/spdy/hpack/hpack_input_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_input_stream.h" +#include "net/spdy/hpack/hpack_input_stream.h" #include <bitset> #include <string> @@ -10,7 +10,7 @@ #include "base/logging.h" #include "base/strings/string_piece.h" -#include "net/spdy/hpack_constants.h" +#include "net/spdy/hpack/hpack_constants.h" #include "net/spdy/spdy_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -36,13 +36,14 @@ class HpackInputStreamTest : public ::testing::Test { }; // Hex representation of encoded length and Huffman string. -const char kEncodedHuffmanFixture[] = "2d" // Length prefix. - "94e7821dd7f2e6c7b335dfdfcd5b3960" - "d5af27087f3672c1ab270fb5291f9587" - "316065c003ed4ee5b1063d5007"; +const char kEncodedHuffmanFixture[] = + "2d" // Length prefix. + "94e7821dd7f2e6c7b335dfdfcd5b3960" + "d5af27087f3672c1ab270fb5291f9587" + "316065c003ed4ee5b1063d5007"; const char kDecodedHuffmanFixture[] = - "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"; + "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"; // Utility function to decode an assumed-valid uint32 with an N-bit // prefix. @@ -518,7 +519,7 @@ TEST_F(HpackInputStreamTest, DecodeNextIdentityStringNotEnoughInput) { TEST_F(HpackInputStreamTest, DecodeNextHuffmanString) { string output, input(a2b_hex(kEncodedHuffmanFixture)); - HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture)-1, input); + HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture) - 1, input); EXPECT_TRUE(input_stream.HasMoreData()); EXPECT_TRUE(input_stream.DecodeNextHuffmanString(huffman_table_, &output)); @@ -529,7 +530,7 @@ TEST_F(HpackInputStreamTest, DecodeNextHuffmanString) { TEST_F(HpackInputStreamTest, DecodeNextHuffmanStringSizeLimit) { string output, input(a2b_hex(kEncodedHuffmanFixture)); // Max string literal is one byte shorter than the decoded fixture. - HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture)-2, input); + HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture) - 2, input); // Decoded string overflows the max string literal. EXPECT_TRUE(input_stream.HasMoreData()); @@ -539,7 +540,7 @@ TEST_F(HpackInputStreamTest, DecodeNextHuffmanStringSizeLimit) { TEST_F(HpackInputStreamTest, DecodeNextHuffmanStringNotEnoughInput) { string output, input(a2b_hex(kEncodedHuffmanFixture)); input[0]++; // Input prefix is one byte larger than available input. - HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture)-1, input); + HpackInputStream input_stream(arraysize(kDecodedHuffmanFixture) - 1, input); // Not enough buffer for declared encoded length. EXPECT_TRUE(input_stream.HasMoreData()); diff --git a/net/spdy/hpack_output_stream.cc b/net/spdy/hpack/hpack_output_stream.cc index d8eb54b..d2342b1 100644 --- a/net/spdy/hpack_output_stream.cc +++ b/net/spdy/hpack/hpack_output_stream.cc @@ -2,18 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_output_stream.h" #include "base/logging.h" - namespace net { using base::StringPiece; using std::string; -HpackOutputStream::HpackOutputStream() - : bit_offset_(0) {} +HpackOutputStream::HpackOutputStream() : bit_offset_(0) {} HpackOutputStream::~HpackOutputStream() {} diff --git a/net/spdy/hpack_output_stream.h b/net/spdy/hpack/hpack_output_stream.h index c607e49..5063900 100644 --- a/net/spdy/hpack_output_stream.h +++ b/net/spdy/hpack/hpack_output_stream.h @@ -12,7 +12,7 @@ #include "base/macros.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_constants.h" +#include "net/spdy/hpack/hpack_constants.h" // All section references below are to // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 diff --git a/net/spdy/hpack_output_stream_test.cc b/net/spdy/hpack/hpack_output_stream_test.cc index f8e0780..48b5dcc 100644 --- a/net/spdy/hpack_output_stream_test.cc +++ b/net/spdy/hpack/hpack_output_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_output_stream.h" +#include "net/spdy/hpack/hpack_output_stream.h" #include <cstddef> diff --git a/net/spdy/hpack_round_trip_test.cc b/net/spdy/hpack/hpack_round_trip_test.cc index cd34afd..1dd2f6e 100644 --- a/net/spdy/hpack_round_trip_test.cc +++ b/net/spdy/hpack/hpack_round_trip_test.cc @@ -9,9 +9,9 @@ #include <vector> #include "base/rand_util.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_decoder.h" -#include "net/spdy/hpack_encoder.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_decoder.h" +#include "net/spdy/hpack/hpack_encoder.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { @@ -38,8 +38,8 @@ class HpackRoundTripTest : public ::testing::Test { string encoded; encoder_.EncodeHeaderSet(header_set, &encoded); - bool success = decoder_.HandleControlFrameHeadersData( - 1, encoded.data(), encoded.size()); + bool success = decoder_.HandleControlFrameHeadersData(1, encoded.data(), + encoded.size()); success &= decoder_.HandleControlFrameHeadersComplete(1, nullptr); EXPECT_EQ(header_set, decoder_.decoded_block()); @@ -47,8 +47,7 @@ class HpackRoundTripTest : public ::testing::Test { } size_t SampleExponential(size_t mean, size_t sanity_bound) { - return std::min<size_t>(-std::log(base::RandDouble()) * mean, - sanity_bound); + return std::min<size_t>(-std::log(base::RandDouble()) * mean, sanity_bound); } HpackEncoder encoder_; @@ -79,7 +78,8 @@ TEST_F(HpackRoundTripTest, ResponseFixtures) { headers["content-encoding"] = "gzip"; headers["date"] = "Mon, 21 Oct 2013 20:13:22 GMT"; headers["location"] = "https://www.example.com"; - headers["set-cookie"] = "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" + headers["set-cookie"] = + "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" " max-age=3600; version=1"; headers["multivalue"] = string("foo\0bar", 7); EXPECT_TRUE(RoundTrip(headers)); diff --git a/net/spdy/hpack_static_table.cc b/net/spdy/hpack/hpack_static_table.cc index da2793d..8ee1d0b 100644 --- a/net/spdy/hpack_static_table.cc +++ b/net/spdy/hpack/hpack_static_table.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_static_table.h" +#include "net/spdy/hpack/hpack_static_table.h" #include "base/logging.h" -#include "net/spdy/hpack_constants.h" -#include "net/spdy/hpack_entry.h" +#include "net/spdy/hpack/hpack_constants.h" +#include "net/spdy/hpack/hpack_entry.h" namespace net { diff --git a/net/spdy/hpack_static_table.h b/net/spdy/hpack/hpack_static_table.h index eb343ba..e7e0fd4 100644 --- a/net/spdy/hpack_static_table.h +++ b/net/spdy/hpack/hpack_static_table.h @@ -5,7 +5,7 @@ #ifndef NET_SPDY_HPACK_STATIC_TABLE_H_ #define NET_SPDY_HPACK_STATIC_TABLE_H_ -#include "net/spdy/hpack_header_table.h" +#include "net/spdy/hpack/hpack_header_table.h" namespace net { diff --git a/net/spdy/hpack_static_table_test.cc b/net/spdy/hpack/hpack_static_table_test.cc index a13d737..441668f 100644 --- a/net/spdy/hpack_static_table_test.cc +++ b/net/spdy/hpack/hpack_static_table_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_static_table.h" +#include "net/spdy/hpack/hpack_static_table.h" #include <vector> #include "net/base/net_export.h" -#include "net/spdy/hpack_constants.h" +#include "net/spdy/hpack/hpack_constants.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { diff --git a/net/spdy/hpack_string_util.cc b/net/spdy/hpack/hpack_string_util.cc index dddb855..3f59291 100644 --- a/net/spdy/hpack_string_util.cc +++ b/net/spdy/hpack/hpack_string_util.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_string_util.h" +#include "net/spdy/hpack/hpack_string_util.h" #include "base/basictypes.h" diff --git a/net/spdy/hpack_string_util.h b/net/spdy/hpack/hpack_string_util.h index 66cc0c6..22ffb56 100644 --- a/net/spdy/hpack_string_util.h +++ b/net/spdy/hpack/hpack_string_util.h @@ -14,9 +14,8 @@ namespace net { // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 // A constant-time StringPiece comparison function. -bool NET_EXPORT_PRIVATE StringPiecesEqualConstantTime( - base::StringPiece str1, - base::StringPiece str2); +bool NET_EXPORT_PRIVATE StringPiecesEqualConstantTime(base::StringPiece str1, + base::StringPiece str2); } // namespace net diff --git a/net/spdy/hpack_string_util_test.cc b/net/spdy/hpack/hpack_string_util_test.cc index e73f5ce..e1576fc 100644 --- a/net/spdy/hpack_string_util_test.cc +++ b/net/spdy/hpack/hpack_string_util_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/spdy/hpack_string_util.h" +#include "net/spdy/hpack/hpack_string_util.h" #include <cstddef> #include <cstring> diff --git a/net/spdy/hpack_constants.cc b/net/spdy/hpack_constants.cc deleted file mode 100644 index 2e1037c..0000000 --- a/net/spdy/hpack_constants.cc +++ /dev/null @@ -1,418 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "net/spdy/hpack_constants.h" - -#include <vector> - -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/singleton.h" -#include "net/spdy/hpack_huffman_table.h" -#include "net/spdy/hpack_static_table.h" - -namespace net { - -namespace { - - -// SharedHpackHuffmanTable is a Singleton wrapping a HpackHuffmanTable -// instance initialized with |kHpackHuffmanCode|. -struct SharedHpackHuffmanTable { - public: - SharedHpackHuffmanTable() { - std::vector<HpackHuffmanSymbol> code = HpackHuffmanCode(); - scoped_ptr<HpackHuffmanTable> mutable_table(new HpackHuffmanTable()); - CHECK(mutable_table->Initialize(&code[0], code.size())); - CHECK(mutable_table->IsInitialized()); - table.reset(mutable_table.release()); - } - - static SharedHpackHuffmanTable* GetInstance() { - return Singleton<SharedHpackHuffmanTable>::get(); - } - - scoped_ptr<const HpackHuffmanTable> table; -}; - -// SharedHpackStaticTable is a Singleton wrapping a HpackStaticTable -// instance initialized with |kHpackStaticTable|. -struct SharedHpackStaticTable { - public: - SharedHpackStaticTable() { - std::vector<HpackStaticEntry> static_table = HpackStaticTableVector(); - scoped_ptr<HpackStaticTable> mutable_table(new HpackStaticTable()); - mutable_table->Initialize(&static_table[0], static_table.size()); - CHECK(mutable_table->IsInitialized()); - table.reset(mutable_table.release()); - } - - static SharedHpackStaticTable* GetInstance() { - return Singleton<SharedHpackStaticTable>::get(); - } - - scoped_ptr<const HpackStaticTable> table; -}; - -} // namespace - -// Produced by applying the python program [1] with tables -// provided by [2] (inserted into the source of the python program) -// and copy-paste them into this file. -// -// [1] net/tools/build_hpack_constants.py -// [2] http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 - -// HpackHuffmanSymbol entries are initialized as {code, length, id}. -// Codes are specified in the |length| most-significant bits of |code|. -std::vector<HpackHuffmanSymbol> HpackHuffmanCode() { - static const HpackHuffmanSymbol kHpackHuffmanCode[] = { - {0xffc00000ul, 13, 0}, // 11111111|11000 - {0xffffb000ul, 23, 1}, // 11111111|11111111|1011000 - {0xfffffe20ul, 28, 2}, // 11111111|11111111|11111110|0010 - {0xfffffe30ul, 28, 3}, // 11111111|11111111|11111110|0011 - {0xfffffe40ul, 28, 4}, // 11111111|11111111|11111110|0100 - {0xfffffe50ul, 28, 5}, // 11111111|11111111|11111110|0101 - {0xfffffe60ul, 28, 6}, // 11111111|11111111|11111110|0110 - {0xfffffe70ul, 28, 7}, // 11111111|11111111|11111110|0111 - {0xfffffe80ul, 28, 8}, // 11111111|11111111|11111110|1000 - {0xffffea00ul, 24, 9}, // 11111111|11111111|11101010 - {0xfffffff0ul, 30, 10}, // 11111111|11111111|11111111|111100 - {0xfffffe90ul, 28, 11}, // 11111111|11111111|11111110|1001 - {0xfffffea0ul, 28, 12}, // 11111111|11111111|11111110|1010 - {0xfffffff4ul, 30, 13}, // 11111111|11111111|11111111|111101 - {0xfffffeb0ul, 28, 14}, // 11111111|11111111|11111110|1011 - {0xfffffec0ul, 28, 15}, // 11111111|11111111|11111110|1100 - {0xfffffed0ul, 28, 16}, // 11111111|11111111|11111110|1101 - {0xfffffee0ul, 28, 17}, // 11111111|11111111|11111110|1110 - {0xfffffef0ul, 28, 18}, // 11111111|11111111|11111110|1111 - {0xffffff00ul, 28, 19}, // 11111111|11111111|11111111|0000 - {0xffffff10ul, 28, 20}, // 11111111|11111111|11111111|0001 - {0xffffff20ul, 28, 21}, // 11111111|11111111|11111111|0010 - {0xfffffff8ul, 30, 22}, // 11111111|11111111|11111111|111110 - {0xffffff30ul, 28, 23}, // 11111111|11111111|11111111|0011 - {0xffffff40ul, 28, 24}, // 11111111|11111111|11111111|0100 - {0xffffff50ul, 28, 25}, // 11111111|11111111|11111111|0101 - {0xffffff60ul, 28, 26}, // 11111111|11111111|11111111|0110 - {0xffffff70ul, 28, 27}, // 11111111|11111111|11111111|0111 - {0xffffff80ul, 28, 28}, // 11111111|11111111|11111111|1000 - {0xffffff90ul, 28, 29}, // 11111111|11111111|11111111|1001 - {0xffffffa0ul, 28, 30}, // 11111111|11111111|11111111|1010 - {0xffffffb0ul, 28, 31}, // 11111111|11111111|11111111|1011 - {0x50000000ul, 6, 32}, // ' ' 010100 - {0xfe000000ul, 10, 33}, // '!' 11111110|00 - {0xfe400000ul, 10, 34}, // '"' 11111110|01 - {0xffa00000ul, 12, 35}, // '#' 11111111|1010 - {0xffc80000ul, 13, 36}, // '$' 11111111|11001 - {0x54000000ul, 6, 37}, // '%' 010101 - {0xf8000000ul, 8, 38}, // '&' 11111000 - {0xff400000ul, 11, 39}, // ''' 11111111|010 - {0xfe800000ul, 10, 40}, // '(' 11111110|10 - {0xfec00000ul, 10, 41}, // ')' 11111110|11 - {0xf9000000ul, 8, 42}, // '*' 11111001 - {0xff600000ul, 11, 43}, // '+' 11111111|011 - {0xfa000000ul, 8, 44}, // ',' 11111010 - {0x58000000ul, 6, 45}, // '-' 010110 - {0x5c000000ul, 6, 46}, // '.' 010111 - {0x60000000ul, 6, 47}, // '/' 011000 - {0x00000000ul, 5, 48}, // '0' 00000 - {0x08000000ul, 5, 49}, // '1' 00001 - {0x10000000ul, 5, 50}, // '2' 00010 - {0x64000000ul, 6, 51}, // '3' 011001 - {0x68000000ul, 6, 52}, // '4' 011010 - {0x6c000000ul, 6, 53}, // '5' 011011 - {0x70000000ul, 6, 54}, // '6' 011100 - {0x74000000ul, 6, 55}, // '7' 011101 - {0x78000000ul, 6, 56}, // '8' 011110 - {0x7c000000ul, 6, 57}, // '9' 011111 - {0xb8000000ul, 7, 58}, // ':' 1011100 - {0xfb000000ul, 8, 59}, // ';' 11111011 - {0xfff80000ul, 15, 60}, // '<' 11111111|1111100 - {0x80000000ul, 6, 61}, // '=' 100000 - {0xffb00000ul, 12, 62}, // '>' 11111111|1011 - {0xff000000ul, 10, 63}, // '?' 11111111|00 - {0xffd00000ul, 13, 64}, // '@' 11111111|11010 - {0x84000000ul, 6, 65}, // 'A' 100001 - {0xba000000ul, 7, 66}, // 'B' 1011101 - {0xbc000000ul, 7, 67}, // 'C' 1011110 - {0xbe000000ul, 7, 68}, // 'D' 1011111 - {0xc0000000ul, 7, 69}, // 'E' 1100000 - {0xc2000000ul, 7, 70}, // 'F' 1100001 - {0xc4000000ul, 7, 71}, // 'G' 1100010 - {0xc6000000ul, 7, 72}, // 'H' 1100011 - {0xc8000000ul, 7, 73}, // 'I' 1100100 - {0xca000000ul, 7, 74}, // 'J' 1100101 - {0xcc000000ul, 7, 75}, // 'K' 1100110 - {0xce000000ul, 7, 76}, // 'L' 1100111 - {0xd0000000ul, 7, 77}, // 'M' 1101000 - {0xd2000000ul, 7, 78}, // 'N' 1101001 - {0xd4000000ul, 7, 79}, // 'O' 1101010 - {0xd6000000ul, 7, 80}, // 'P' 1101011 - {0xd8000000ul, 7, 81}, // 'Q' 1101100 - {0xda000000ul, 7, 82}, // 'R' 1101101 - {0xdc000000ul, 7, 83}, // 'S' 1101110 - {0xde000000ul, 7, 84}, // 'T' 1101111 - {0xe0000000ul, 7, 85}, // 'U' 1110000 - {0xe2000000ul, 7, 86}, // 'V' 1110001 - {0xe4000000ul, 7, 87}, // 'W' 1110010 - {0xfc000000ul, 8, 88}, // 'X' 11111100 - {0xe6000000ul, 7, 89}, // 'Y' 1110011 - {0xfd000000ul, 8, 90}, // 'Z' 11111101 - {0xffd80000ul, 13, 91}, // '[' 11111111|11011 - {0xfffe0000ul, 19, 92}, // '\' 11111111|11111110|000 - {0xffe00000ul, 13, 93}, // ']' 11111111|11100 - {0xfff00000ul, 14, 94}, // '^' 11111111|111100 - {0x88000000ul, 6, 95}, // '_' 100010 - {0xfffa0000ul, 15, 96}, // '`' 11111111|1111101 - {0x18000000ul, 5, 97}, // 'a' 00011 - {0x8c000000ul, 6, 98}, // 'b' 100011 - {0x20000000ul, 5, 99}, // 'c' 00100 - {0x90000000ul, 6, 100}, // 'd' 100100 - {0x28000000ul, 5, 101}, // 'e' 00101 - {0x94000000ul, 6, 102}, // 'f' 100101 - {0x98000000ul, 6, 103}, // 'g' 100110 - {0x9c000000ul, 6, 104}, // 'h' 100111 - {0x30000000ul, 5, 105}, // 'i' 00110 - {0xe8000000ul, 7, 106}, // 'j' 1110100 - {0xea000000ul, 7, 107}, // 'k' 1110101 - {0xa0000000ul, 6, 108}, // 'l' 101000 - {0xa4000000ul, 6, 109}, // 'm' 101001 - {0xa8000000ul, 6, 110}, // 'n' 101010 - {0x38000000ul, 5, 111}, // 'o' 00111 - {0xac000000ul, 6, 112}, // 'p' 101011 - {0xec000000ul, 7, 113}, // 'q' 1110110 - {0xb0000000ul, 6, 114}, // 'r' 101100 - {0x40000000ul, 5, 115}, // 's' 01000 - {0x48000000ul, 5, 116}, // 't' 01001 - {0xb4000000ul, 6, 117}, // 'u' 101101 - {0xee000000ul, 7, 118}, // 'v' 1110111 - {0xf0000000ul, 7, 119}, // 'w' 1111000 - {0xf2000000ul, 7, 120}, // 'x' 1111001 - {0xf4000000ul, 7, 121}, // 'y' 1111010 - {0xf6000000ul, 7, 122}, // 'z' 1111011 - {0xfffc0000ul, 15, 123}, // '{' 11111111|1111110 - {0xff800000ul, 11, 124}, // '|' 11111111|100 - {0xfff40000ul, 14, 125}, // '}' 11111111|111101 - {0xffe80000ul, 13, 126}, // '~' 11111111|11101 - {0xffffffc0ul, 28, 127}, // 11111111|11111111|11111111|1100 - {0xfffe6000ul, 20, 128}, // 11111111|11111110|0110 - {0xffff4800ul, 22, 129}, // 11111111|11111111|010010 - {0xfffe7000ul, 20, 130}, // 11111111|11111110|0111 - {0xfffe8000ul, 20, 131}, // 11111111|11111110|1000 - {0xffff4c00ul, 22, 132}, // 11111111|11111111|010011 - {0xffff5000ul, 22, 133}, // 11111111|11111111|010100 - {0xffff5400ul, 22, 134}, // 11111111|11111111|010101 - {0xffffb200ul, 23, 135}, // 11111111|11111111|1011001 - {0xffff5800ul, 22, 136}, // 11111111|11111111|010110 - {0xffffb400ul, 23, 137}, // 11111111|11111111|1011010 - {0xffffb600ul, 23, 138}, // 11111111|11111111|1011011 - {0xffffb800ul, 23, 139}, // 11111111|11111111|1011100 - {0xffffba00ul, 23, 140}, // 11111111|11111111|1011101 - {0xffffbc00ul, 23, 141}, // 11111111|11111111|1011110 - {0xffffeb00ul, 24, 142}, // 11111111|11111111|11101011 - {0xffffbe00ul, 23, 143}, // 11111111|11111111|1011111 - {0xffffec00ul, 24, 144}, // 11111111|11111111|11101100 - {0xffffed00ul, 24, 145}, // 11111111|11111111|11101101 - {0xffff5c00ul, 22, 146}, // 11111111|11111111|010111 - {0xffffc000ul, 23, 147}, // 11111111|11111111|1100000 - {0xffffee00ul, 24, 148}, // 11111111|11111111|11101110 - {0xffffc200ul, 23, 149}, // 11111111|11111111|1100001 - {0xffffc400ul, 23, 150}, // 11111111|11111111|1100010 - {0xffffc600ul, 23, 151}, // 11111111|11111111|1100011 - {0xffffc800ul, 23, 152}, // 11111111|11111111|1100100 - {0xfffee000ul, 21, 153}, // 11111111|11111110|11100 - {0xffff6000ul, 22, 154}, // 11111111|11111111|011000 - {0xffffca00ul, 23, 155}, // 11111111|11111111|1100101 - {0xffff6400ul, 22, 156}, // 11111111|11111111|011001 - {0xffffcc00ul, 23, 157}, // 11111111|11111111|1100110 - {0xffffce00ul, 23, 158}, // 11111111|11111111|1100111 - {0xffffef00ul, 24, 159}, // 11111111|11111111|11101111 - {0xffff6800ul, 22, 160}, // 11111111|11111111|011010 - {0xfffee800ul, 21, 161}, // 11111111|11111110|11101 - {0xfffe9000ul, 20, 162}, // 11111111|11111110|1001 - {0xffff6c00ul, 22, 163}, // 11111111|11111111|011011 - {0xffff7000ul, 22, 164}, // 11111111|11111111|011100 - {0xffffd000ul, 23, 165}, // 11111111|11111111|1101000 - {0xffffd200ul, 23, 166}, // 11111111|11111111|1101001 - {0xfffef000ul, 21, 167}, // 11111111|11111110|11110 - {0xffffd400ul, 23, 168}, // 11111111|11111111|1101010 - {0xffff7400ul, 22, 169}, // 11111111|11111111|011101 - {0xffff7800ul, 22, 170}, // 11111111|11111111|011110 - {0xfffff000ul, 24, 171}, // 11111111|11111111|11110000 - {0xfffef800ul, 21, 172}, // 11111111|11111110|11111 - {0xffff7c00ul, 22, 173}, // 11111111|11111111|011111 - {0xffffd600ul, 23, 174}, // 11111111|11111111|1101011 - {0xffffd800ul, 23, 175}, // 11111111|11111111|1101100 - {0xffff0000ul, 21, 176}, // 11111111|11111111|00000 - {0xffff0800ul, 21, 177}, // 11111111|11111111|00001 - {0xffff8000ul, 22, 178}, // 11111111|11111111|100000 - {0xffff1000ul, 21, 179}, // 11111111|11111111|00010 - {0xffffda00ul, 23, 180}, // 11111111|11111111|1101101 - {0xffff8400ul, 22, 181}, // 11111111|11111111|100001 - {0xffffdc00ul, 23, 182}, // 11111111|11111111|1101110 - {0xffffde00ul, 23, 183}, // 11111111|11111111|1101111 - {0xfffea000ul, 20, 184}, // 11111111|11111110|1010 - {0xffff8800ul, 22, 185}, // 11111111|11111111|100010 - {0xffff8c00ul, 22, 186}, // 11111111|11111111|100011 - {0xffff9000ul, 22, 187}, // 11111111|11111111|100100 - {0xffffe000ul, 23, 188}, // 11111111|11111111|1110000 - {0xffff9400ul, 22, 189}, // 11111111|11111111|100101 - {0xffff9800ul, 22, 190}, // 11111111|11111111|100110 - {0xffffe200ul, 23, 191}, // 11111111|11111111|1110001 - {0xfffff800ul, 26, 192}, // 11111111|11111111|11111000|00 - {0xfffff840ul, 26, 193}, // 11111111|11111111|11111000|01 - {0xfffeb000ul, 20, 194}, // 11111111|11111110|1011 - {0xfffe2000ul, 19, 195}, // 11111111|11111110|001 - {0xffff9c00ul, 22, 196}, // 11111111|11111111|100111 - {0xffffe400ul, 23, 197}, // 11111111|11111111|1110010 - {0xffffa000ul, 22, 198}, // 11111111|11111111|101000 - {0xfffff600ul, 25, 199}, // 11111111|11111111|11110110|0 - {0xfffff880ul, 26, 200}, // 11111111|11111111|11111000|10 - {0xfffff8c0ul, 26, 201}, // 11111111|11111111|11111000|11 - {0xfffff900ul, 26, 202}, // 11111111|11111111|11111001|00 - {0xfffffbc0ul, 27, 203}, // 11111111|11111111|11111011|110 - {0xfffffbe0ul, 27, 204}, // 11111111|11111111|11111011|111 - {0xfffff940ul, 26, 205}, // 11111111|11111111|11111001|01 - {0xfffff100ul, 24, 206}, // 11111111|11111111|11110001 - {0xfffff680ul, 25, 207}, // 11111111|11111111|11110110|1 - {0xfffe4000ul, 19, 208}, // 11111111|11111110|010 - {0xffff1800ul, 21, 209}, // 11111111|11111111|00011 - {0xfffff980ul, 26, 210}, // 11111111|11111111|11111001|10 - {0xfffffc00ul, 27, 211}, // 11111111|11111111|11111100|000 - {0xfffffc20ul, 27, 212}, // 11111111|11111111|11111100|001 - {0xfffff9c0ul, 26, 213}, // 11111111|11111111|11111001|11 - {0xfffffc40ul, 27, 214}, // 11111111|11111111|11111100|010 - {0xfffff200ul, 24, 215}, // 11111111|11111111|11110010 - {0xffff2000ul, 21, 216}, // 11111111|11111111|00100 - {0xffff2800ul, 21, 217}, // 11111111|11111111|00101 - {0xfffffa00ul, 26, 218}, // 11111111|11111111|11111010|00 - {0xfffffa40ul, 26, 219}, // 11111111|11111111|11111010|01 - {0xffffffd0ul, 28, 220}, // 11111111|11111111|11111111|1101 - {0xfffffc60ul, 27, 221}, // 11111111|11111111|11111100|011 - {0xfffffc80ul, 27, 222}, // 11111111|11111111|11111100|100 - {0xfffffca0ul, 27, 223}, // 11111111|11111111|11111100|101 - {0xfffec000ul, 20, 224}, // 11111111|11111110|1100 - {0xfffff300ul, 24, 225}, // 11111111|11111111|11110011 - {0xfffed000ul, 20, 226}, // 11111111|11111110|1101 - {0xffff3000ul, 21, 227}, // 11111111|11111111|00110 - {0xffffa400ul, 22, 228}, // 11111111|11111111|101001 - {0xffff3800ul, 21, 229}, // 11111111|11111111|00111 - {0xffff4000ul, 21, 230}, // 11111111|11111111|01000 - {0xffffe600ul, 23, 231}, // 11111111|11111111|1110011 - {0xffffa800ul, 22, 232}, // 11111111|11111111|101010 - {0xffffac00ul, 22, 233}, // 11111111|11111111|101011 - {0xfffff700ul, 25, 234}, // 11111111|11111111|11110111|0 - {0xfffff780ul, 25, 235}, // 11111111|11111111|11110111|1 - {0xfffff400ul, 24, 236}, // 11111111|11111111|11110100 - {0xfffff500ul, 24, 237}, // 11111111|11111111|11110101 - {0xfffffa80ul, 26, 238}, // 11111111|11111111|11111010|10 - {0xffffe800ul, 23, 239}, // 11111111|11111111|1110100 - {0xfffffac0ul, 26, 240}, // 11111111|11111111|11111010|11 - {0xfffffcc0ul, 27, 241}, // 11111111|11111111|11111100|110 - {0xfffffb00ul, 26, 242}, // 11111111|11111111|11111011|00 - {0xfffffb40ul, 26, 243}, // 11111111|11111111|11111011|01 - {0xfffffce0ul, 27, 244}, // 11111111|11111111|11111100|111 - {0xfffffd00ul, 27, 245}, // 11111111|11111111|11111101|000 - {0xfffffd20ul, 27, 246}, // 11111111|11111111|11111101|001 - {0xfffffd40ul, 27, 247}, // 11111111|11111111|11111101|010 - {0xfffffd60ul, 27, 248}, // 11111111|11111111|11111101|011 - {0xffffffe0ul, 28, 249}, // 11111111|11111111|11111111|1110 - {0xfffffd80ul, 27, 250}, // 11111111|11111111|11111101|100 - {0xfffffda0ul, 27, 251}, // 11111111|11111111|11111101|101 - {0xfffffdc0ul, 27, 252}, // 11111111|11111111|11111101|110 - {0xfffffde0ul, 27, 253}, // 11111111|11111111|11111101|111 - {0xfffffe00ul, 27, 254}, // 11111111|11111111|11111110|000 - {0xfffffb80ul, 26, 255}, // 11111111|11111111|11111011|10 - {0xfffffffcul, 30, 256}, // EOS 11111111|11111111|11111111|111111 - }; - return std::vector<HpackHuffmanSymbol>( - kHpackHuffmanCode, - kHpackHuffmanCode + arraysize(kHpackHuffmanCode)); -} - -// The "constructor" for a HpackStaticEntry that computes the lengths at -// compile time. -#define STATIC_ENTRY(name, value) \ - { name, arraysize(name) - 1, value, arraysize(value) - 1 } - -std::vector<HpackStaticEntry> HpackStaticTableVector() { - static const HpackStaticEntry kHpackStaticTable[] = { - STATIC_ENTRY(":authority", ""), // 1 - STATIC_ENTRY(":method", "GET"), // 2 - STATIC_ENTRY(":method", "POST"), // 3 - STATIC_ENTRY(":path", "/"), // 4 - STATIC_ENTRY(":path", "/index.html"), // 5 - STATIC_ENTRY(":scheme", "http"), // 6 - STATIC_ENTRY(":scheme", "https"), // 7 - STATIC_ENTRY(":status", "200"), // 8 - STATIC_ENTRY(":status", "204"), // 9 - STATIC_ENTRY(":status", "206"), // 10 - STATIC_ENTRY(":status", "304"), // 11 - STATIC_ENTRY(":status", "400"), // 12 - STATIC_ENTRY(":status", "404"), // 13 - STATIC_ENTRY(":status", "500"), // 14 - STATIC_ENTRY("accept-charset", ""), // 15 - STATIC_ENTRY("accept-encoding", "gzip, deflate"), // 16 - STATIC_ENTRY("accept-language", ""), // 17 - STATIC_ENTRY("accept-ranges", ""), // 18 - STATIC_ENTRY("accept", ""), // 19 - STATIC_ENTRY("access-control-allow-origin", ""), // 20 - STATIC_ENTRY("age", ""), // 21 - STATIC_ENTRY("allow", ""), // 22 - STATIC_ENTRY("authorization", ""), // 23 - STATIC_ENTRY("cache-control", ""), // 24 - STATIC_ENTRY("content-disposition", ""), // 25 - STATIC_ENTRY("content-encoding", ""), // 26 - STATIC_ENTRY("content-language", ""), // 27 - STATIC_ENTRY("content-length", ""), // 28 - STATIC_ENTRY("content-location", ""), // 29 - STATIC_ENTRY("content-range", ""), // 30 - STATIC_ENTRY("content-type", ""), // 31 - STATIC_ENTRY("cookie", ""), // 32 - STATIC_ENTRY("date", ""), // 33 - STATIC_ENTRY("etag", ""), // 34 - STATIC_ENTRY("expect", ""), // 35 - STATIC_ENTRY("expires", ""), // 36 - STATIC_ENTRY("from", ""), // 37 - STATIC_ENTRY("host", ""), // 38 - STATIC_ENTRY("if-match", ""), // 39 - STATIC_ENTRY("if-modified-since", ""), // 40 - STATIC_ENTRY("if-none-match", ""), // 41 - STATIC_ENTRY("if-range", ""), // 42 - STATIC_ENTRY("if-unmodified-since", ""), // 43 - STATIC_ENTRY("last-modified", ""), // 44 - STATIC_ENTRY("link", ""), // 45 - STATIC_ENTRY("location", ""), // 46 - STATIC_ENTRY("max-forwards", ""), // 47 - STATIC_ENTRY("proxy-authenticate", ""), // 48 - STATIC_ENTRY("proxy-authorization", ""), // 49 - STATIC_ENTRY("range", ""), // 50 - STATIC_ENTRY("referer", ""), // 51 - STATIC_ENTRY("refresh", ""), // 52 - STATIC_ENTRY("retry-after", ""), // 53 - STATIC_ENTRY("server", ""), // 54 - STATIC_ENTRY("set-cookie", ""), // 55 - STATIC_ENTRY("strict-transport-security", ""), // 56 - STATIC_ENTRY("transfer-encoding", ""), // 57 - STATIC_ENTRY("user-agent", ""), // 58 - STATIC_ENTRY("vary", ""), // 59 - STATIC_ENTRY("via", ""), // 60 - STATIC_ENTRY("www-authenticate", ""), // 61 - }; - return std::vector<HpackStaticEntry>( - kHpackStaticTable, - kHpackStaticTable + arraysize(kHpackStaticTable)); -} - -#undef STATIC_ENTRY - -const HpackHuffmanTable& ObtainHpackHuffmanTable() { - return *SharedHpackHuffmanTable::GetInstance()->table; -} - -const HpackStaticTable& ObtainHpackStaticTable() { - return *SharedHpackStaticTable::GetInstance()->table; -} - -} // namespace net diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index 9e08d2b..e4cb7c2 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -15,7 +15,7 @@ #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram_macros.h" #include "base/third_party/valgrind/memcheck.h" -#include "net/spdy/hpack_constants.h" +#include "net/spdy/hpack/hpack_constants.h" #include "net/spdy/spdy_frame_builder.h" #include "net/spdy/spdy_frame_reader.h" #include "net/spdy/spdy_bitmasks.h" diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h index a96a949..d16c57a 100644 --- a/net/spdy/spdy_framer.h +++ b/net/spdy/spdy_framer.h @@ -15,8 +15,8 @@ #include "base/strings/string_piece.h" #include "base/sys_byteorder.h" #include "net/base/net_export.h" -#include "net/spdy/hpack_decoder.h" -#include "net/spdy/hpack_encoder.h" +#include "net/spdy/hpack/hpack_decoder.h" +#include "net/spdy/hpack/hpack_encoder.h" #include "net/spdy/spdy_alt_svc_wire_format.h" #include "net/spdy/spdy_header_block.h" #include "net/spdy/spdy_protocol.h" diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index 62f6827..066722f 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc @@ -15,7 +15,7 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" -#include "net/spdy/hpack_constants.h" +#include "net/spdy/hpack/hpack_constants.h" #include "net/spdy/mock_spdy_framer_visitor.h" #include "net/spdy/spdy_frame_builder.h" #include "net/spdy/spdy_frame_reader.h" diff --git a/net/tools/build_hpack_constants.py b/net/tools/build_hpack_constants.py index 3074e55..3111078 100755 --- a/net/tools/build_hpack_constants.py +++ b/net/tools/build_hpack_constants.py @@ -5,9 +5,8 @@ # found in the LICENSE file. """This script builds a table that has to be manully inserted into -net/spdy/hpack_constants.cc. It also contains data that potentially -has to be updated if the http hpack algorithm changes its -constants.""" +net/spdy/hpack/hpack_constants.cc. It also contains data that potentially has to +be updated if the http hpack algorithm changes its constants.""" import re |