| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic/core/crypto/crypto_framer.h" | 5 #include "net/quic/core/crypto/crypto_framer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "net/quic/core/crypto/crypto_protocol.h" | 10 #include "net/quic/core/crypto/crypto_protocol.h" |
| 11 #include "net/quic/core/quic_data_reader.h" | 11 #include "net/quic/core/quic_data_reader.h" |
| 12 #include "net/quic/core/quic_data_writer.h" | 12 #include "net/quic/core/quic_data_writer.h" |
| 13 | 13 |
| 14 using base::StringPiece; | 14 using base::StringPiece; |
| 15 using std::pair; | |
| 16 using std::vector; | |
| 17 | 15 |
| 18 namespace net { | 16 namespace net { |
| 19 | 17 |
| 20 namespace { | 18 namespace { |
| 21 | 19 |
| 22 const size_t kQuicTagSize = sizeof(uint32_t); | 20 const size_t kQuicTagSize = sizeof(uint32_t); |
| 23 const size_t kCryptoEndOffsetSize = sizeof(uint32_t); | 21 const size_t kCryptoEndOffsetSize = sizeof(uint32_t); |
| 24 const size_t kNumEntriesSize = sizeof(uint16_t); | 22 const size_t kNumEntriesSize = sizeof(uint16_t); |
| 25 | 23 |
| 26 // OneShotVisitor is a framer visitor that records a single handshake message. | 24 // OneShotVisitor is a framer visitor that records a single handshake message. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 tag, static_cast<size_t>(end_offset - last_end_offset))); | 251 tag, static_cast<size_t>(end_offset - last_end_offset))); |
| 254 last_end_offset = end_offset; | 252 last_end_offset = end_offset; |
| 255 } | 253 } |
| 256 values_len_ = last_end_offset; | 254 values_len_ = last_end_offset; |
| 257 state_ = STATE_READING_VALUES; | 255 state_ = STATE_READING_VALUES; |
| 258 } | 256 } |
| 259 case STATE_READING_VALUES: | 257 case STATE_READING_VALUES: |
| 260 if (reader.BytesRemaining() < values_len_) { | 258 if (reader.BytesRemaining() < values_len_) { |
| 261 break; | 259 break; |
| 262 } | 260 } |
| 263 for (const pair<QuicTag, size_t>& item : tags_and_lengths_) { | 261 for (const std::pair<QuicTag, size_t>& item : tags_and_lengths_) { |
| 264 StringPiece value; | 262 StringPiece value; |
| 265 reader.ReadStringPiece(&value, item.second); | 263 reader.ReadStringPiece(&value, item.second); |
| 266 message_.SetStringPiece(item.first, value); | 264 message_.SetStringPiece(item.first, value); |
| 267 } | 265 } |
| 268 visitor_->OnHandshakeMessage(message_); | 266 visitor_->OnHandshakeMessage(message_); |
| 269 Clear(); | 267 Clear(); |
| 270 state_ = STATE_READING_TAG; | 268 state_ = STATE_READING_TAG; |
| 271 break; | 269 break; |
| 272 } | 270 } |
| 273 // Save any remaining data. | 271 // Save any remaining data. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 285 } | 283 } |
| 286 *end_offset += pad_length; | 284 *end_offset += pad_length; |
| 287 if (!writer->WriteUInt32(*end_offset)) { | 285 if (!writer->WriteUInt32(*end_offset)) { |
| 288 DCHECK(false) << "Failed to write end offset."; | 286 DCHECK(false) << "Failed to write end offset."; |
| 289 return false; | 287 return false; |
| 290 } | 288 } |
| 291 return true; | 289 return true; |
| 292 } | 290 } |
| 293 | 291 |
| 294 } // namespace net | 292 } // namespace net |
| OLD | NEW |