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

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

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 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
« no previous file with comments | « net/quic/core/quic_crypto_stream.h ('k') | net/quic/core/quic_data_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/core/quic_crypto_stream.h" 5 #include "net/quic/core/quic_crypto_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_piece.h"
10 #include "net/quic/core/crypto/crypto_handshake.h" 9 #include "net/quic/core/crypto/crypto_handshake.h"
11 #include "net/quic/core/crypto/crypto_utils.h" 10 #include "net/quic/core/crypto/crypto_utils.h"
12 #include "net/quic/core/quic_connection.h" 11 #include "net/quic/core/quic_connection.h"
13 #include "net/quic/core/quic_flags.h" 12 #include "net/quic/core/quic_flags.h"
14 #include "net/quic/core/quic_session.h" 13 #include "net/quic/core/quic_session.h"
15 #include "net/quic/core/quic_utils.h" 14 #include "net/quic/core/quic_utils.h"
16 #include "net/quic/platform/api/quic_logging.h" 15 #include "net/quic/platform/api/quic_logging.h"
17 16
18 using std::string; 17 using std::string;
19 using base::StringPiece;
20 18
21 namespace net { 19 namespace net {
22 20
23 #define ENDPOINT \ 21 #define ENDPOINT \
24 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ 22 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \
25 " ") 23 " ")
26 24
27 QuicCryptoStream::QuicCryptoStream(QuicSession* session) 25 QuicCryptoStream::QuicCryptoStream(QuicSession* session)
28 : QuicStream(kCryptoStreamId, session), 26 : QuicStream(kCryptoStreamId, session),
29 encryption_established_(false), 27 encryption_established_(false),
(...skipping 27 matching lines...) Expand all
57 session()->OnCryptoHandshakeMessageReceived(message); 55 session()->OnCryptoHandshakeMessageReceived(message);
58 } 56 }
59 57
60 void QuicCryptoStream::OnDataAvailable() { 58 void QuicCryptoStream::OnDataAvailable() {
61 struct iovec iov; 59 struct iovec iov;
62 while (true) { 60 while (true) {
63 if (sequencer()->GetReadableRegions(&iov, 1) != 1) { 61 if (sequencer()->GetReadableRegions(&iov, 1) != 1) {
64 // No more data to read. 62 // No more data to read.
65 break; 63 break;
66 } 64 }
67 StringPiece data(static_cast<char*>(iov.iov_base), iov.iov_len); 65 QuicStringPiece data(static_cast<char*>(iov.iov_base), iov.iov_len);
68 if (!crypto_framer_.ProcessInput(data)) { 66 if (!crypto_framer_.ProcessInput(data)) {
69 CloseConnectionWithDetails(crypto_framer_.error(), 67 CloseConnectionWithDetails(crypto_framer_.error(),
70 crypto_framer_.error_detail()); 68 crypto_framer_.error_detail());
71 return; 69 return;
72 } 70 }
73 sequencer()->MarkConsumed(iov.iov_len); 71 sequencer()->MarkConsumed(iov.iov_len);
74 if (handshake_confirmed_ && crypto_framer_.InputBytesRemaining() == 0 && 72 if (handshake_confirmed_ && crypto_framer_.InputBytesRemaining() == 0 &&
75 FLAGS_quic_reloadable_flag_quic_release_crypto_stream_buffer) { 73 FLAGS_quic_reloadable_flag_quic_release_crypto_stream_buffer) {
76 // If the handshake is complete and the current message has been fully 74 // If the handshake is complete and the current message has been fully
77 // processed then no more handshake messages are likely to arrive soon 75 // processed then no more handshake messages are likely to arrive soon
78 // so release the memory in the stream sequencer. 76 // so release the memory in the stream sequencer.
79 sequencer()->ReleaseBufferIfEmpty(); 77 sequencer()->ReleaseBufferIfEmpty();
80 } 78 }
81 } 79 }
82 } 80 }
83 81
84 void QuicCryptoStream::SendHandshakeMessage( 82 void QuicCryptoStream::SendHandshakeMessage(
85 const CryptoHandshakeMessage& message) { 83 const CryptoHandshakeMessage& message) {
86 QUIC_DVLOG(1) << ENDPOINT << "Sending " << message.DebugString(); 84 QUIC_DVLOG(1) << ENDPOINT << "Sending " << message.DebugString();
87 session()->connection()->NeuterUnencryptedPackets(); 85 session()->connection()->NeuterUnencryptedPackets();
88 session()->OnCryptoHandshakeMessageSent(message); 86 session()->OnCryptoHandshakeMessageSent(message);
89 const QuicData& data = message.GetSerialized(); 87 const QuicData& data = message.GetSerialized();
90 WriteOrBufferData(StringPiece(data.data(), data.length()), false, nullptr); 88 WriteOrBufferData(QuicStringPiece(data.data(), data.length()), false,
89 nullptr);
91 } 90 }
92 91
93 bool QuicCryptoStream::ExportKeyingMaterial(StringPiece label, 92 bool QuicCryptoStream::ExportKeyingMaterial(QuicStringPiece label,
94 StringPiece context, 93 QuicStringPiece context,
95 size_t result_len, 94 size_t result_len,
96 string* result) const { 95 string* result) const {
97 if (!handshake_confirmed()) { 96 if (!handshake_confirmed()) {
98 QUIC_DLOG(ERROR) << "ExportKeyingMaterial was called before forward-secure" 97 QUIC_DLOG(ERROR) << "ExportKeyingMaterial was called before forward-secure"
99 << "encryption was established."; 98 << "encryption was established.";
100 return false; 99 return false;
101 } 100 }
102 return CryptoUtils::ExportKeyingMaterial( 101 return CryptoUtils::ExportKeyingMaterial(
103 crypto_negotiated_params_->subkey_secret, label, context, result_len, 102 crypto_negotiated_params_->subkey_secret, label, context, result_len,
104 result); 103 result);
(...skipping 10 matching lines...) Expand all
115 "EXPORTER-Token-Binding", 114 "EXPORTER-Token-Binding",
116 /* context= */ "", 32, result); 115 /* context= */ "", 32, result);
117 } 116 }
118 117
119 const QuicCryptoNegotiatedParameters& 118 const QuicCryptoNegotiatedParameters&
120 QuicCryptoStream::crypto_negotiated_params() const { 119 QuicCryptoStream::crypto_negotiated_params() const {
121 return *crypto_negotiated_params_; 120 return *crypto_negotiated_params_;
122 } 121 }
123 122
124 } // namespace net 123 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_stream.h ('k') | net/quic/core/quic_data_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698