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

Side by Side Diff: net/quic/quic_crypto_stream.cc

Issue 420313005: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0723
Patch Set: change QUIC packet size to 1350 Created 6 years, 4 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
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 #include "net/quic/quic_crypto_stream.h" 5 #include "net/quic/quic_crypto_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "net/quic/crypto/crypto_handshake.h" 10 #include "net/quic/crypto/crypto_handshake.h"
11 #include "net/quic/crypto/crypto_utils.h" 11 #include "net/quic/crypto/crypto_utils.h"
12 #include "net/quic/quic_connection.h" 12 #include "net/quic/quic_connection.h"
13 #include "net/quic/quic_session.h" 13 #include "net/quic/quic_session.h"
14 #include "net/quic/quic_utils.h" 14 #include "net/quic/quic_utils.h"
15 15
16 using std::string; 16 using std::string;
17 using base::StringPiece; 17 using base::StringPiece;
18 18
19 namespace net { 19 namespace net {
20 20
21 #define ENDPOINT (is_server_ ? "Server: " : " Client: ")
wtc 2014/08/04 23:28:13 Nit: It seems that we can just call session()->is_
ramant (doing other things) 2014/08/09 02:53:19 Done.
22
21 QuicCryptoStream::QuicCryptoStream(QuicSession* session) 23 QuicCryptoStream::QuicCryptoStream(QuicSession* session)
22 : ReliableQuicStream(kCryptoStreamId, session), 24 : ReliableQuicStream(kCryptoStreamId, session),
23 encryption_established_(false), 25 encryption_established_(false),
24 handshake_confirmed_(false) { 26 handshake_confirmed_(false),
27 is_server_(session->is_server()) {
25 crypto_framer_.set_visitor(this); 28 crypto_framer_.set_visitor(this);
26 if (version() <= QUIC_VERSION_20) { 29 if (version() <= QUIC_VERSION_20) {
27 // Prior to QUIC_VERSION_21 the crypto stream is not subject to any flow 30 // Prior to QUIC_VERSION_21 the crypto stream is not subject to any flow
28 // control. 31 // control.
29 DisableFlowControl(); 32 DisableFlowControl();
30 } 33 }
31 // The crypto stream is exempt from connection level flow control. 34 // The crypto stream is exempt from connection level flow control.
32 DisableConnectionFlowControlForThisStream(); 35 DisableConnectionFlowControlForThisStream();
33 } 36 }
34 37
35 void QuicCryptoStream::OnError(CryptoFramer* framer) { 38 void QuicCryptoStream::OnError(CryptoFramer* framer) {
36 DLOG(WARNING) << "Error processing crypto data: " 39 DLOG(WARNING) << "Error processing crypto data: "
37 << QuicUtils::ErrorToString(framer->error()); 40 << QuicUtils::ErrorToString(framer->error());
38 } 41 }
39 42
40 void QuicCryptoStream::OnHandshakeMessage( 43 void QuicCryptoStream::OnHandshakeMessage(
41 const CryptoHandshakeMessage& message) { 44 const CryptoHandshakeMessage& message) {
45 DVLOG(1) << ENDPOINT << "Received " << message.DebugString();
42 session()->OnCryptoHandshakeMessageReceived(message); 46 session()->OnCryptoHandshakeMessageReceived(message);
43 } 47 }
44 48
45 uint32 QuicCryptoStream::ProcessRawData(const char* data, 49 uint32 QuicCryptoStream::ProcessRawData(const char* data,
46 uint32 data_len) { 50 uint32 data_len) {
47 if (!crypto_framer_.ProcessInput(StringPiece(data, data_len))) { 51 if (!crypto_framer_.ProcessInput(StringPiece(data, data_len))) {
48 CloseConnection(crypto_framer_.error()); 52 CloseConnection(crypto_framer_.error());
49 return 0; 53 return 0;
50 } 54 }
51 return data_len; 55 return data_len;
52 } 56 }
53 57
54 QuicPriority QuicCryptoStream::EffectivePriority() const { 58 QuicPriority QuicCryptoStream::EffectivePriority() const {
55 return QuicUtils::HighestPriority(); 59 return QuicUtils::HighestPriority();
56 } 60 }
57 61
58 void QuicCryptoStream::SendHandshakeMessage( 62 void QuicCryptoStream::SendHandshakeMessage(
59 const CryptoHandshakeMessage& message) { 63 const CryptoHandshakeMessage& message) {
64 DVLOG(1) << ENDPOINT << "Sending " << message.DebugString();
60 session()->OnCryptoHandshakeMessageSent(message); 65 session()->OnCryptoHandshakeMessageSent(message);
61 const QuicData& data = message.GetSerialized(); 66 const QuicData& data = message.GetSerialized();
62 // TODO(wtc): check the return value. 67 // TODO(wtc): check the return value.
63 WriteOrBufferData(string(data.data(), data.length()), false, NULL); 68 WriteOrBufferData(string(data.data(), data.length()), false, NULL);
64 } 69 }
65 70
66 bool QuicCryptoStream::ExportKeyingMaterial( 71 bool QuicCryptoStream::ExportKeyingMaterial(
67 StringPiece label, 72 StringPiece label,
68 StringPiece context, 73 StringPiece context,
69 size_t result_len, 74 size_t result_len,
(...skipping 10 matching lines...) Expand all
80 result_len, 85 result_len,
81 result); 86 result);
82 } 87 }
83 88
84 const QuicCryptoNegotiatedParameters& 89 const QuicCryptoNegotiatedParameters&
85 QuicCryptoStream::crypto_negotiated_params() const { 90 QuicCryptoStream::crypto_negotiated_params() const {
86 return crypto_negotiated_params_; 91 return crypto_negotiated_params_;
87 } 92 }
88 93
89 } // namespace net 94 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698