| 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_input_stream.h" | 5 #include "net/spdy/hpack/hpack_input_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/spdy/hpack/hpack_huffman_decoder.h" | 10 #include "net/spdy/hpack/hpack_huffman_decoder.h" |
| 11 #include "net/spdy/spdy_bug_tracker.h" | 11 #include "net/spdy/spdy_bug_tracker.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 using std::string; | |
| 16 | |
| 17 HpackInputStream::HpackInputStream(SpdyStringPiece buffer) | 15 HpackInputStream::HpackInputStream(SpdyStringPiece buffer) |
| 18 : buffer_(buffer), | 16 : buffer_(buffer), |
| 19 bit_offset_(0), | 17 bit_offset_(0), |
| 20 parsed_bytes_(0), | 18 parsed_bytes_(0), |
| 21 parsed_bytes_current_(0), | 19 parsed_bytes_current_(0), |
| 22 need_more_data_(false) {} | 20 need_more_data_(false) {} |
| 23 | 21 |
| 24 HpackInputStream::~HpackInputStream() {} | 22 HpackInputStream::~HpackInputStream() {} |
| 25 | 23 |
| 26 bool HpackInputStream::HasMoreData() const { | 24 bool HpackInputStream::HasMoreData() const { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 need_more_data_ = true; | 126 need_more_data_ = true; |
| 129 return false; | 127 return false; |
| 130 } | 128 } |
| 131 | 129 |
| 132 *str = SpdyStringPiece(buffer_.data(), size); | 130 *str = SpdyStringPiece(buffer_.data(), size); |
| 133 buffer_.remove_prefix(size); | 131 buffer_.remove_prefix(size); |
| 134 parsed_bytes_current_ += size; | 132 parsed_bytes_current_ += size; |
| 135 return true; | 133 return true; |
| 136 } | 134 } |
| 137 | 135 |
| 138 bool HpackInputStream::DecodeNextHuffmanString(string* str) { | 136 bool HpackInputStream::DecodeNextHuffmanString(SpdyString* str) { |
| 139 uint32_t encoded_size = 0; | 137 uint32_t encoded_size = 0; |
| 140 if (!DecodeNextUint32(&encoded_size)) { | 138 if (!DecodeNextUint32(&encoded_size)) { |
| 141 if (!need_more_data_) { | 139 if (!need_more_data_) { |
| 142 DVLOG(1) << "HpackInputStream::DecodeNextHuffmanString " | 140 DVLOG(1) << "HpackInputStream::DecodeNextHuffmanString " |
| 143 << "unable to decode size"; | 141 << "unable to decode size"; |
| 144 } | 142 } |
| 145 return false; | 143 return false; |
| 146 } | 144 } |
| 147 | 145 |
| 148 if (encoded_size > buffer_.size()) { | 146 if (encoded_size > buffer_.size()) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 240 |
| 243 bool HpackInputStream::NeedMoreData() const { | 241 bool HpackInputStream::NeedMoreData() const { |
| 244 return need_more_data_; | 242 return need_more_data_; |
| 245 } | 243 } |
| 246 | 244 |
| 247 void HpackInputStream::MarkCurrentPosition() { | 245 void HpackInputStream::MarkCurrentPosition() { |
| 248 parsed_bytes_ = parsed_bytes_current_; | 246 parsed_bytes_ = parsed_bytes_current_; |
| 249 } | 247 } |
| 250 | 248 |
| 251 } // namespace net | 249 } // namespace net |
| OLD | NEW |