| 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/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "net/tools/quic/quic_time_wait_list_manager.h" | 26 #include "net/tools/quic/quic_time_wait_list_manager.h" |
| 27 #include "net/tools/quic/test_tools/mock_quic_time_wait_list_manager.h" | 27 #include "net/tools/quic/test_tools/mock_quic_time_wait_list_manager.h" |
| 28 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" | 28 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 31 |
| 32 using base::StringPiece; | 32 using base::StringPiece; |
| 33 using net::EpollServer; | 33 using net::EpollServer; |
| 34 using net::test::ConstructEncryptedPacket; | 34 using net::test::ConstructEncryptedPacket; |
| 35 using net::test::CryptoTestUtils; | 35 using net::test::CryptoTestUtils; |
| 36 using net::test::MockConnection; | 36 using net::test::MockQuicConnection; |
| 37 using net::test::MockConnectionHelper; | 37 using net::test::MockQuicConnectionHelper; |
| 38 using net::test::ValueRestore; | 38 using net::test::ValueRestore; |
| 39 using std::string; | 39 using std::string; |
| 40 using std::vector; | 40 using std::vector; |
| 41 using testing::DoAll; | 41 using testing::DoAll; |
| 42 using testing::InSequence; | 42 using testing::InSequence; |
| 43 using testing::Invoke; | 43 using testing::Invoke; |
| 44 using testing::WithoutArgs; | 44 using testing::WithoutArgs; |
| 45 using testing::_; | 45 using testing::_; |
| 46 | 46 |
| 47 namespace net { | 47 namespace net { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const IPEndPoint& client_address)); | 111 const IPEndPoint& client_address)); |
| 112 | 112 |
| 113 using QuicDispatcher::current_server_address; | 113 using QuicDispatcher::current_server_address; |
| 114 using QuicDispatcher::current_client_address; | 114 using QuicDispatcher::current_client_address; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 // A Connection class which unregisters the session from the dispatcher when | 117 // A Connection class which unregisters the session from the dispatcher when |
| 118 // sending connection close. | 118 // sending connection close. |
| 119 // It'd be slightly more realistic to do this from the Session but it would | 119 // It'd be slightly more realistic to do this from the Session but it would |
| 120 // involve a lot more mocking. | 120 // involve a lot more mocking. |
| 121 class MockServerConnection : public MockConnection { | 121 class MockServerConnection : public MockQuicConnection { |
| 122 public: | 122 public: |
| 123 MockServerConnection(QuicConnectionId connection_id, | 123 MockServerConnection(QuicConnectionId connection_id, |
| 124 MockConnectionHelper* helper, | 124 MockQuicConnectionHelper* helper, |
| 125 MockAlarmFactory* alarm_factory, | 125 MockAlarmFactory* alarm_factory, |
| 126 QuicDispatcher* dispatcher) | 126 QuicDispatcher* dispatcher) |
| 127 : MockConnection(connection_id, | 127 : MockQuicConnection(connection_id, |
| 128 helper, | 128 helper, |
| 129 alarm_factory, | 129 alarm_factory, |
| 130 Perspective::IS_SERVER), | 130 Perspective::IS_SERVER), |
| 131 dispatcher_(dispatcher) {} | 131 dispatcher_(dispatcher) {} |
| 132 | 132 |
| 133 void UnregisterOnConnectionClosed() { | 133 void UnregisterOnConnectionClosed() { |
| 134 LOG(ERROR) << "Unregistering " << connection_id(); | 134 LOG(ERROR) << "Unregistering " << connection_id(); |
| 135 dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR, | 135 dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR, |
| 136 "Unregistering."); | 136 "Unregistering."); |
| 137 } | 137 } |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 QuicDispatcher* dispatcher_; | 140 QuicDispatcher* dispatcher_; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 QuicServerSessionBase* CreateSession( | 143 QuicServerSessionBase* CreateSession( |
| 144 QuicDispatcher* dispatcher, | 144 QuicDispatcher* dispatcher, |
| 145 const QuicConfig& config, | 145 const QuicConfig& config, |
| 146 QuicConnectionId connection_id, | 146 QuicConnectionId connection_id, |
| 147 const IPEndPoint& client_address, | 147 const IPEndPoint& client_address, |
| 148 MockConnectionHelper* helper, | 148 MockQuicConnectionHelper* helper, |
| 149 MockAlarmFactory* alarm_factory, | 149 MockAlarmFactory* alarm_factory, |
| 150 const QuicCryptoServerConfig* crypto_config, | 150 const QuicCryptoServerConfig* crypto_config, |
| 151 QuicCompressedCertsCache* compressed_certs_cache, | 151 QuicCompressedCertsCache* compressed_certs_cache, |
| 152 TestQuicSpdyServerSession** session) { | 152 TestQuicSpdyServerSession** session) { |
| 153 MockServerConnection* connection = new MockServerConnection( | 153 MockServerConnection* connection = new MockServerConnection( |
| 154 connection_id, helper, alarm_factory, dispatcher); | 154 connection_id, helper, alarm_factory, dispatcher); |
| 155 *session = new TestQuicSpdyServerSession(config, connection, crypto_config, | 155 *session = new TestQuicSpdyServerSession(config, connection, crypto_config, |
| 156 compressed_certs_cache); | 156 compressed_certs_cache); |
| 157 connection->set_visitor(*session); | 157 connection->set_visitor(*session); |
| 158 ON_CALL(*connection, CloseConnection(_, _, _)) | 158 ON_CALL(*connection, CloseConnection(_, _, _)) |
| 159 .WillByDefault(WithoutArgs(Invoke( | 159 .WillByDefault(WithoutArgs(Invoke( |
| 160 connection, &MockServerConnection::UnregisterOnConnectionClosed))); | 160 connection, &MockServerConnection::UnregisterOnConnectionClosed))); |
| 161 EXPECT_CALL(*reinterpret_cast<MockConnection*>((*session)->connection()), | 161 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>((*session)->connection()), |
| 162 ProcessUdpPacket(_, client_address, _)); | 162 ProcessUdpPacket(_, client_address, _)); |
| 163 | 163 |
| 164 return *session; | 164 return *session; |
| 165 } | 165 } |
| 166 | 166 |
| 167 class QuicDispatcherTest : public ::testing::Test { | 167 class QuicDispatcherTest : public ::testing::Test { |
| 168 public: | 168 public: |
| 169 QuicDispatcherTest() | 169 QuicDispatcherTest() |
| 170 : helper_(&eps_, QuicAllocator::BUFFER_POOL), | 170 : helper_(&eps_, QuicAllocator::BUFFER_POOL), |
| 171 alarm_factory_(&eps_), | 171 alarm_factory_(&eps_), |
| 172 crypto_config_(QuicCryptoServerConfig::TESTING, | 172 crypto_config_(QuicCryptoServerConfig::TESTING, |
| 173 QuicRandom::GetInstance(), | 173 QuicRandom::GetInstance(), |
| 174 CryptoTestUtils::ProofSourceForTesting()), | 174 CryptoTestUtils::ProofSourceForTesting()), |
| 175 dispatcher_(config_, &crypto_config_, &eps_), | 175 dispatcher_(config_, &crypto_config_, &eps_), |
| 176 time_wait_list_manager_(nullptr), | 176 time_wait_list_manager_(nullptr), |
| 177 session1_(nullptr), | 177 session1_(nullptr), |
| 178 session2_(nullptr) { | 178 session2_(nullptr) { |
| 179 dispatcher_.InitializeWithWriter(new QuicDefaultPacketWriter(1)); | 179 dispatcher_.InitializeWithWriter(new QuicDefaultPacketWriter(1)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 ~QuicDispatcherTest() override {} | 182 ~QuicDispatcherTest() override {} |
| 183 | 183 |
| 184 MockConnection* connection1() { | 184 MockQuicConnection* connection1() { |
| 185 return reinterpret_cast<MockConnection*>(session1_->connection()); | 185 return reinterpret_cast<MockQuicConnection*>(session1_->connection()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 MockConnection* connection2() { | 188 MockQuicConnection* connection2() { |
| 189 return reinterpret_cast<MockConnection*>(session2_->connection()); | 189 return reinterpret_cast<MockQuicConnection*>(session2_->connection()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Process a packet with an 8 byte connection id, | 192 // Process a packet with an 8 byte connection id, |
| 193 // 6 byte packet number, default path id, and packet number 1, | 193 // 6 byte packet number, default path id, and packet number 1, |
| 194 // using the first supported version. | 194 // using the first supported version. |
| 195 void ProcessPacket(IPEndPoint client_address, | 195 void ProcessPacket(IPEndPoint client_address, |
| 196 QuicConnectionId connection_id, | 196 QuicConnectionId connection_id, |
| 197 bool has_version_flag, | 197 bool has_version_flag, |
| 198 bool has_multipath_flag, | 198 bool has_multipath_flag, |
| 199 const string& data) { | 199 const string& data) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 time_wait_list_manager_ = | 261 time_wait_list_manager_ = |
| 262 new MockTimeWaitListManager(QuicDispatcherPeer::GetWriter(&dispatcher_), | 262 new MockTimeWaitListManager(QuicDispatcherPeer::GetWriter(&dispatcher_), |
| 263 &dispatcher_, &helper_, &alarm_factory_); | 263 &dispatcher_, &helper_, &alarm_factory_); |
| 264 // dispatcher_ takes the ownership of time_wait_list_manager_. | 264 // dispatcher_ takes the ownership of time_wait_list_manager_. |
| 265 QuicDispatcherPeer::SetTimeWaitListManager(&dispatcher_, | 265 QuicDispatcherPeer::SetTimeWaitListManager(&dispatcher_, |
| 266 time_wait_list_manager_); | 266 time_wait_list_manager_); |
| 267 } | 267 } |
| 268 | 268 |
| 269 EpollServer eps_; | 269 EpollServer eps_; |
| 270 QuicEpollConnectionHelper helper_; | 270 QuicEpollConnectionHelper helper_; |
| 271 MockConnectionHelper mock_helper_; | 271 MockQuicConnectionHelper mock_helper_; |
| 272 QuicEpollAlarmFactory alarm_factory_; | 272 QuicEpollAlarmFactory alarm_factory_; |
| 273 MockAlarmFactory mock_alarm_factory_; | 273 MockAlarmFactory mock_alarm_factory_; |
| 274 QuicConfig config_; | 274 QuicConfig config_; |
| 275 QuicCryptoServerConfig crypto_config_; | 275 QuicCryptoServerConfig crypto_config_; |
| 276 IPEndPoint server_address_; | 276 IPEndPoint server_address_; |
| 277 TestDispatcher dispatcher_; | 277 TestDispatcher dispatcher_; |
| 278 MockTimeWaitListManager* time_wait_list_manager_; | 278 MockTimeWaitListManager* time_wait_list_manager_; |
| 279 TestQuicSpdyServerSession* session1_; | 279 TestQuicSpdyServerSession* session1_; |
| 280 TestQuicSpdyServerSession* session2_; | 280 TestQuicSpdyServerSession* session2_; |
| 281 string data_; | 281 string data_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 294 EXPECT_EQ(client_address, dispatcher_.current_client_address()); | 294 EXPECT_EQ(client_address, dispatcher_.current_client_address()); |
| 295 EXPECT_EQ(server_address_, dispatcher_.current_server_address()); | 295 EXPECT_EQ(server_address_, dispatcher_.current_server_address()); |
| 296 | 296 |
| 297 EXPECT_CALL(dispatcher_, CreateQuicSession(2, client_address)) | 297 EXPECT_CALL(dispatcher_, CreateQuicSession(2, client_address)) |
| 298 .WillOnce(testing::Return(CreateSession( | 298 .WillOnce(testing::Return(CreateSession( |
| 299 &dispatcher_, config_, 2, client_address, &mock_helper_, | 299 &dispatcher_, config_, 2, client_address, &mock_helper_, |
| 300 &mock_alarm_factory_, &crypto_config_, | 300 &mock_alarm_factory_, &crypto_config_, |
| 301 QuicDispatcherPeer::GetCache(&dispatcher_), &session2_))); | 301 QuicDispatcherPeer::GetCache(&dispatcher_), &session2_))); |
| 302 ProcessPacket(client_address, 2, true, false, "bar"); | 302 ProcessPacket(client_address, 2, true, false, "bar"); |
| 303 | 303 |
| 304 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()), | 304 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 305 ProcessUdpPacket(_, _, _)) | 305 ProcessUdpPacket(_, _, _)) |
| 306 .Times(1) | 306 .Times(1) |
| 307 .WillOnce(testing::WithArgs<2>( | 307 .WillOnce(testing::WithArgs<2>( |
| 308 Invoke(this, &QuicDispatcherTest::ValidatePacket))); | 308 Invoke(this, &QuicDispatcherTest::ValidatePacket))); |
| 309 ProcessPacket(client_address, 1, false, false, "eep"); | 309 ProcessPacket(client_address, 1, false, false, "eep"); |
| 310 } | 310 } |
| 311 | 311 |
| 312 TEST_F(QuicDispatcherTest, StatelessVersionNegotiation) { | 312 TEST_F(QuicDispatcherTest, StatelessVersionNegotiation) { |
| 313 IPEndPoint client_address(net::test::Loopback4(), 1); | 313 IPEndPoint client_address(net::test::Loopback4(), 1); |
| 314 server_address_ = IPEndPoint(net::test::Any4(), 5); | 314 server_address_ = IPEndPoint(net::test::Any4(), 5); |
| 315 | 315 |
| 316 EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address)).Times(0); | 316 EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address)).Times(0); |
| 317 QuicVersion version = static_cast<QuicVersion>(QuicVersionMin() - 1); | 317 QuicVersion version = static_cast<QuicVersion>(QuicVersionMin() - 1); |
| 318 ProcessPacket(client_address, 1, true, version, "foo", | 318 ProcessPacket(client_address, 1, true, version, "foo", |
| 319 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1); | 319 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1); |
| 320 } | 320 } |
| 321 | 321 |
| 322 TEST_F(QuicDispatcherTest, Shutdown) { | 322 TEST_F(QuicDispatcherTest, Shutdown) { |
| 323 IPEndPoint client_address(net::test::Loopback4(), 1); | 323 IPEndPoint client_address(net::test::Loopback4(), 1); |
| 324 | 324 |
| 325 EXPECT_CALL(dispatcher_, CreateQuicSession(_, client_address)) | 325 EXPECT_CALL(dispatcher_, CreateQuicSession(_, client_address)) |
| 326 .WillOnce(testing::Return(CreateSession( | 326 .WillOnce(testing::Return(CreateSession( |
| 327 &dispatcher_, config_, 1, client_address, &mock_helper_, | 327 &dispatcher_, config_, 1, client_address, &mock_helper_, |
| 328 &mock_alarm_factory_, &crypto_config_, | 328 &mock_alarm_factory_, &crypto_config_, |
| 329 QuicDispatcherPeer::GetCache(&dispatcher_), &session1_))); | 329 QuicDispatcherPeer::GetCache(&dispatcher_), &session1_))); |
| 330 | 330 |
| 331 ProcessPacket(client_address, 1, true, false, "foo"); | 331 ProcessPacket(client_address, 1, true, false, "foo"); |
| 332 | 332 |
| 333 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()), | 333 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 334 CloseConnection(QUIC_PEER_GOING_AWAY, _, _)); | 334 CloseConnection(QUIC_PEER_GOING_AWAY, _, _)); |
| 335 | 335 |
| 336 dispatcher_.Shutdown(); | 336 dispatcher_.Shutdown(); |
| 337 } | 337 } |
| 338 | 338 |
| 339 TEST_F(QuicDispatcherTest, TimeWaitListManager) { | 339 TEST_F(QuicDispatcherTest, TimeWaitListManager) { |
| 340 CreateTimeWaitListManager(); | 340 CreateTimeWaitListManager(); |
| 341 | 341 |
| 342 // Create a new session. | 342 // Create a new session. |
| 343 IPEndPoint client_address(net::test::Loopback4(), 1); | 343 IPEndPoint client_address(net::test::Loopback4(), 1); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 359 std::unique_ptr<QuicEncryptedPacket> encrypted( | 359 std::unique_ptr<QuicEncryptedPacket> encrypted( |
| 360 QuicFramer::BuildPublicResetPacket(packet)); | 360 QuicFramer::BuildPublicResetPacket(packet)); |
| 361 std::unique_ptr<QuicReceivedPacket> received( | 361 std::unique_ptr<QuicReceivedPacket> received( |
| 362 ConstructReceivedPacket(*encrypted, helper_.GetClock()->Now())); | 362 ConstructReceivedPacket(*encrypted, helper_.GetClock()->Now())); |
| 363 EXPECT_CALL(*session1_, OnConnectionClosed(QUIC_PUBLIC_RESET, _, | 363 EXPECT_CALL(*session1_, OnConnectionClosed(QUIC_PUBLIC_RESET, _, |
| 364 ConnectionCloseSource::FROM_PEER)) | 364 ConnectionCloseSource::FROM_PEER)) |
| 365 .Times(1) | 365 .Times(1) |
| 366 .WillOnce(WithoutArgs(Invoke( | 366 .WillOnce(WithoutArgs(Invoke( |
| 367 reinterpret_cast<MockServerConnection*>(session1_->connection()), | 367 reinterpret_cast<MockServerConnection*>(session1_->connection()), |
| 368 &MockServerConnection::UnregisterOnConnectionClosed))); | 368 &MockServerConnection::UnregisterOnConnectionClosed))); |
| 369 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()), | 369 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 370 ProcessUdpPacket(_, _, _)) | 370 ProcessUdpPacket(_, _, _)) |
| 371 .WillOnce( | 371 .WillOnce( |
| 372 Invoke(reinterpret_cast<MockConnection*>(session1_->connection()), | 372 Invoke(reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 373 &MockConnection::ReallyProcessUdpPacket)); | 373 &MockQuicConnection::ReallyProcessUdpPacket)); |
| 374 dispatcher_.ProcessPacket(IPEndPoint(), client_address, *received); | 374 dispatcher_.ProcessPacket(IPEndPoint(), client_address, *received); |
| 375 EXPECT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); | 375 EXPECT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); |
| 376 | 376 |
| 377 // Dispatcher forwards subsequent packets for this connection_id to the time | 377 // Dispatcher forwards subsequent packets for this connection_id to the time |
| 378 // wait list manager. | 378 // wait list manager. |
| 379 EXPECT_CALL(*time_wait_list_manager_, | 379 EXPECT_CALL(*time_wait_list_manager_, |
| 380 ProcessPacket(_, _, connection_id, _, _)) | 380 ProcessPacket(_, _, connection_id, _, _)) |
| 381 .Times(1); | 381 .Times(1); |
| 382 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _)) | 382 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _)) |
| 383 .Times(0); | 383 .Times(0); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 // the existing connection_id will go on the time-wait list. | 595 // the existing connection_id will go on the time-wait list. |
| 596 EXPECT_EQ(ExpectStatelessReject(), | 596 EXPECT_EQ(ExpectStatelessReject(), |
| 597 time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); | 597 time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); |
| 598 if (ExpectStatelessReject()) { | 598 if (ExpectStatelessReject()) { |
| 599 // The second packet will be processed on the time-wait list. | 599 // The second packet will be processed on the time-wait list. |
| 600 EXPECT_CALL(*time_wait_list_manager_, | 600 EXPECT_CALL(*time_wait_list_manager_, |
| 601 ProcessPacket(_, _, connection_id, _, _)) | 601 ProcessPacket(_, _, connection_id, _, _)) |
| 602 .Times(1); | 602 .Times(1); |
| 603 } else { | 603 } else { |
| 604 // The second packet will trigger a packet-validation | 604 // The second packet will trigger a packet-validation |
| 605 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()), | 605 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 606 ProcessUdpPacket(_, _, _)) | 606 ProcessUdpPacket(_, _, _)) |
| 607 .Times(1) | 607 .Times(1) |
| 608 .WillOnce(testing::WithArgs<2>( | 608 .WillOnce(testing::WithArgs<2>( |
| 609 Invoke(this, &QuicDispatcherTest::ValidatePacket))); | 609 Invoke(this, &QuicDispatcherTest::ValidatePacket))); |
| 610 } | 610 } |
| 611 ProcessPacket(client_address, connection_id, true, false, "foo"); | 611 ProcessPacket(client_address, connection_id, true, false, "foo"); |
| 612 } | 612 } |
| 613 | 613 |
| 614 // Verify the stopgap test: Packets with truncated connection IDs should be | 614 // Verify the stopgap test: Packets with truncated connection IDs should be |
| 615 // dropped. | 615 // dropped. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 687 } |
| 688 | 688 |
| 689 void SetBlocked() { writer_->write_blocked_ = true; } | 689 void SetBlocked() { writer_->write_blocked_ = true; } |
| 690 | 690 |
| 691 void BlockConnection2() { | 691 void BlockConnection2() { |
| 692 writer_->write_blocked_ = true; | 692 writer_->write_blocked_ = true; |
| 693 dispatcher_.OnWriteBlocked(connection2()); | 693 dispatcher_.OnWriteBlocked(connection2()); |
| 694 } | 694 } |
| 695 | 695 |
| 696 protected: | 696 protected: |
| 697 MockConnectionHelper helper_; | 697 MockQuicConnectionHelper helper_; |
| 698 MockAlarmFactory alarm_factory_; | 698 MockAlarmFactory alarm_factory_; |
| 699 BlockingWriter* writer_; | 699 BlockingWriter* writer_; |
| 700 QuicDispatcher::WriteBlockedList* blocked_list_; | 700 QuicDispatcher::WriteBlockedList* blocked_list_; |
| 701 }; | 701 }; |
| 702 | 702 |
| 703 TEST_F(QuicDispatcherWriteBlockedListTest, BasicOnCanWrite) { | 703 TEST_F(QuicDispatcherWriteBlockedListTest, BasicOnCanWrite) { |
| 704 // No OnCanWrite calls because no connections are blocked. | 704 // No OnCanWrite calls because no connections are blocked. |
| 705 dispatcher_.OnCanWrite(); | 705 dispatcher_.OnCanWrite(); |
| 706 | 706 |
| 707 // Register connection 1 for events, and make sure it's notified. | 707 // Register connection 1 for events, and make sure it's notified. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 827 |
| 828 // And we'll resume where we left off when we get another call. | 828 // And we'll resume where we left off when we get another call. |
| 829 EXPECT_CALL(*connection2(), OnCanWrite()); | 829 EXPECT_CALL(*connection2(), OnCanWrite()); |
| 830 dispatcher_.OnCanWrite(); | 830 dispatcher_.OnCanWrite(); |
| 831 EXPECT_FALSE(dispatcher_.HasPendingWrites()); | 831 EXPECT_FALSE(dispatcher_.HasPendingWrites()); |
| 832 } | 832 } |
| 833 | 833 |
| 834 } // namespace | 834 } // namespace |
| 835 } // namespace test | 835 } // namespace test |
| 836 } // namespace net | 836 } // namespace net |
| OLD | NEW |