OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/quic/quic_crypto_stream.h" |
| 6 #include "net/quic/quic_session.h" |
| 7 |
| 8 using base::StringPiece; |
| 9 |
| 10 namespace net { |
| 11 |
| 12 QuicCryptoStream::QuicCryptoStream(QuicSession* session) |
| 13 : ReliableQuicStream(kCryptoStreamId, session), |
| 14 handshake_complete_(false) { |
| 15 crypto_framer_.set_visitor(this); |
| 16 } |
| 17 |
| 18 void QuicCryptoStream::OnError(CryptoFramer* framer) { |
| 19 session()->ConnectionClose(framer->error(), false); |
| 20 } |
| 21 |
| 22 uint32 QuicCryptoStream::ProcessData(const char* data, |
| 23 uint32 data_len) { |
| 24 // Do not process handshake messages after the handshake is complete. |
| 25 if (handshake_complete()) { |
| 26 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); |
| 27 return 0; |
| 28 } |
| 29 if (!crypto_framer_.ProcessInput(StringPiece(data, data_len))) { |
| 30 CloseConnection(crypto_framer_.error()); |
| 31 return 0; |
| 32 } |
| 33 return data_len; |
| 34 } |
| 35 |
| 36 void QuicCryptoStream::CloseConnection(QuicErrorCode error) { |
| 37 session()->connection()->SendConnectionClose(error); |
| 38 } |
| 39 |
| 40 void QuicCryptoStream::SendHandshakeMessage( |
| 41 const CryptoHandshakeMessage& message) { |
| 42 scoped_ptr<QuicData> data(crypto_framer_.ConstructHandshakeMessage(message)); |
| 43 WriteData(string(data->data(), data->length()), false); |
| 44 } |
| 45 |
| 46 } // namespace net |
OLD | NEW |