| 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/crypto/crypto_framer.h" | 5 #include "net/quic/crypto/crypto_framer.h" |
| 6 | 6 |
| 7 #include "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
| 8 #include "net/quic/quic_data_reader.h" | 8 #include "net/quic/quic_data_reader.h" |
| 9 #include "net/quic/quic_data_writer.h" | 9 #include "net/quic/quic_data_writer.h" |
| 10 | 10 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 tag, static_cast<size_t>(end_offset - last_end_offset))); | 245 tag, static_cast<size_t>(end_offset - last_end_offset))); |
| 246 last_end_offset = end_offset; | 246 last_end_offset = end_offset; |
| 247 } | 247 } |
| 248 values_len_ = last_end_offset; | 248 values_len_ = last_end_offset; |
| 249 state_ = STATE_READING_VALUES; | 249 state_ = STATE_READING_VALUES; |
| 250 } | 250 } |
| 251 case STATE_READING_VALUES: | 251 case STATE_READING_VALUES: |
| 252 if (reader.BytesRemaining() < values_len_) { | 252 if (reader.BytesRemaining() < values_len_) { |
| 253 break; | 253 break; |
| 254 } | 254 } |
| 255 for (vector<pair<QuicTag, size_t> >::const_iterator | 255 for (const pair<QuicTag, size_t>& item : tags_and_lengths_) { |
| 256 it = tags_and_lengths_.begin(); it != tags_and_lengths_.end(); | |
| 257 it++) { | |
| 258 StringPiece value; | 256 StringPiece value; |
| 259 reader.ReadStringPiece(&value, it->second); | 257 reader.ReadStringPiece(&value, item.second); |
| 260 message_.SetStringPiece(it->first, value); | 258 message_.SetStringPiece(item.first, value); |
| 261 } | 259 } |
| 262 visitor_->OnHandshakeMessage(message_); | 260 visitor_->OnHandshakeMessage(message_); |
| 263 Clear(); | 261 Clear(); |
| 264 state_ = STATE_READING_TAG; | 262 state_ = STATE_READING_TAG; |
| 265 break; | 263 break; |
| 266 } | 264 } |
| 267 // Save any remaining data. | 265 // Save any remaining data. |
| 268 buffer_ = reader.PeekRemainingPayload().as_string(); | 266 buffer_ = reader.PeekRemainingPayload().as_string(); |
| 269 return QUIC_NO_ERROR; | 267 return QUIC_NO_ERROR; |
| 270 } | 268 } |
| 271 | 269 |
| 272 // static | 270 // static |
| 273 bool CryptoFramer::WritePadTag(QuicDataWriter* writer, | 271 bool CryptoFramer::WritePadTag(QuicDataWriter* writer, |
| 274 size_t pad_length, | 272 size_t pad_length, |
| 275 uint32* end_offset) { | 273 uint32* end_offset) { |
| 276 if (!writer->WriteUInt32(kPAD)) { | 274 if (!writer->WriteUInt32(kPAD)) { |
| 277 DCHECK(false) << "Failed to write tag."; | 275 DCHECK(false) << "Failed to write tag."; |
| 278 return false; | 276 return false; |
| 279 } | 277 } |
| 280 *end_offset += pad_length; | 278 *end_offset += pad_length; |
| 281 if (!writer->WriteUInt32(*end_offset)) { | 279 if (!writer->WriteUInt32(*end_offset)) { |
| 282 DCHECK(false) << "Failed to write end offset."; | 280 DCHECK(false) << "Failed to write end offset."; |
| 283 return false; | 281 return false; |
| 284 } | 282 } |
| 285 return true; | 283 return true; |
| 286 } | 284 } |
| 287 | 285 |
| 288 } // namespace net | 286 } // namespace net |
| OLD | NEW |