Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / net / quic / quic_crypto_stream.cc
blob414c2e2f7c25f5f52ae230b8af4faeb650686646
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.
5 #include "net/quic/quic_crypto_stream.h"
7 #include <string>
9 #include "base/strings/string_piece.h"
10 #include "net/quic/crypto/crypto_handshake.h"
11 #include "net/quic/quic_connection.h"
12 #include "net/quic/quic_session.h"
13 #include "net/quic/quic_utils.h"
15 using std::string;
16 using base::StringPiece;
18 namespace net {
20 QuicCryptoStream::QuicCryptoStream(QuicSession* session)
21 : ReliableQuicStream(kCryptoStreamId, session),
22 encryption_established_(false),
23 handshake_confirmed_(false) {
24 crypto_framer_.set_visitor(this);
27 void QuicCryptoStream::OnError(CryptoFramer* framer) {
28 DLOG(WARNING) << "Error processing crypto data: "
29 << QuicUtils::ErrorToString(framer->error());
32 void QuicCryptoStream::OnHandshakeMessage(
33 const CryptoHandshakeMessage& message) {
34 session()->OnCryptoHandshakeMessageReceived(message);
37 uint32 QuicCryptoStream::ProcessRawData(const char* data,
38 uint32 data_len) {
39 // Do not process handshake messages after the handshake is confirmed.
40 if (handshake_confirmed()) {
41 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE);
42 return 0;
44 if (!crypto_framer_.ProcessInput(StringPiece(data, data_len))) {
45 CloseConnection(crypto_framer_.error());
46 return 0;
48 return data_len;
51 QuicPriority QuicCryptoStream::EffectivePriority() const {
52 return QuicUtils::HighestPriority();
55 void QuicCryptoStream::SendHandshakeMessage(
56 const CryptoHandshakeMessage& message) {
57 session()->OnCryptoHandshakeMessageSent(message);
58 const QuicData& data = message.GetSerialized();
59 // To make reasoning about crypto frames easier, we don't combine them with
60 // any other frames in a single packet.
61 session()->connection()->Flush();
62 // TODO(wtc): check the return value.
63 WriteOrBufferData(string(data.data(), data.length()), false, NULL);
64 session()->connection()->Flush();
67 const QuicCryptoNegotiatedParameters&
68 QuicCryptoStream::crypto_negotiated_params() const {
69 return crypto_negotiated_params_;
72 } // namespace net