| 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 #ifndef NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ | 5 #ifndef NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ |
| 6 #define NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ | 6 #define NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <utility> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 14 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 15 #include "net/quic/crypto/crypto_handshake.h" | 16 #include "net/quic/crypto/crypto_handshake.h" |
| 16 #include "net/quic/crypto/crypto_protocol.h" | 17 #include "net/quic/crypto/crypto_protocol.h" |
| 17 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
| 18 | 19 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 void Clear(); | 80 void Clear(); |
| 80 | 81 |
| 81 void set_error(QuicErrorCode error) { | 82 void set_error(QuicErrorCode error) { |
| 82 error_ = error; | 83 error_ = error; |
| 83 } | 84 } |
| 84 | 85 |
| 85 // Represents the current state of the parsing state machine. | 86 // Represents the current state of the parsing state machine. |
| 86 enum CryptoFramerState { | 87 enum CryptoFramerState { |
| 87 STATE_READING_TAG, | 88 STATE_READING_TAG, |
| 88 STATE_READING_NUM_ENTRIES, | 89 STATE_READING_NUM_ENTRIES, |
| 89 STATE_READING_KEY_TAGS, | 90 STATE_READING_TAGS_AND_LENGTHS, |
| 90 STATE_READING_LENGTHS, | |
| 91 STATE_READING_VALUES | 91 STATE_READING_VALUES |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // Visitor to invoke when messages are parsed. | 94 // Visitor to invoke when messages are parsed. |
| 95 CryptoFramerVisitorInterface* visitor_; | 95 CryptoFramerVisitorInterface* visitor_; |
| 96 // Last error. | 96 // Last error. |
| 97 QuicErrorCode error_; | 97 QuicErrorCode error_; |
| 98 // Remaining unparsed data. | 98 // Remaining unparsed data. |
| 99 std::string buffer_; | 99 std::string buffer_; |
| 100 // Current state of the parsing. | 100 // Current state of the parsing. |
| 101 CryptoFramerState state_; | 101 CryptoFramerState state_; |
| 102 // The message currently being parsed. | 102 // The message currently being parsed. |
| 103 CryptoHandshakeMessage message_; | 103 CryptoHandshakeMessage message_; |
| 104 // Number of entires in the message currently being parsed. | 104 // Number of entires in the message currently being parsed. |
| 105 uint16 num_entries_; | 105 uint16 num_entries_; |
| 106 // Vector of tags in the message currently being parsed. | 106 // tags_and_lengths_ contains the tags that are currently being parsed and |
| 107 CryptoTagVector tags_; | 107 // their lengths. |
| 108 // Length of the data associated with each tag in the message currently | 108 std::vector<std::pair<CryptoTag, size_t> > tags_and_lengths_; |
| 109 // being parsed. | |
| 110 std::map<CryptoTag, size_t> tag_length_map_; | |
| 111 // Cumulative length of all values in the message currently being parsed. | 109 // Cumulative length of all values in the message currently being parsed. |
| 112 size_t values_len_; | 110 size_t values_len_; |
| 113 }; | 111 }; |
| 114 | 112 |
| 115 } // namespace net | 113 } // namespace net |
| 116 | 114 |
| 117 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ | 115 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ |
| OLD | NEW |