OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 : net::Perspective::IS_SERVER; | 436 : net::Perspective::IS_SERVER; |
437 bool owns_writer = false; | 437 bool owns_writer = false; |
438 rtc::scoped_ptr<net::QuicConnection> connection(new net::QuicConnection( | 438 rtc::scoped_ptr<net::QuicConnection> connection(new net::QuicConnection( |
439 kConnectionId, kConnectionIpEndpoint, &helper_, this, owns_writer, | 439 kConnectionId, kConnectionIpEndpoint, &helper_, this, owns_writer, |
440 perspective, net::QuicSupportedVersions())); | 440 perspective, net::QuicSupportedVersions())); |
441 quic_.reset(new QuicSession(std::move(connection), config_)); | 441 quic_.reset(new QuicSession(std::move(connection), config_)); |
442 quic_->SignalHandshakeComplete.connect( | 442 quic_->SignalHandshakeComplete.connect( |
443 this, &QuicTransportChannel::OnHandshakeComplete); | 443 this, &QuicTransportChannel::OnHandshakeComplete); |
444 quic_->SignalConnectionClosed.connect( | 444 quic_->SignalConnectionClosed.connect( |
445 this, &QuicTransportChannel::OnConnectionClosed); | 445 this, &QuicTransportChannel::OnConnectionClosed); |
| 446 quic_->SignalIncomingStream.connect(this, |
| 447 &QuicTransportChannel::OnIncomingStream); |
446 return true; | 448 return true; |
447 } | 449 } |
448 | 450 |
449 bool QuicTransportChannel::StartQuicHandshake() { | 451 bool QuicTransportChannel::StartQuicHandshake() { |
450 if (*ssl_role_ == rtc::SSL_CLIENT) { | 452 if (*ssl_role_ == rtc::SSL_CLIENT) { |
451 // Unique identifier for remote peer. | 453 // Unique identifier for remote peer. |
452 net::QuicServerId server_id(remote_fingerprint_->value, kQuicServerPort); | 454 net::QuicServerId server_id(remote_fingerprint_->value, kQuicServerPort); |
453 // Perform authentication of remote peer; owned by QuicCryptoClientConfig. | 455 // Perform authentication of remote peer; owned by QuicCryptoClientConfig. |
454 // TODO(mikescarlett): Actually verify proof. | 456 // TODO(mikescarlett): Actually verify proof. |
455 net::ProofVerifier* proof_verifier = new InsecureProofVerifier(); | 457 net::ProofVerifier* proof_verifier = new InsecureProofVerifier(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 518 |
517 // TODO(mikescarlett): Implement check for whether |channel_| is currently | 519 // TODO(mikescarlett): Implement check for whether |channel_| is currently |
518 // write blocked so that |quic_| does not try to write packet. This is | 520 // write blocked so that |quic_| does not try to write packet. This is |
519 // necessary because |channel_| can be writable yet write blocked and | 521 // necessary because |channel_| can be writable yet write blocked and |
520 // channel_->GetError() is not flushed when there is no error. | 522 // channel_->GetError() is not flushed when there is no error. |
521 bool QuicTransportChannel::IsWriteBlocked() const { | 523 bool QuicTransportChannel::IsWriteBlocked() const { |
522 return !channel_->writable(); | 524 return !channel_->writable(); |
523 } | 525 } |
524 | 526 |
525 void QuicTransportChannel::OnHandshakeComplete() { | 527 void QuicTransportChannel::OnHandshakeComplete() { |
| 528 LOG_J(LS_INFO, this) |
| 529 << "QUIC handshake complete, setting QuicTransportChanel to writable"; |
526 set_quic_state(QUIC_TRANSPORT_CONNECTED); | 530 set_quic_state(QUIC_TRANSPORT_CONNECTED); |
527 set_writable(true); | 531 set_writable(true); |
528 // OnReceivingState might have been called before the QUIC channel was | 532 // OnReceivingState might have been called before the QUIC channel was |
529 // connected, in which case the QUIC channel is now receiving. | 533 // connected, in which case the QUIC channel is now receiving. |
530 if (channel_->receiving()) { | 534 if (channel_->receiving()) { |
531 set_receiving(true); | 535 set_receiving(true); |
532 } | 536 } |
533 } | 537 } |
534 | 538 |
535 void QuicTransportChannel::OnConnectionClosed(net::QuicErrorCode error, | 539 void QuicTransportChannel::OnConnectionClosed(net::QuicErrorCode error, |
536 bool from_peer) { | 540 bool from_peer) { |
537 LOG_J(LS_INFO, this) << "Connection closed by " | 541 LOG_J(LS_INFO, this) << "Connection closed by " |
538 << (from_peer ? "other" : "this") << " peer " | 542 << (from_peer ? "other" : "this") << " peer " |
539 << "with QUIC error " << error; | 543 << "with QUIC error " << error; |
540 // TODO(mikescarlett): Allow the QUIC session to be reset when the connection | 544 // TODO(mikescarlett): Allow the QUIC session to be reset when the connection |
541 // does not close due to failure. | 545 // does not close due to failure. |
542 set_quic_state(QUIC_TRANSPORT_CLOSED); | 546 set_quic_state(QUIC_TRANSPORT_CLOSED); |
543 set_writable(false); | 547 set_writable(false); |
| 548 SignalClosed(); |
544 } | 549 } |
545 | 550 |
546 void QuicTransportChannel::OnProofValid( | 551 void QuicTransportChannel::OnProofValid( |
547 const net::QuicCryptoClientConfig::CachedState& cached) { | 552 const net::QuicCryptoClientConfig::CachedState& cached) { |
548 LOG_J(LS_INFO, this) << "Cached proof marked valid"; | 553 LOG_J(LS_INFO, this) << "Cached proof marked valid"; |
549 } | 554 } |
550 | 555 |
551 void QuicTransportChannel::OnProofVerifyDetailsAvailable( | 556 void QuicTransportChannel::OnProofVerifyDetailsAvailable( |
552 const net::ProofVerifyDetails& verify_details) { | 557 const net::ProofVerifyDetails& verify_details) { |
553 LOG_J(LS_INFO, this) << "Proof verify details available from" | 558 LOG_J(LS_INFO, this) << "Proof verify details available from" |
554 << " QuicCryptoClientStream"; | 559 << " QuicCryptoClientStream"; |
555 } | 560 } |
556 | 561 |
557 bool QuicTransportChannel::HasDataToWrite() const { | 562 bool QuicTransportChannel::HasDataToWrite() const { |
558 return quic_ && quic_->HasDataToWrite(); | 563 return quic_ && quic_->HasDataToWrite(); |
559 } | 564 } |
560 | 565 |
561 void QuicTransportChannel::OnCanWrite() { | 566 void QuicTransportChannel::OnCanWrite() { |
562 RTC_DCHECK(quic_ != nullptr); | 567 RTC_DCHECK(quic_ != nullptr); |
563 quic_->connection()->OnCanWrite(); | 568 quic_->connection()->OnCanWrite(); |
564 } | 569 } |
565 | 570 |
566 void QuicTransportChannel::set_quic_state(QuicTransportState state) { | 571 void QuicTransportChannel::set_quic_state(QuicTransportState state) { |
567 LOG_J(LS_VERBOSE, this) << "set_quic_state from:" << quic_state_ << " to " | 572 LOG_J(LS_VERBOSE, this) << "set_quic_state from:" << quic_state_ << " to " |
568 << state; | 573 << state; |
569 quic_state_ = state; | 574 quic_state_ = state; |
570 } | 575 } |
571 | 576 |
| 577 ReliableQuicStream* QuicTransportChannel::CreateQuicStream() { |
| 578 if (quic_) { |
| 579 net::SpdyPriority priority = 0; // Priority of the QUIC stream (not used) |
| 580 return quic_->CreateOutgoingDynamicStream(priority); |
| 581 } |
| 582 return nullptr; |
| 583 } |
| 584 |
| 585 void QuicTransportChannel::OnIncomingStream(ReliableQuicStream* stream) { |
| 586 SignalIncomingStream(stream); |
| 587 } |
| 588 |
572 } // namespace cricket | 589 } // namespace cricket |
OLD | NEW |