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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 : QuicDataStream(id, session) { | 89 : QuicDataStream(id, session) { |
90 } | 90 } |
91 | 91 |
92 using ReliableQuicStream::CloseWriteSide; | 92 using ReliableQuicStream::CloseWriteSide; |
93 | 93 |
94 virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE { | 94 virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE { |
95 return data_len; | 95 return data_len; |
96 } | 96 } |
97 | 97 |
98 void SendBody(const string& data, bool fin) { | 98 void SendBody(const string& data, bool fin) { |
99 WriteOrBufferData(data, fin, NULL); | 99 WriteOrBufferData(data, fin, nullptr); |
100 } | 100 } |
101 | 101 |
102 MOCK_METHOD0(OnCanWrite, void()); | 102 MOCK_METHOD0(OnCanWrite, void()); |
103 }; | 103 }; |
104 | 104 |
105 // Poor man's functor for use as callback in a mock. | 105 // Poor man's functor for use as callback in a mock. |
106 class StreamBlocker { | 106 class StreamBlocker { |
107 public: | 107 public: |
108 StreamBlocker(QuicSession* session, QuicStreamId stream_id) | 108 StreamBlocker(QuicSession* session, QuicStreamId stream_id) |
109 : session_(session), | 109 : session_(session), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return QuicSession::WritevData(id, data, offset, fin, fec_protection, | 165 return QuicSession::WritevData(id, data, offset, fin, fec_protection, |
166 ack_notifier_delegate); | 166 ack_notifier_delegate); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 void set_writev_consumes_all_data(bool val) { | 170 void set_writev_consumes_all_data(bool val) { |
171 writev_consumes_all_data_ = val; | 171 writev_consumes_all_data_ = val; |
172 } | 172 } |
173 | 173 |
174 QuicConsumedData SendStreamData(QuicStreamId id) { | 174 QuicConsumedData SendStreamData(QuicStreamId id) { |
175 return WritevData(id, IOVector(), 0, true, MAY_FEC_PROTECT, NULL); | 175 return WritevData(id, IOVector(), 0, true, MAY_FEC_PROTECT, nullptr); |
176 } | 176 } |
177 | 177 |
178 using QuicSession::PostProcessAfterData; | 178 using QuicSession::PostProcessAfterData; |
179 | 179 |
180 private: | 180 private: |
181 StrictMock<TestCryptoStream> crypto_stream_; | 181 StrictMock<TestCryptoStream> crypto_stream_; |
182 | 182 |
183 bool writev_consumes_all_data_; | 183 bool writev_consumes_all_data_; |
184 }; | 184 }; |
185 | 185 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 261 } |
262 | 262 |
263 TEST_P(QuicSessionTest, IsClosedStreamDefault) { | 263 TEST_P(QuicSessionTest, IsClosedStreamDefault) { |
264 // Ensure that no streams are initially closed. | 264 // Ensure that no streams are initially closed. |
265 for (int i = kCryptoStreamId; i < 100; i++) { | 265 for (int i = kCryptoStreamId; i < 100; i++) { |
266 EXPECT_FALSE(session_.IsClosedStream(i)) << "stream id: " << i; | 266 EXPECT_FALSE(session_.IsClosedStream(i)) << "stream id: " << i; |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 TEST_P(QuicSessionTest, ImplicitlyCreatedStreams) { | 270 TEST_P(QuicSessionTest, ImplicitlyCreatedStreams) { |
271 ASSERT_TRUE(session_.GetIncomingDataStream(7) != NULL); | 271 ASSERT_TRUE(session_.GetIncomingDataStream(7) != nullptr); |
272 // Both 3 and 5 should be implicitly created. | 272 // Both 3 and 5 should be implicitly created. |
273 EXPECT_FALSE(session_.IsClosedStream(3)); | 273 EXPECT_FALSE(session_.IsClosedStream(3)); |
274 EXPECT_FALSE(session_.IsClosedStream(5)); | 274 EXPECT_FALSE(session_.IsClosedStream(5)); |
275 ASSERT_TRUE(session_.GetIncomingDataStream(5) != NULL); | 275 ASSERT_TRUE(session_.GetIncomingDataStream(5) != nullptr); |
276 ASSERT_TRUE(session_.GetIncomingDataStream(3) != NULL); | 276 ASSERT_TRUE(session_.GetIncomingDataStream(3) != nullptr); |
277 } | 277 } |
278 | 278 |
279 TEST_P(QuicSessionTest, IsClosedStreamLocallyCreated) { | 279 TEST_P(QuicSessionTest, IsClosedStreamLocallyCreated) { |
280 TestStream* stream2 = session_.CreateOutgoingDataStream(); | 280 TestStream* stream2 = session_.CreateOutgoingDataStream(); |
281 EXPECT_EQ(2u, stream2->id()); | 281 EXPECT_EQ(2u, stream2->id()); |
282 TestStream* stream4 = session_.CreateOutgoingDataStream(); | 282 TestStream* stream4 = session_.CreateOutgoingDataStream(); |
283 EXPECT_EQ(4u, stream4->id()); | 283 EXPECT_EQ(4u, stream4->id()); |
284 | 284 |
285 CheckClosedStreams(); | 285 CheckClosedStreams(); |
286 CloseStream(4); | 286 CloseStream(4); |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 } | 945 } |
946 | 946 |
947 // Called after any new data is received by the session, and triggers the call | 947 // Called after any new data is received by the session, and triggers the call |
948 // to close the connection. | 948 // to close the connection. |
949 session_.PostProcessAfterData(); | 949 session_.PostProcessAfterData(); |
950 } | 950 } |
951 | 951 |
952 } // namespace | 952 } // namespace |
953 } // namespace test | 953 } // namespace test |
954 } // namespace net | 954 } // namespace net |
OLD | NEW |