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 <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 const QuicPriority kHighestPriority = 0; | 48 const QuicPriority kHighestPriority = 0; |
49 const QuicPriority kSomeMiddlePriority = 3; | 49 const QuicPriority kSomeMiddlePriority = 3; |
50 | 50 |
51 class TestCryptoStream : public QuicCryptoStream { | 51 class TestCryptoStream : public QuicCryptoStream { |
52 public: | 52 public: |
53 explicit TestCryptoStream(QuicSession* session) | 53 explicit TestCryptoStream(QuicSession* session) |
54 : QuicCryptoStream(session) { | 54 : QuicCryptoStream(session) { |
55 } | 55 } |
56 | 56 |
57 virtual void OnHandshakeMessage( | 57 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override { |
58 const CryptoHandshakeMessage& message) override { | |
59 encryption_established_ = true; | 58 encryption_established_ = true; |
60 handshake_confirmed_ = true; | 59 handshake_confirmed_ = true; |
61 CryptoHandshakeMessage msg; | 60 CryptoHandshakeMessage msg; |
62 string error_details; | 61 string error_details; |
63 session()->config()->SetInitialFlowControlWindowToSend( | 62 session()->config()->SetInitialFlowControlWindowToSend( |
64 kInitialSessionFlowControlWindowForTest); | 63 kInitialSessionFlowControlWindowForTest); |
65 session()->config()->SetInitialStreamFlowControlWindowToSend( | 64 session()->config()->SetInitialStreamFlowControlWindowToSend( |
66 kInitialStreamFlowControlWindowForTest); | 65 kInitialStreamFlowControlWindowForTest); |
67 session()->config()->SetInitialSessionFlowControlWindowToSend( | 66 session()->config()->SetInitialSessionFlowControlWindowToSend( |
68 kInitialSessionFlowControlWindowForTest); | 67 kInitialSessionFlowControlWindowForTest); |
(...skipping 18 matching lines...) Expand all Loading... |
87 }; | 86 }; |
88 | 87 |
89 class TestStream : public QuicDataStream { | 88 class TestStream : public QuicDataStream { |
90 public: | 89 public: |
91 TestStream(QuicStreamId id, QuicSession* session) | 90 TestStream(QuicStreamId id, QuicSession* session) |
92 : QuicDataStream(id, session) { | 91 : QuicDataStream(id, session) { |
93 } | 92 } |
94 | 93 |
95 using ReliableQuicStream::CloseWriteSide; | 94 using ReliableQuicStream::CloseWriteSide; |
96 | 95 |
97 virtual uint32 ProcessData(const char* data, uint32 data_len) override { | 96 uint32 ProcessData(const char* data, uint32 data_len) override { |
98 return data_len; | 97 return data_len; |
99 } | 98 } |
100 | 99 |
101 void SendBody(const string& data, bool fin) { | 100 void SendBody(const string& data, bool fin) { |
102 WriteOrBufferData(data, fin, nullptr); | 101 WriteOrBufferData(data, fin, nullptr); |
103 } | 102 } |
104 | 103 |
105 MOCK_METHOD0(OnCanWrite, void()); | 104 MOCK_METHOD0(OnCanWrite, void()); |
106 }; | 105 }; |
107 | 106 |
(...skipping 16 matching lines...) Expand all Loading... |
124 | 123 |
125 class TestSession : public QuicSession { | 124 class TestSession : public QuicSession { |
126 public: | 125 public: |
127 explicit TestSession(QuicConnection* connection) | 126 explicit TestSession(QuicConnection* connection) |
128 : QuicSession(connection, DefaultQuicConfig()), | 127 : QuicSession(connection, DefaultQuicConfig()), |
129 crypto_stream_(this), | 128 crypto_stream_(this), |
130 writev_consumes_all_data_(false) { | 129 writev_consumes_all_data_(false) { |
131 InitializeSession(); | 130 InitializeSession(); |
132 } | 131 } |
133 | 132 |
134 virtual TestCryptoStream* GetCryptoStream() override { | 133 TestCryptoStream* GetCryptoStream() override { return &crypto_stream_; } |
135 return &crypto_stream_; | |
136 } | |
137 | 134 |
138 virtual TestStream* CreateOutgoingDataStream() override { | 135 TestStream* CreateOutgoingDataStream() override { |
139 TestStream* stream = new TestStream(GetNextStreamId(), this); | 136 TestStream* stream = new TestStream(GetNextStreamId(), this); |
140 ActivateStream(stream); | 137 ActivateStream(stream); |
141 return stream; | 138 return stream; |
142 } | 139 } |
143 | 140 |
144 virtual TestStream* CreateIncomingDataStream(QuicStreamId id) override { | 141 TestStream* CreateIncomingDataStream(QuicStreamId id) override { |
145 return new TestStream(id, this); | 142 return new TestStream(id, this); |
146 } | 143 } |
147 | 144 |
148 bool IsClosedStream(QuicStreamId id) { | 145 bool IsClosedStream(QuicStreamId id) { |
149 return QuicSession::IsClosedStream(id); | 146 return QuicSession::IsClosedStream(id); |
150 } | 147 } |
151 | 148 |
152 QuicDataStream* GetIncomingDataStream(QuicStreamId stream_id) { | 149 QuicDataStream* GetIncomingDataStream(QuicStreamId stream_id) { |
153 return QuicSession::GetIncomingDataStream(stream_id); | 150 return QuicSession::GetIncomingDataStream(stream_id); |
154 } | 151 } |
155 | 152 |
156 virtual QuicConsumedData WritevData( | 153 QuicConsumedData WritevData( |
157 QuicStreamId id, | 154 QuicStreamId id, |
158 const IOVector& data, | 155 const IOVector& data, |
159 QuicStreamOffset offset, | 156 QuicStreamOffset offset, |
160 bool fin, | 157 bool fin, |
161 FecProtection fec_protection, | 158 FecProtection fec_protection, |
162 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) override { | 159 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) override { |
163 // Always consumes everything. | 160 // Always consumes everything. |
164 if (writev_consumes_all_data_) { | 161 if (writev_consumes_all_data_) { |
165 return QuicConsumedData(data.TotalBufferSize(), fin); | 162 return QuicConsumedData(data.TotalBufferSize(), fin); |
166 } else { | 163 } else { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 "SICAID=AJKiYcHdKgxum7KMXG0ei2t1-W4OD1uW-ecNsCqC0wDuAXiDGIcT_HA2o1" | 213 "SICAID=AJKiYcHdKgxum7KMXG0ei2t1-W4OD1u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vBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" | 221 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" |
225 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; | 222 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; |
| 223 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
226 } | 224 } |
227 | 225 |
228 void CheckClosedStreams() { | 226 void CheckClosedStreams() { |
229 for (int i = kCryptoStreamId; i < 100; i++) { | 227 for (int i = kCryptoStreamId; i < 100; i++) { |
230 if (!ContainsKey(closed_streams_, i)) { | 228 if (!ContainsKey(closed_streams_, i)) { |
231 EXPECT_FALSE(session_.IsClosedStream(i)) << " stream id: " << i; | 229 EXPECT_FALSE(session_.IsClosedStream(i)) << " stream id: " << i; |
232 } else { | 230 } else { |
233 EXPECT_TRUE(session_.IsClosedStream(i)) << " stream id: " << i; | 231 EXPECT_TRUE(session_.IsClosedStream(i)) << " stream id: " << i; |
234 } | 232 } |
235 } | 233 } |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 } | 1014 } |
1017 | 1015 |
1018 // Called after any new data is received by the session, and triggers the call | 1016 // Called after any new data is received by the session, and triggers the call |
1019 // to close the connection. | 1017 // to close the connection. |
1020 session_.PostProcessAfterData(); | 1018 session_.PostProcessAfterData(); |
1021 } | 1019 } |
1022 | 1020 |
1023 } // namespace | 1021 } // namespace |
1024 } // namespace test | 1022 } // namespace test |
1025 } // namespace net | 1023 } // namespace net |
OLD | NEW |