Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: net/quic/crypto/crypto_framer.h

Issue 12381018: QUIC - Some sketching of the crypto handshake. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 }; 35 };
36 36
37 // A class for framing the crypto messages that are exchanged in a QUIC 37 // A class for framing the crypto messages that are exchanged in a QUIC
38 // session. 38 // session.
39 class NET_EXPORT_PRIVATE CryptoFramer { 39 class NET_EXPORT_PRIVATE CryptoFramer {
40 public: 40 public:
41 CryptoFramer(); 41 CryptoFramer();
42 42
43 virtual ~CryptoFramer(); 43 virtual ~CryptoFramer();
44 44
45 // ParseMessage parses exactly one message from the given StringPiece. If
46 // there is an error, the message is truncated, or the message has trailing
47 // garbage then NULL will be returned.
48 static CryptoHandshakeMessage* ParseMessage(base::StringPiece in);
49
45 // Set callbacks to be called from the framer. A visitor must be set, or 50 // Set callbacks to be called from the framer. A visitor must be set, or
46 // else the framer will crash. It is acceptable for the visitor to do 51 // else the framer will crash. It is acceptable for the visitor to do
47 // nothing. If this is called multiple times, only the last visitor 52 // nothing. If this is called multiple times, only the last visitor
48 // will be used. |visitor| will be owned by the framer. 53 // will be used. |visitor| will be owned by the framer.
49 void set_visitor(CryptoFramerVisitorInterface* visitor) { 54 void set_visitor(CryptoFramerVisitorInterface* visitor) {
50 visitor_ = visitor; 55 visitor_ = visitor;
51 } 56 }
52 57
53 QuicErrorCode error() const { 58 QuicErrorCode error() const {
54 return error_; 59 return error_;
55 } 60 }
56 61
57 // Processes input data, which must be delivered in order. Returns 62 // Processes input data, which must be delivered in order. Returns
58 // false if there was an error, and true otherwise. 63 // false if there was an error, and true otherwise.
59 bool ProcessInput(base::StringPiece input); 64 bool ProcessInput(base::StringPiece input);
60 65
61 // Returns the number of bytes of buffered input data remaining to be 66 // Returns the number of bytes of buffered input data remaining to be
62 // parsed. 67 // parsed.
63 size_t InputBytesRemaining() const { 68 size_t InputBytesRemaining() const {
64 return buffer_.length(); 69 return buffer_.length();
65 } 70 }
66 71
67 // Returns a new QuicData owned by the caller that contains a serialized 72 // Returns a new QuicData owned by the caller that contains a serialized
68 // |message|, or NULL if there was an error. 73 // |message|, or NULL if there was an error.
69 QuicData* ConstructHandshakeMessage(const CryptoHandshakeMessage& message); 74 static QuicData* ConstructHandshakeMessage(
75 const CryptoHandshakeMessage& message);
70 76
71 private: 77 private:
72 // Clears per-message state. Does not clear the visitor. 78 // Clears per-message state. Does not clear the visitor.
73 void Clear(); 79 void Clear();
74 80
75 void set_error(QuicErrorCode error) { 81 void set_error(QuicErrorCode error) {
76 error_ = error; 82 error_ = error;
77 } 83 }
78 84
79 // Represents the current state of the parsing state machine. 85 // Represents the current state of the parsing state machine.
(...skipping 24 matching lines...) Expand all
104 std::map<CryptoTag, size_t> tag_length_map_; 110 std::map<CryptoTag, size_t> tag_length_map_;
105 // Data associated with each tag in the message currently being parsed. 111 // Data associated with each tag in the message currently being parsed.
106 CryptoTagValueMap tag_value_map_; 112 CryptoTagValueMap tag_value_map_;
107 // Cumulative length of all values in the message currently being parsed. 113 // Cumulative length of all values in the message currently being parsed.
108 size_t values_len_; 114 size_t values_len_;
109 }; 115 };
110 116
111 } // namespace net 117 } // namespace net
112 118
113 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ 119 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698