| Index: net/quic/quartc/quartc_session.cc
|
| diff --git a/net/quic/quartc/quartc_session.cc b/net/quic/quartc/quartc_session.cc
|
| index 0e839c9d437a07014eec61c22de1b07433ba8574..7e5c5af676a460c119411b6db2c0eb845f3d08f0 100644
|
| --- a/net/quic/quartc/quartc_session.cc
|
| +++ b/net/quic/quartc/quartc_session.cc
|
| @@ -149,7 +149,8 @@ QuicCryptoStream* QuartcSession::GetMutableCryptoStream() {
|
|
|
| QuartcStream* QuartcSession::CreateOutgoingDynamicStream(
|
| SpdyPriority priority) {
|
| - return CreateDataStream(GetNextOutgoingStreamId(), priority);
|
| + return ActivateDataStream(
|
| + CreateDataStream(GetNextOutgoingStreamId(), priority));
|
| }
|
|
|
| void QuartcSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
|
| @@ -173,6 +174,21 @@ void QuartcSession::CloseStream(QuicStreamId stream_id) {
|
| QuicSession::CloseStream(stream_id);
|
| }
|
|
|
| +void QuartcSession::CancelStream(QuicStreamId stream_id) {
|
| + ResetStream(stream_id, QuicRstStreamErrorCode::QUIC_STREAM_CANCELLED);
|
| +}
|
| +
|
| +void QuartcSession::ResetStream(QuicStreamId stream_id,
|
| + QuicRstStreamErrorCode error) {
|
| + if (!IsOpenStream(stream_id)) {
|
| + return;
|
| + }
|
| + QuicStream* stream = QuicSession::GetOrCreateStream(stream_id);
|
| + if (stream) {
|
| + stream->Reset(error);
|
| + }
|
| +}
|
| +
|
| void QuartcSession::OnConnectionClosed(QuicErrorCode error,
|
| const string& error_details,
|
| ConnectionCloseSource source) {
|
| @@ -267,35 +283,50 @@ void QuartcSession::SetServerCryptoConfig(
|
| }
|
|
|
| QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) {
|
| - QuartcStream* stream = CreateDataStream(id, kDefaultPriority);
|
| - if (stream) {
|
| - DCHECK(session_delegate_);
|
| - session_delegate_->OnIncomingStream(stream);
|
| - }
|
| - return stream;
|
| + return ActivateDataStream(CreateDataStream(id, kDefaultPriority));
|
| }
|
|
|
| std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) {
|
| - QuartcStream* stream = CreateDataStream(id, kDefaultPriority);
|
| - return QuicWrapUnique(stream);
|
| + return CreateDataStream(id, kDefaultPriority);
|
| }
|
|
|
| -QuartcStream* QuartcSession::CreateDataStream(QuicStreamId id,
|
| - SpdyPriority priority) {
|
| +std::unique_ptr<QuartcStream> QuartcSession::CreateDataStream(
|
| + QuicStreamId id,
|
| + SpdyPriority priority) {
|
| if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) {
|
| // Encryption not active so no stream created
|
| return nullptr;
|
| }
|
| - QuartcStream* stream = new QuartcStream(id, this);
|
| + auto stream = QuicMakeUnique<QuartcStream>(id, this);
|
| if (stream) {
|
| - // Make QuicSession take ownership of the stream.
|
| - ActivateStream(std::unique_ptr<QuicStream>(stream));
|
| // Register the stream to the QuicWriteBlockedList. |priority| is clamped
|
| // between 0 and 7, with 0 being the highest priority and 7 the lowest
|
| // priority.
|
| write_blocked_streams()->RegisterStream(stream->id(), priority);
|
| +
|
| + if (IsIncomingStream(id)) {
|
| + DCHECK(session_delegate_);
|
| + // Incoming streams need to be registered with the session_delegate_.
|
| + session_delegate_->OnIncomingStream(stream.get());
|
| + // Quartc doesn't send on incoming streams.
|
| + stream->set_fin_sent(true);
|
| + } else {
|
| + // Quartc doesn't receive on outgoing streams.
|
| + stream->set_fin_received(true);
|
| + }
|
| }
|
| return stream;
|
| }
|
|
|
| +QuartcStream* QuartcSession::ActivateDataStream(
|
| + std::unique_ptr<QuartcStream> stream) {
|
| + // Transfer ownership of the data stream to the session via ActivateStream().
|
| + QuartcStream* raw = stream.release();
|
| + if (raw) {
|
| + // Make QuicSession take ownership of the stream.
|
| + ActivateStream(std::unique_ptr<QuicStream>(raw));
|
| + }
|
| + return raw;
|
| +}
|
| +
|
| } // namespace net
|
|
|