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

Unified Diff: net/quic/crypto/crypto_framer.cc

Issue 12381018: QUIC - Some sketching of the crypto handshake. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/crypto/crypto_framer.h ('k') | net/quic/crypto/crypto_handshake.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/crypto_framer.cc
===================================================================
--- net/quic/crypto/crypto_framer.cc (revision 184750)
+++ net/quic/crypto/crypto_framer.cc (working copy)
@@ -18,6 +18,31 @@
const size_t kNumEntriesSize = sizeof(uint16);
const size_t kValueLenSize = sizeof(uint16);
+// OneShotVisitor is a framer visitor that records a single handshake message.
+class OneShotVisitor : public CryptoFramerVisitorInterface {
+ public:
+ explicit OneShotVisitor(CryptoHandshakeMessage* out)
+ : out_(out),
+ error_(false) {
+ }
+
+ void OnError(CryptoFramer* framer) {
+ error_ = true;
+ }
+
+ void OnHandshakeMessage(const CryptoHandshakeMessage& message) {
+ *out_ = message;
+ }
+
+ bool error() const {
+ return error_;
+ }
+
+ private:
+ CryptoHandshakeMessage* const out_;
+ bool error_;
+};
+
} // namespace
CryptoFramer::CryptoFramer()
@@ -30,6 +55,22 @@
CryptoFramer::~CryptoFramer() {}
+// static
+CryptoHandshakeMessage* CryptoFramer::ParseMessage(StringPiece in) {
+ scoped_ptr<CryptoHandshakeMessage> msg(new CryptoHandshakeMessage);
+ OneShotVisitor visitor(msg.get());
+ CryptoFramer framer;
+
+ framer.set_visitor(&visitor);
+ if (!framer.ProcessInput(in) ||
+ visitor.error() ||
+ framer.InputBytesRemaining()) {
+ return NULL;
+ }
+
+ return msg.release();
+}
+
bool CryptoFramer::ProcessInput(StringPiece input) {
DCHECK_EQ(QUIC_NO_ERROR, error_);
if (error_ != QUIC_NO_ERROR) {
@@ -119,6 +160,7 @@
return true;
}
+// static
QuicData* CryptoFramer::ConstructHandshakeMessage(
const CryptoHandshakeMessage& message) {
if (message.tag_value_map.size() > kMaxEntries) {
« no previous file with comments | « net/quic/crypto/crypto_framer.h ('k') | net/quic/crypto/crypto_handshake.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698