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_input_stream.h" | 5 #include "net/spdy/hpack_input_stream.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 HpackInputStream::~HpackInputStream() {} | 23 HpackInputStream::~HpackInputStream() {} |
24 | 24 |
25 bool HpackInputStream::HasMoreData() const { | 25 bool HpackInputStream::HasMoreData() const { |
26 return !buffer_.empty(); | 26 return !buffer_.empty(); |
27 } | 27 } |
28 | 28 |
29 bool HpackInputStream::MatchPrefixAndConsume(HpackPrefix prefix) { | 29 bool HpackInputStream::MatchPrefixAndConsume(HpackPrefix prefix) { |
30 DCHECK_GT(prefix.bit_size, 0u); | 30 DCHECK_GT(prefix.bit_size, 0u); |
31 DCHECK_LE(prefix.bit_size, 8u); | 31 DCHECK_LE(prefix.bit_size, 8u); |
32 | 32 |
33 uint8 next_octet = 0; | 33 uint32 peeked = 0; |
34 if (!PeekNextOctet(&next_octet)) | 34 size_t peeked_count = 0; |
| 35 |
| 36 if (!PeekBits(&peeked_count, &peeked)) |
35 return false; | 37 return false; |
36 | 38 |
37 if ((next_octet >> (8 - prefix.bit_size)) == prefix.bits) { | 39 if ((peeked >> (32 - prefix.bit_size)) == prefix.bits) { |
38 ConsumeBits(prefix.bit_size); | 40 ConsumeBits(prefix.bit_size); |
39 return true; | 41 return true; |
40 } | 42 } |
41 | |
42 return false; | 43 return false; |
43 } | 44 } |
44 | 45 |
45 bool HpackInputStream::PeekNextOctet(uint8* next_octet) { | 46 bool HpackInputStream::PeekNextOctet(uint8* next_octet) { |
46 if ((bit_offset_ > 0) || buffer_.empty()) | 47 if ((bit_offset_ > 0) || buffer_.empty()) |
47 return false; | 48 return false; |
48 | 49 |
49 *next_octet = buffer_[0]; | 50 *next_octet = buffer_[0]; |
50 return true; | 51 return true; |
51 } | 52 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 buffer_.remove_prefix(byte_count); | 163 buffer_.remove_prefix(byte_count); |
163 } | 164 } |
164 | 165 |
165 void HpackInputStream::ConsumeByteRemainder() { | 166 void HpackInputStream::ConsumeByteRemainder() { |
166 if (bit_offset_ != 0) { | 167 if (bit_offset_ != 0) { |
167 ConsumeBits(8 - bit_offset_); | 168 ConsumeBits(8 - bit_offset_); |
168 } | 169 } |
169 } | 170 } |
170 | 171 |
171 } // namespace net | 172 } // namespace net |
OLD | NEW |