This source file includes following definitions.
- bits32
- HpackHuffmanCode
- ObtainHpackHuffmanTable
#include "net/spdy/hpack_constants.h"
#include <bitset>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "net/spdy/hpack_huffman_table.h"
namespace net {
namespace {
uint32 bits32(const std::string& bitstring) {
return std::bitset<32>(bitstring).to_ulong();
}
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;
};
}
std::vector<HpackHuffmanSymbol> HpackHuffmanCode() {
const HpackHuffmanSymbol kHpackHuffmanCode[] = {
{bits32("11111111111111111111011101000000"), 27, 0},
{bits32("11111111111111111111011101100000"), 27, 1},
{bits32("11111111111111111111011110000000"), 27, 2},
{bits32("11111111111111111111011110100000"), 27, 3},
{bits32("11111111111111111111011111000000"), 27, 4},
{bits32("11111111111111111111011111100000"), 27, 5},
{bits32("11111111111111111111100000000000"), 27, 6},
{bits32("11111111111111111111100000100000"), 27, 7},
{bits32("11111111111111111111100001000000"), 27, 8},
{bits32("11111111111111111111100001100000"), 27, 9},
{bits32("11111111111111111111100010000000"), 27, 10},
{bits32("11111111111111111111100010100000"), 27, 11},
{bits32("11111111111111111111100011000000"), 27, 12},
{bits32("11111111111111111111100011100000"), 27, 13},
{bits32("11111111111111111111100100000000"), 27, 14},
{bits32("11111111111111111111100100100000"), 27, 15},
{bits32("11111111111111111111100101000000"), 27, 16},
{bits32("11111111111111111111100101100000"), 27, 17},
{bits32("11111111111111111111100110000000"), 27, 18},
{bits32("11111111111111111111100110100000"), 27, 19},
{bits32("11111111111111111111100111000000"), 27, 20},
{bits32("11111111111111111111100111100000"), 27, 21},
{bits32("11111111111111111111101000000000"), 27, 22},
{bits32("11111111111111111111101000100000"), 27, 23},
{bits32("11111111111111111111101001000000"), 27, 24},
{bits32("11111111111111111111101001100000"), 27, 25},
{bits32("11111111111111111111101010000000"), 27, 26},
{bits32("11111111111111111111101010100000"), 27, 27},
{bits32("11111111111111111111101011000000"), 27, 28},
{bits32("11111111111111111111101011100000"), 27, 29},
{bits32("11111111111111111111101100000000"), 27, 30},
{bits32("11111111111111111111101100100000"), 27, 31},
{bits32("11101000000000000000000000000000"), 8, 32},
{bits32("11111111110000000000000000000000"), 12, 33},
{bits32("11111111111010000000000000000000"), 14, 34},
{bits32("11111111111110000000000000000000"), 15, 35},
{bits32("11111111111110100000000000000000"), 15, 36},
{bits32("10010000000000000000000000000000"), 6, 37},
{bits32("11011100000000000000000000000000"), 7, 38},
{bits32("11111111111111000000000000000000"), 15, 39},
{bits32("11111111010000000000000000000000"), 11, 40},
{bits32("11111111011000000000000000000000"), 11, 41},
{bits32("11111110100000000000000000000000"), 10, 42},
{bits32("11111111100000000000000000000000"), 11, 43},
{bits32("11101001000000000000000000000000"), 8, 44},
{bits32("10010100000000000000000000000000"), 6, 45},
{bits32("00100000000000000000000000000000"), 5, 46},
{bits32("00000000000000000000000000000000"), 4, 47},
{bits32("00101000000000000000000000000000"), 5, 48},
{bits32("00110000000000000000000000000000"), 5, 49},
{bits32("00111000000000000000000000000000"), 5, 50},
{bits32("10011000000000000000000000000000"), 6, 51},
{bits32("10011100000000000000000000000000"), 6, 52},
{bits32("10100000000000000000000000000000"), 6, 53},
{bits32("10100100000000000000000000000000"), 6, 54},
{bits32("10101000000000000000000000000000"), 6, 55},
{bits32("10101100000000000000000000000000"), 6, 56},
{bits32("10110000000000000000000000000000"), 6, 57},
{bits32("11110110000000000000000000000000"), 9, 58},
{bits32("11101010000000000000000000000000"), 8, 59},
{bits32("11111111111111111000000000000000"), 18, 60},
{bits32("10110100000000000000000000000000"), 6, 61},
{bits32("11111111111111100000000000000000"), 17, 62},
{bits32("11110110100000000000000000000000"), 9, 63},
{bits32("11111111111011000000000000000000"), 14, 64},
{bits32("11011110000000000000000000000000"), 7, 65},
{bits32("11101011000000000000000000000000"), 8, 66},
{bits32("11101100000000000000000000000000"), 8, 67},
{bits32("11101101000000000000000000000000"), 8, 68},
{bits32("11101110000000000000000000000000"), 8, 69},
{bits32("11100000000000000000000000000000"), 7, 70},
{bits32("11110111000000000000000000000000"), 9, 71},
{bits32("11110111100000000000000000000000"), 9, 72},
{bits32("11111000000000000000000000000000"), 9, 73},
{bits32("11111000100000000000000000000000"), 9, 74},
{bits32("11111110110000000000000000000000"), 10, 75},
{bits32("11111001000000000000000000000000"), 9, 76},
{bits32("11101111000000000000000000000000"), 8, 77},
{bits32("11111001100000000000000000000000"), 9, 78},
{bits32("11111010000000000000000000000000"), 9, 79},
{bits32("11111010100000000000000000000000"), 9, 80},
{bits32("11111011000000000000000000000000"), 9, 81},
{bits32("11111011100000000000000000000000"), 9, 82},
{bits32("11110000000000000000000000000000"), 8, 83},
{bits32("11110001000000000000000000000000"), 8, 84},
{bits32("11111100000000000000000000000000"), 9, 85},
{bits32("11111100100000000000000000000000"), 9, 86},
{bits32("11111101000000000000000000000000"), 9, 87},
{bits32("11111101100000000000000000000000"), 9, 88},
{bits32("11111110000000000000000000000000"), 9, 89},
{bits32("11111111000000000000000000000000"), 10, 90},
{bits32("11111111111100000000000000000000"), 14, 91},
{bits32("11111111111111111111101101000000"), 27, 92},
{bits32("11111111111000000000000000000000"), 13, 93},
{bits32("11111111111101000000000000000000"), 14, 94},
{bits32("10111000000000000000000000000000"), 6, 95},
{bits32("11111111111111111100000000000000"), 19, 96},
{bits32("01000000000000000000000000000000"), 5, 97},
{bits32("10111100000000000000000000000000"), 6, 98},
{bits32("01001000000000000000000000000000"), 5, 99},
{bits32("11000000000000000000000000000000"), 6, 100},
{bits32("00010000000000000000000000000000"), 4, 101},
{bits32("11000100000000000000000000000000"), 6, 102},
{bits32("11001000000000000000000000000000"), 6, 103},
{bits32("11001100000000000000000000000000"), 6, 104},
{bits32("01010000000000000000000000000000"), 5, 105},
{bits32("11100010000000000000000000000000"), 7, 106},
{bits32("11100100000000000000000000000000"), 7, 107},
{bits32("01011000000000000000000000000000"), 5, 108},
{bits32("11010000000000000000000000000000"), 6, 109},
{bits32("01100000000000000000000000000000"), 5, 110},
{bits32("01101000000000000000000000000000"), 5, 111},
{bits32("01110000000000000000000000000000"), 5, 112},
{bits32("11110010000000000000000000000000"), 8, 113},
{bits32("01111000000000000000000000000000"), 5, 114},
{bits32("10000000000000000000000000000000"), 5, 115},
{bits32("10001000000000000000000000000000"), 5, 116},
{bits32("11010100000000000000000000000000"), 6, 117},
{bits32("11100110000000000000000000000000"), 7, 118},
{bits32("11011000000000000000000000000000"), 6, 119},
{bits32("11110011000000000000000000000000"), 8, 120},
{bits32("11110100000000000000000000000000"), 8, 121},
{bits32("11110101000000000000000000000000"), 8, 122},
{bits32("11111111111111101000000000000000"), 17, 123},
{bits32("11111111101000000000000000000000"), 11, 124},
{bits32("11111111111111110000000000000000"), 17, 125},
{bits32("11111111110100000000000000000000"), 12, 126},
{bits32("11111111111111111111101101100000"), 27, 127},
{bits32("11111111111111111111101110000000"), 27, 128},
{bits32("11111111111111111111101110100000"), 27, 129},
{bits32("11111111111111111111101111000000"), 27, 130},
{bits32("11111111111111111111101111100000"), 27, 131},
{bits32("11111111111111111111110000000000"), 27, 132},
{bits32("11111111111111111111110000100000"), 27, 133},
{bits32("11111111111111111111110001000000"), 27, 134},
{bits32("11111111111111111111110001100000"), 27, 135},
{bits32("11111111111111111111110010000000"), 27, 136},
{bits32("11111111111111111111110010100000"), 27, 137},
{bits32("11111111111111111111110011000000"), 27, 138},
{bits32("11111111111111111111110011100000"), 27, 139},
{bits32("11111111111111111111110100000000"), 27, 140},
{bits32("11111111111111111111110100100000"), 27, 141},
{bits32("11111111111111111111110101000000"), 27, 142},
{bits32("11111111111111111111110101100000"), 27, 143},
{bits32("11111111111111111111110110000000"), 27, 144},
{bits32("11111111111111111111110110100000"), 27, 145},
{bits32("11111111111111111111110111000000"), 27, 146},
{bits32("11111111111111111111110111100000"), 27, 147},
{bits32("11111111111111111111111000000000"), 27, 148},
{bits32("11111111111111111111111000100000"), 27, 149},
{bits32("11111111111111111111111001000000"), 27, 150},
{bits32("11111111111111111111111001100000"), 27, 151},
{bits32("11111111111111111111111010000000"), 27, 152},
{bits32("11111111111111111111111010100000"), 27, 153},
{bits32("11111111111111111111111011000000"), 27, 154},
{bits32("11111111111111111111111011100000"), 27, 155},
{bits32("11111111111111111111111100000000"), 27, 156},
{bits32("11111111111111111111111100100000"), 27, 157},
{bits32("11111111111111111111111101000000"), 27, 158},
{bits32("11111111111111111111111101100000"), 27, 159},
{bits32("11111111111111111111111110000000"), 27, 160},
{bits32("11111111111111111111111110100000"), 27, 161},
{bits32("11111111111111111111111111000000"), 27, 162},
{bits32("11111111111111111111111111100000"), 27, 163},
{bits32("11111111111111111110000000000000"), 26, 164},
{bits32("11111111111111111110000001000000"), 26, 165},
{bits32("11111111111111111110000010000000"), 26, 166},
{bits32("11111111111111111110000011000000"), 26, 167},
{bits32("11111111111111111110000100000000"), 26, 168},
{bits32("11111111111111111110000101000000"), 26, 169},
{bits32("11111111111111111110000110000000"), 26, 170},
{bits32("11111111111111111110000111000000"), 26, 171},
{bits32("11111111111111111110001000000000"), 26, 172},
{bits32("11111111111111111110001001000000"), 26, 173},
{bits32("11111111111111111110001010000000"), 26, 174},
{bits32("11111111111111111110001011000000"), 26, 175},
{bits32("11111111111111111110001100000000"), 26, 176},
{bits32("11111111111111111110001101000000"), 26, 177},
{bits32("11111111111111111110001110000000"), 26, 178},
{bits32("11111111111111111110001111000000"), 26, 179},
{bits32("11111111111111111110010000000000"), 26, 180},
{bits32("11111111111111111110010001000000"), 26, 181},
{bits32("11111111111111111110010010000000"), 26, 182},
{bits32("11111111111111111110010011000000"), 26, 183},
{bits32("11111111111111111110010100000000"), 26, 184},
{bits32("11111111111111111110010101000000"), 26, 185},
{bits32("11111111111111111110010110000000"), 26, 186},
{bits32("11111111111111111110010111000000"), 26, 187},
{bits32("11111111111111111110011000000000"), 26, 188},
{bits32("11111111111111111110011001000000"), 26, 189},
{bits32("11111111111111111110011010000000"), 26, 190},
{bits32("11111111111111111110011011000000"), 26, 191},
{bits32("11111111111111111110011100000000"), 26, 192},
{bits32("11111111111111111110011101000000"), 26, 193},
{bits32("11111111111111111110011110000000"), 26, 194},
{bits32("11111111111111111110011111000000"), 26, 195},
{bits32("11111111111111111110100000000000"), 26, 196},
{bits32("11111111111111111110100001000000"), 26, 197},
{bits32("11111111111111111110100010000000"), 26, 198},
{bits32("11111111111111111110100011000000"), 26, 199},
{bits32("11111111111111111110100100000000"), 26, 200},
{bits32("11111111111111111110100101000000"), 26, 201},
{bits32("11111111111111111110100110000000"), 26, 202},
{bits32("11111111111111111110100111000000"), 26, 203},
{bits32("11111111111111111110101000000000"), 26, 204},
{bits32("11111111111111111110101001000000"), 26, 205},
{bits32("11111111111111111110101010000000"), 26, 206},
{bits32("11111111111111111110101011000000"), 26, 207},
{bits32("11111111111111111110101100000000"), 26, 208},
{bits32("11111111111111111110101101000000"), 26, 209},
{bits32("11111111111111111110101110000000"), 26, 210},
{bits32("11111111111111111110101111000000"), 26, 211},
{bits32("11111111111111111110110000000000"), 26, 212},
{bits32("11111111111111111110110001000000"), 26, 213},
{bits32("11111111111111111110110010000000"), 26, 214},
{bits32("11111111111111111110110011000000"), 26, 215},
{bits32("11111111111111111110110100000000"), 26, 216},
{bits32("11111111111111111110110101000000"), 26, 217},
{bits32("11111111111111111110110110000000"), 26, 218},
{bits32("11111111111111111110110111000000"), 26, 219},
{bits32("11111111111111111110111000000000"), 26, 220},
{bits32("11111111111111111110111001000000"), 26, 221},
{bits32("11111111111111111110111010000000"), 26, 222},
{bits32("11111111111111111110111011000000"), 26, 223},
{bits32("11111111111111111110111100000000"), 26, 224},
{bits32("11111111111111111110111101000000"), 26, 225},
{bits32("11111111111111111110111110000000"), 26, 226},
{bits32("11111111111111111110111111000000"), 26, 227},
{bits32("11111111111111111111000000000000"), 26, 228},
{bits32("11111111111111111111000001000000"), 26, 229},
{bits32("11111111111111111111000010000000"), 26, 230},
{bits32("11111111111111111111000011000000"), 26, 231},
{bits32("11111111111111111111000100000000"), 26, 232},
{bits32("11111111111111111111000101000000"), 26, 233},
{bits32("11111111111111111111000110000000"), 26, 234},
{bits32("11111111111111111111000111000000"), 26, 235},
{bits32("11111111111111111111001000000000"), 26, 236},
{bits32("11111111111111111111001001000000"), 26, 237},
{bits32("11111111111111111111001010000000"), 26, 238},
{bits32("11111111111111111111001011000000"), 26, 239},
{bits32("11111111111111111111001100000000"), 26, 240},
{bits32("11111111111111111111001101000000"), 26, 241},
{bits32("11111111111111111111001110000000"), 26, 242},
{bits32("11111111111111111111001111000000"), 26, 243},
{bits32("11111111111111111111010000000000"), 26, 244},
{bits32("11111111111111111111010001000000"), 26, 245},
{bits32("11111111111111111111010010000000"), 26, 246},
{bits32("11111111111111111111010011000000"), 26, 247},
{bits32("11111111111111111111010100000000"), 26, 248},
{bits32("11111111111111111111010101000000"), 26, 249},
{bits32("11111111111111111111010110000000"), 26, 250},
{bits32("11111111111111111111010111000000"), 26, 251},
{bits32("11111111111111111111011000000000"), 26, 252},
{bits32("11111111111111111111011001000000"), 26, 253},
{bits32("11111111111111111111011010000000"), 26, 254},
{bits32("11111111111111111111011011000000"), 26, 255},
{bits32("11111111111111111111011100000000"), 26, 256},
};
return std::vector<HpackHuffmanSymbol>(
kHpackHuffmanCode,
kHpackHuffmanCode + arraysize(kHpackHuffmanCode));
}
const HpackHuffmanTable& ObtainHpackHuffmanTable() {
return *SharedHpackHuffmanTable::GetInstance()->table;
}
}