| 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 #include <memory> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
| 13 #include "net/spdy/hpack/hpack_input_stream.h" | 13 #include "net/spdy/hpack/hpack_input_stream.h" |
| 14 #include "net/spdy/hpack/hpack_output_stream.h" | 14 #include "net/spdy/hpack/hpack_output_stream.h" |
| 15 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 using base::StringPiece; | 19 using base::StringPiece; |
| 19 using std::string; | 20 using std::string; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // How many bits to index in the root decode table. | 24 // How many bits to index in the root decode table. |
| 24 const uint8_t kDecodeTableRootBits = 9; | 25 const uint8_t kDecodeTableRootBits = 9; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 in->ConsumeBits(entry.length); | 312 in->ConsumeBits(entry.length); |
| 312 bits = bits << entry.length; | 313 bits = bits << entry.length; |
| 313 bits_available -= entry.length; | 314 bits_available -= entry.length; |
| 314 } | 315 } |
| 315 peeked_success = in->PeekBits(&bits_available, &bits); | 316 peeked_success = in->PeekBits(&bits_available, &bits); |
| 316 } | 317 } |
| 317 NOTREACHED(); | 318 NOTREACHED(); |
| 318 return false; | 319 return false; |
| 319 } | 320 } |
| 320 | 321 |
| 322 size_t HpackHuffmanTable::EstimateMemoryUsage() const { |
| 323 return SpdyEstimateMemoryUsage(decode_tables_) + |
| 324 SpdyEstimateMemoryUsage(decode_entries_) + |
| 325 SpdyEstimateMemoryUsage(code_by_id_) + |
| 326 SpdyEstimateMemoryUsage(length_by_id_); |
| 327 } |
| 328 |
| 321 } // namespace net | 329 } // namespace net |
| OLD | NEW |