| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 // Set callbacks to be called from the framer. A visitor must be set, or | 49 // Set callbacks to be called from the framer. A visitor must be set, or |
| 50 // else the framer will crash. It is acceptable for the visitor to do | 50 // else the framer will crash. It is acceptable for the visitor to do |
| 51 // nothing. If this is called multiple times, only the last visitor | 51 // nothing. If this is called multiple times, only the last visitor |
| 52 // will be used. |visitor| will be owned by the framer. | 52 // will be used. |visitor| will be owned by the framer. |
| 53 void set_visitor(CryptoFramerVisitorInterface* visitor) { | 53 void set_visitor(CryptoFramerVisitorInterface* visitor) { |
| 54 visitor_ = visitor; | 54 visitor_ = visitor; |
| 55 } | 55 } |
| 56 | 56 |
| 57 QuicErrorCode error() const { return error_; } | 57 QuicErrorCode error() const { return error_; } |
| 58 const std::string& error_detail() const { return error_detail_; } |
| 58 | 59 |
| 59 // Processes input data, which must be delivered in order. Returns | 60 // Processes input data, which must be delivered in order. Returns |
| 60 // false if there was an error, and true otherwise. | 61 // false if there was an error, and true otherwise. |
| 61 bool ProcessInput(base::StringPiece input); | 62 bool ProcessInput(base::StringPiece input); |
| 62 | 63 |
| 63 // Returns the number of bytes of buffered input data remaining to be | 64 // Returns the number of bytes of buffered input data remaining to be |
| 64 // parsed. | 65 // parsed. |
| 65 size_t InputBytesRemaining() const { return buffer_.length(); } | 66 size_t InputBytesRemaining() const { return buffer_.length(); } |
| 66 | 67 |
| 67 // Returns a new QuicData owned by the caller that contains a serialized | 68 // Returns a new QuicData owned by the caller that contains a serialized |
| (...skipping 24 matching lines...) Expand all Loading... |
| 92 // Visitor to invoke when messages are parsed. | 93 // Visitor to invoke when messages are parsed. |
| 93 CryptoFramerVisitorInterface* visitor_; | 94 CryptoFramerVisitorInterface* visitor_; |
| 94 // Last error. | 95 // Last error. |
| 95 QuicErrorCode error_; | 96 QuicErrorCode error_; |
| 96 // Remaining unparsed data. | 97 // Remaining unparsed data. |
| 97 std::string buffer_; | 98 std::string buffer_; |
| 98 // Current state of the parsing. | 99 // Current state of the parsing. |
| 99 CryptoFramerState state_; | 100 CryptoFramerState state_; |
| 100 // The message currently being parsed. | 101 // The message currently being parsed. |
| 101 CryptoHandshakeMessage message_; | 102 CryptoHandshakeMessage message_; |
| 103 // The issue which caused |error_| |
| 104 std::string error_detail_; |
| 102 // Number of entires in the message currently being parsed. | 105 // Number of entires in the message currently being parsed. |
| 103 uint16 num_entries_; | 106 uint16 num_entries_; |
| 104 // tags_and_lengths_ contains the tags that are currently being parsed and | 107 // tags_and_lengths_ contains the tags that are currently being parsed and |
| 105 // their lengths. | 108 // their lengths. |
| 106 std::vector<std::pair<QuicTag, size_t>> tags_and_lengths_; | 109 std::vector<std::pair<QuicTag, size_t>> tags_and_lengths_; |
| 107 // Cumulative length of all values in the message currently being parsed. | 110 // Cumulative length of all values in the message currently being parsed. |
| 108 size_t values_len_; | 111 size_t values_len_; |
| 109 }; | 112 }; |
| 110 | 113 |
| 111 } // namespace net | 114 } // namespace net |
| 112 | 115 |
| 113 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ | 116 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ |
| OLD | NEW |