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

Side by Side Diff: net/quic/quartc/quartc_session.cc

Issue 2915993002: Move tests from portable_quic to the new quic/quartc wrapper location. (Closed)
Patch Set: Added missing test files and included in BUILD.gn Created 3 years, 6 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/quartc/quartc_session.h ('k') | net/quic/quartc/quartc_session_test.cc » ('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) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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/quartc/quartc_session.h" 5 #include "net/quic/quartc/quartc_session.h"
6 6
7 #include "net/quic/platform/api/quic_ptr_util.h" 7 #include "net/quic/platform/api/quic_ptr_util.h"
8 8
9 using std::string; 9 using std::string;
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const QuicCryptoStream* QuartcSession::GetCryptoStream() const { 142 const QuicCryptoStream* QuartcSession::GetCryptoStream() const {
143 return crypto_stream_.get(); 143 return crypto_stream_.get();
144 } 144 }
145 145
146 QuicCryptoStream* QuartcSession::GetMutableCryptoStream() { 146 QuicCryptoStream* QuartcSession::GetMutableCryptoStream() {
147 return crypto_stream_.get(); 147 return crypto_stream_.get();
148 } 148 }
149 149
150 QuartcStream* QuartcSession::CreateOutgoingDynamicStream( 150 QuartcStream* QuartcSession::CreateOutgoingDynamicStream(
151 SpdyPriority priority) { 151 SpdyPriority priority) {
152 return CreateDataStream(GetNextOutgoingStreamId(), priority); 152 return ActivateDataStream(
153 CreateDataStream(GetNextOutgoingStreamId(), priority));
153 } 154 }
154 155
155 void QuartcSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { 156 void QuartcSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
156 QuicSession::OnCryptoHandshakeEvent(event); 157 QuicSession::OnCryptoHandshakeEvent(event);
157 if (event == HANDSHAKE_CONFIRMED) { 158 if (event == HANDSHAKE_CONFIRMED) {
158 DCHECK(IsEncryptionEstablished()); 159 DCHECK(IsEncryptionEstablished());
159 DCHECK(IsCryptoHandshakeConfirmed()); 160 DCHECK(IsCryptoHandshakeConfirmed());
160 161
161 DCHECK(session_delegate_); 162 DCHECK(session_delegate_);
162 session_delegate_->OnCryptoHandshakeComplete(); 163 session_delegate_->OnCryptoHandshakeComplete();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 QuicCryptoClientConfig* client_config) { 261 QuicCryptoClientConfig* client_config) {
261 quic_crypto_client_config_.reset(client_config); 262 quic_crypto_client_config_.reset(client_config);
262 } 263 }
263 264
264 void QuartcSession::SetServerCryptoConfig( 265 void QuartcSession::SetServerCryptoConfig(
265 QuicCryptoServerConfig* server_config) { 266 QuicCryptoServerConfig* server_config) {
266 quic_crypto_server_config_.reset(server_config); 267 quic_crypto_server_config_.reset(server_config);
267 } 268 }
268 269
269 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { 270 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) {
270 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); 271 return ActivateDataStream(CreateDataStream(id, kDefaultPriority));
272 }
273
274 std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) {
275 return CreateDataStream(id, kDefaultPriority);
276 }
277
278 std::unique_ptr<QuartcStream> QuartcSession::CreateDataStream(
279 QuicStreamId id,
280 SpdyPriority priority) {
281 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) {
282 // Encryption not active so no stream created
283 return nullptr;
284 }
285 auto stream = QuicMakeUnique<QuartcStream>(id, this);
271 if (stream) { 286 if (stream) {
272 DCHECK(session_delegate_); 287 // Register the stream to the QuicWriteBlockedList. |priority| is clamped
273 session_delegate_->OnIncomingStream(stream); 288 // between 0 and 7, with 0 being the highest priority and 7 the lowest
289 // priority.
290 write_blocked_streams()->RegisterStream(stream->id(), priority);
291
292 // Incoming streams need to be registered with the session_delegate_.
293 if (IsIncomingStream(id)) {
294 DCHECK(session_delegate_);
295 session_delegate_->OnIncomingStream(stream.get());
296 }
274 } 297 }
275 return stream; 298 return stream;
276 } 299 }
277 300
278 std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) { 301 QuartcStream* QuartcSession::ActivateDataStream(
279 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); 302 std::unique_ptr<QuartcStream> stream) {
280 return QuicWrapUnique(stream); 303 // Transfer ownership of the data stream to the session via ActivateStream().
281 } 304 QuartcStream* raw = stream.release();
282 305 if (raw) {
283 QuartcStream* QuartcSession::CreateDataStream(QuicStreamId id, 306 // Make QuicSession take ownership of the stream.
284 SpdyPriority priority) { 307 ActivateStream(std::unique_ptr<QuicStream>(raw));
285 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) {
286 // Encryption not active so no stream created
287 return nullptr;
288 } 308 }
289 QuartcStream* stream = new QuartcStream(id, this); 309 return raw;
290 if (stream) {
291 // Make QuicSession take ownership of the stream.
292 ActivateStream(std::unique_ptr<QuicStream>(stream));
293 // Register the stream to the QuicWriteBlockedList. |priority| is clamped
294 // between 0 and 7, with 0 being the highest priority and 7 the lowest
295 // priority.
296 write_blocked_streams()->RegisterStream(stream->id(), priority);
297 }
298 return stream;
299 } 310 }
300 311
301 } // namespace net 312 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quartc/quartc_session.h ('k') | net/quic/quartc/quartc_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698