OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/hpack/hpack_huffman_table.h" | 5 #include "net/spdy/hpack/hpack_huffman_table.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
12 #include "net/spdy/hpack/hpack_input_stream.h" | 13 #include "net/spdy/hpack/hpack_input_stream.h" |
13 #include "net/spdy/hpack/hpack_output_stream.h" | 14 #include "net/spdy/hpack/hpack_output_stream.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 using base::StringPiece; | 18 using base::StringPiece; |
18 using std::string; | 19 using std::string; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 CHECK_GT(code_by_id_.size(), symbol_id); | 257 CHECK_GT(code_by_id_.size(), symbol_id); |
257 | 258 |
258 bit_count += length_by_id_[symbol_id]; | 259 bit_count += length_by_id_[symbol_id]; |
259 } | 260 } |
260 if (bit_count % 8 != 0) { | 261 if (bit_count % 8 != 0) { |
261 bit_count += 8 - bit_count % 8; | 262 bit_count += 8 - bit_count % 8; |
262 } | 263 } |
263 return bit_count / 8; | 264 return bit_count / 8; |
264 } | 265 } |
265 | 266 |
266 bool HpackHuffmanTable::DecodeString(HpackInputStream* in, | 267 bool HpackHuffmanTable::GenericDecodeString(HpackInputStream* in, |
267 size_t out_capacity, | 268 size_t out_capacity, |
268 string* out) const { | 269 string* out) const { |
269 // Number of decode iterations required for a 32-bit code. | 270 // Number of decode iterations required for a 32-bit code. |
270 const int kDecodeIterations = static_cast<int>( | 271 const int kDecodeIterations = static_cast<int>( |
271 std::ceil((32.f - kDecodeTableRootBits) / kDecodeTableBranchBits)); | 272 std::ceil((32.f - kDecodeTableRootBits) / kDecodeTableBranchBits)); |
272 | 273 |
273 out->clear(); | 274 out->clear(); |
274 | 275 |
275 // Current input, stored in the high |bits_available| bits of |bits|. | 276 // Current input, stored in the high |bits_available| bits of |bits|. |
276 uint32_t bits = 0; | 277 uint32_t bits = 0; |
277 size_t bits_available = 0; | 278 size_t bits_available = 0; |
278 bool peeked_success = in->PeekBits(&bits_available, &bits); | 279 bool peeked_success = in->PeekBits(&bits_available, &bits); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 bits = bits << entry.length; | 316 bits = bits << entry.length; |
316 bits_available -= entry.length; | 317 bits_available -= entry.length; |
317 } | 318 } |
318 peeked_success = in->PeekBits(&bits_available, &bits); | 319 peeked_success = in->PeekBits(&bits_available, &bits); |
319 } | 320 } |
320 NOTREACHED(); | 321 NOTREACHED(); |
321 return false; | 322 return false; |
322 } | 323 } |
323 | 324 |
324 } // namespace net | 325 } // namespace net |
OLD | NEW |