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/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "net/quic/core/quic_connection.h" | 10 #include "net/quic/core/quic_connection.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 flow_controller_(connection_, | 40 flow_controller_(connection_, |
41 0, | 41 0, |
42 perspective(), | 42 perspective(), |
43 kMinimumFlowControlSendWindow, | 43 kMinimumFlowControlSendWindow, |
44 config_.GetInitialSessionFlowControlWindowToSend(), | 44 config_.GetInitialSessionFlowControlWindowToSend(), |
45 perspective() == Perspective::IS_SERVER, | 45 perspective() == Perspective::IS_SERVER, |
46 nullptr), | 46 nullptr), |
47 currently_writing_stream_id_(0), | 47 currently_writing_stream_id_(0), |
48 respect_goaway_(true), | 48 respect_goaway_(true), |
49 use_stream_notifier_( | 49 use_stream_notifier_( |
50 FLAGS_quic_reloadable_flag_quic_use_stream_notifier2) {} | 50 FLAGS_quic_reloadable_flag_quic_use_stream_notifier2), |
| 51 streams_own_data_(use_stream_notifier_ && |
| 52 FLAGS_quic_reloadable_flag_quic_stream_owns_data) {} |
51 | 53 |
52 void QuicSession::Initialize() { | 54 void QuicSession::Initialize() { |
53 connection_->set_visitor(this); | 55 connection_->set_visitor(this); |
54 if (use_stream_notifier_) { | 56 if (use_stream_notifier_) { |
55 connection_->SetStreamNotifier(this); | 57 connection_->SetStreamNotifier(this); |
56 } | 58 } |
| 59 if (streams_own_data_) { |
| 60 connection_->SetDelegateSavesData(true); |
| 61 } |
57 connection_->SetFromConfig(config_); | 62 connection_->SetFromConfig(config_); |
58 | 63 |
59 DCHECK_EQ(kCryptoStreamId, GetMutableCryptoStream()->id()); | 64 DCHECK_EQ(kCryptoStreamId, GetMutableCryptoStream()->id()); |
60 static_stream_map_[kCryptoStreamId] = GetMutableCryptoStream(); | 65 static_stream_map_[kCryptoStreamId] = GetMutableCryptoStream(); |
61 } | 66 } |
62 | 67 |
63 QuicSession::~QuicSession() { | 68 QuicSession::~QuicSession() { |
64 QUIC_LOG_IF(WARNING, num_locally_closed_incoming_streams_highest_offset() > | 69 QUIC_LOG_IF(WARNING, num_locally_closed_incoming_streams_highest_offset() > |
65 max_open_incoming_streams_) | 70 max_open_incoming_streams_) |
66 << "Surprisingly high number of locally closed peer initiated streams" | 71 << "Surprisingly high number of locally closed peer initiated streams" |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 QUIC_BUG << "Stream: " << frame.stream_id << " is closed when " << frame | 1020 QUIC_BUG << "Stream: " << frame.stream_id << " is closed when " << frame |
1016 << " is discarded."; | 1021 << " is discarded."; |
1017 connection()->CloseConnection( | 1022 connection()->CloseConnection( |
1018 QUIC_INTERNAL_ERROR, "Attempt to discard frame of a closed stream", | 1023 QUIC_INTERNAL_ERROR, "Attempt to discard frame of a closed stream", |
1019 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1024 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
1020 return; | 1025 return; |
1021 } | 1026 } |
1022 stream->OnStreamFrameDiscarded(frame); | 1027 stream->OnStreamFrameDiscarded(frame); |
1023 } | 1028 } |
1024 | 1029 |
| 1030 void QuicSession::SaveStreamData(QuicStreamId id, |
| 1031 QuicIOVector iov, |
| 1032 size_t iov_offset, |
| 1033 QuicStreamOffset offset, |
| 1034 QuicByteCount data_length) { |
| 1035 QuicStream* stream = GetStream(id); |
| 1036 if (stream == nullptr) { |
| 1037 QUIC_BUG << "Stream " << id << " does not exist when trying to save data."; |
| 1038 connection()->CloseConnection( |
| 1039 QUIC_INTERNAL_ERROR, "Attempt to save data of a closed stream", |
| 1040 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1041 return; |
| 1042 } |
| 1043 stream->SaveStreamData(iov, iov_offset, offset, data_length); |
| 1044 } |
| 1045 |
| 1046 bool QuicSession::WriteStreamData(QuicStreamId id, |
| 1047 QuicStreamOffset offset, |
| 1048 QuicByteCount data_length, |
| 1049 QuicDataWriter* writer) { |
| 1050 QuicStream* stream = GetStream(id); |
| 1051 if (stream == nullptr) { |
| 1052 // This causes the connection to be closed because of failed to serialize |
| 1053 // packet. |
| 1054 QUIC_BUG << "Stream " << id << " does not exist when trying to write data."; |
| 1055 return false; |
| 1056 } |
| 1057 return stream->WriteStreamData(offset, data_length, writer); |
| 1058 } |
| 1059 |
1025 } // namespace net | 1060 } // namespace net |
OLD | NEW |