| 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_decoder.h" | 5 #include "net/spdy/hpack/hpack_decoder.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 | 183 |
| 184 const HpackEntry* entry = header_table_.GetByIndex(index_or_zero); | 184 const HpackEntry* entry = header_table_.GetByIndex(index_or_zero); |
| 185 if (entry == NULL) { | 185 if (entry == NULL) { |
| 186 return false; | 186 return false; |
| 187 } | 187 } |
| 188 if (entry->IsStatic()) { | 188 if (entry->IsStatic()) { |
| 189 *next_name = entry->name(); | 189 *next_name = entry->name(); |
| 190 } else { | 190 } else { |
| 191 // |entry| could be evicted as part of this insertion. Preemptively copy. | 191 // |entry| could be evicted as part of this insertion. Preemptively copy. |
| 192 key_buffer_.assign(entry->name()); | 192 key_buffer_.assign(entry->name().data(), entry->name().size()); |
| 193 *next_name = key_buffer_; | 193 *next_name = key_buffer_; |
| 194 } | 194 } |
| 195 return true; | 195 return true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream, | 198 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream, |
| 199 bool is_key, | 199 bool is_key, |
| 200 StringPiece* output) { | 200 StringPiece* output) { |
| 201 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) { | 201 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) { |
| 202 string* buffer = is_key ? &key_buffer_ : &value_buffer_; | 202 string* buffer = is_key ? &key_buffer_ : &value_buffer_; |
| 203 bool result = input_stream->DecodeNextHuffmanString(huffman_table_, buffer); | 203 bool result = input_stream->DecodeNextHuffmanString(huffman_table_, buffer); |
| 204 *output = StringPiece(*buffer); | 204 *output = StringPiece(*buffer); |
| 205 return result; | 205 return result; |
| 206 } | 206 } |
| 207 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { | 207 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { |
| 208 return input_stream->DecodeNextIdentityString(output); | 208 return input_stream->DecodeNextIdentityString(output); |
| 209 } | 209 } |
| 210 return false; | 210 return false; |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace net | 213 } // namespace net |
| OLD | NEW |