| OLD | NEW |
| 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_session.h" | 5 #include "net/quic/quic_session.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "net/quic/crypto/proof_verifier.h" | 8 #include "net/quic/crypto/proof_verifier.h" |
| 9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_headers_stream.h" | 10 #include "net/quic/quic_headers_stream.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } | 313 } |
| 314 | 314 |
| 315 void QuicSession::SendRstStream(QuicStreamId id, | 315 void QuicSession::SendRstStream(QuicStreamId id, |
| 316 QuicRstStreamErrorCode error, | 316 QuicRstStreamErrorCode error, |
| 317 QuicStreamOffset bytes_written) { | 317 QuicStreamOffset bytes_written) { |
| 318 connection_->SendRstStream(id, error, bytes_written); | 318 connection_->SendRstStream(id, error, bytes_written); |
| 319 CloseStreamInner(id, true); | 319 CloseStreamInner(id, true); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void QuicSession::SendGoAway(QuicErrorCode error_code, const string& reason) { | 322 void QuicSession::SendGoAway(QuicErrorCode error_code, const string& reason) { |
| 323 if (goaway_sent_) { |
| 324 return; |
| 325 } |
| 323 goaway_sent_ = true; | 326 goaway_sent_ = true; |
| 324 connection_->SendGoAway(error_code, largest_peer_created_stream_id_, reason); | 327 connection_->SendGoAway(error_code, largest_peer_created_stream_id_, reason); |
| 325 } | 328 } |
| 326 | 329 |
| 327 void QuicSession::CloseStream(QuicStreamId stream_id) { | 330 void QuicSession::CloseStream(QuicStreamId stream_id) { |
| 328 CloseStreamInner(stream_id, false); | 331 CloseStreamInner(stream_id, false); |
| 329 } | 332 } |
| 330 | 333 |
| 331 void QuicSession::CloseStreamInner(QuicStreamId stream_id, | 334 void QuicSession::CloseStreamInner(QuicStreamId stream_id, |
| 332 bool locally_reset) { | 335 bool locally_reset) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 453 } |
| 451 | 454 |
| 452 return GetIncomingDataStream(stream_id); | 455 return GetIncomingDataStream(stream_id); |
| 453 } | 456 } |
| 454 | 457 |
| 455 QuicDataStream* QuicSession::GetIncomingDataStream(QuicStreamId stream_id) { | 458 QuicDataStream* QuicSession::GetIncomingDataStream(QuicStreamId stream_id) { |
| 456 if (IsClosedStream(stream_id)) { | 459 if (IsClosedStream(stream_id)) { |
| 457 return NULL; | 460 return NULL; |
| 458 } | 461 } |
| 459 | 462 |
| 460 if (goaway_sent_) { | |
| 461 // We've already sent a GoAway | |
| 462 SendRstStream(stream_id, QUIC_STREAM_PEER_GOING_AWAY, 0); | |
| 463 return NULL; | |
| 464 } | |
| 465 | |
| 466 implicitly_created_streams_.erase(stream_id); | 463 implicitly_created_streams_.erase(stream_id); |
| 467 if (stream_id > largest_peer_created_stream_id_) { | 464 if (stream_id > largest_peer_created_stream_id_) { |
| 468 // TODO(rch) add unit test for this | 465 // TODO(rch) add unit test for this |
| 469 if (stream_id - largest_peer_created_stream_id_ > kMaxStreamIdDelta) { | 466 if (stream_id - largest_peer_created_stream_id_ > kMaxStreamIdDelta) { |
| 470 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); | 467 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); |
| 471 return NULL; | 468 return NULL; |
| 472 } | 469 } |
| 473 if (largest_peer_created_stream_id_ == 0) { | 470 if (largest_peer_created_stream_id_ == 0) { |
| 474 if (is_server()) { | 471 if (is_server()) { |
| 475 largest_peer_created_stream_id_= 3; | 472 largest_peer_created_stream_id_= 3; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 NOTIMPLEMENTED(); | 548 NOTIMPLEMENTED(); |
| 552 return false; | 549 return false; |
| 553 } | 550 } |
| 554 | 551 |
| 555 void QuicSession::PostProcessAfterData() { | 552 void QuicSession::PostProcessAfterData() { |
| 556 STLDeleteElements(&closed_streams_); | 553 STLDeleteElements(&closed_streams_); |
| 557 closed_streams_.clear(); | 554 closed_streams_.clear(); |
| 558 } | 555 } |
| 559 | 556 |
| 560 } // namespace net | 557 } // namespace net |
| OLD | NEW |