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 <stddef.h> | 5 #include <stddef.h> |
6 #include <sys/epoll.h> | 6 #include <sys/epoll.h> |
7 | 7 |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <list> | 9 #include <list> |
10 #include <memory> | 10 #include <memory> |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 private: | 253 private: |
254 QuicDispatcher* dispatcher_; | 254 QuicDispatcher* dispatcher_; |
255 }; | 255 }; |
256 | 256 |
257 class ClientDelegate : public PacketDroppingTestWriter::Delegate { | 257 class ClientDelegate : public PacketDroppingTestWriter::Delegate { |
258 public: | 258 public: |
259 explicit ClientDelegate(QuicClient* client) : client_(client) {} | 259 explicit ClientDelegate(QuicClient* client) : client_(client) {} |
260 ~ClientDelegate() override {} | 260 ~ClientDelegate() override {} |
261 void OnCanWrite() override { | 261 void OnCanWrite() override { |
262 EpollEvent event(EPOLLOUT, false); | 262 EpollEvent event(EPOLLOUT); |
263 client_->OnEvent(client_->GetLatestFD(), &event); | 263 client_->OnEvent(client_->GetLatestFD(), &event); |
264 } | 264 } |
265 | 265 |
266 private: | 266 private: |
267 QuicClient* client_; | 267 QuicClient* client_; |
268 }; | 268 }; |
269 | 269 |
270 class EndToEndTest : public ::testing::TestWithParam<TestParams> { | 270 class EndToEndTest : public ::testing::TestWithParam<TestParams> { |
271 protected: | 271 protected: |
272 EndToEndTest() | 272 EndToEndTest() |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 if (GetParam().force_hol_blocking) { | 393 if (GetParam().force_hol_blocking) { |
394 client_config_.SetForceHolBlocking(); | 394 client_config_.SetForceHolBlocking(); |
395 } | 395 } |
396 client_config_.SetConnectionOptionsToSend(copt); | 396 client_config_.SetConnectionOptionsToSend(copt); |
397 | 397 |
398 // Start the server first, because CreateQuicClient() attempts | 398 // Start the server first, because CreateQuicClient() attempts |
399 // to connect to the server. | 399 // to connect to the server. |
400 StartServer(); | 400 StartServer(); |
401 | 401 |
402 CreateClientWithWriter(); | 402 CreateClientWithWriter(); |
403 static EpollEvent event(EPOLLOUT, false); | 403 static EpollEvent event(EPOLLOUT); |
404 if (client_writer_ != nullptr) { | 404 if (client_writer_ != nullptr) { |
405 client_writer_->Initialize( | 405 client_writer_->Initialize( |
406 QuicConnectionPeer::GetHelper( | 406 QuicConnectionPeer::GetHelper( |
407 client_->client()->session()->connection()), | 407 client_->client()->session()->connection()), |
408 QuicConnectionPeer::GetAlarmFactory( | 408 QuicConnectionPeer::GetAlarmFactory( |
409 client_->client()->session()->connection()), | 409 client_->client()->session()->connection()), |
410 new ClientDelegate(client_->client())); | 410 new ClientDelegate(client_->client())); |
411 } | 411 } |
412 initialized_ = true; | 412 initialized_ = true; |
413 return client_->client()->connected(); | 413 return client_->client()->connected(); |
(...skipping 2444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 | 2858 |
2859 StartServer(); | 2859 StartServer(); |
2860 | 2860 |
2861 // Use a quic client that drops received body. | 2861 // Use a quic client that drops received body. |
2862 QuicTestClient* client = new QuicTestClientThatDropsBody( | 2862 QuicTestClient* client = new QuicTestClientThatDropsBody( |
2863 server_address_, server_hostname_, client_config_, | 2863 server_address_, server_hostname_, client_config_, |
2864 client_supported_versions_); | 2864 client_supported_versions_); |
2865 client->UseWriter(client_writer_); | 2865 client->UseWriter(client_writer_); |
2866 client->Connect(); | 2866 client->Connect(); |
2867 client_.reset(client); | 2867 client_.reset(client); |
2868 static EpollEvent event(EPOLLOUT, false); | 2868 static EpollEvent event(EPOLLOUT); |
2869 client_writer_->Initialize( | 2869 client_writer_->Initialize( |
2870 QuicConnectionPeer::GetHelper(client_->client()->session()->connection()), | 2870 QuicConnectionPeer::GetHelper(client_->client()->session()->connection()), |
2871 QuicConnectionPeer::GetAlarmFactory( | 2871 QuicConnectionPeer::GetAlarmFactory( |
2872 client_->client()->session()->connection()), | 2872 client_->client()->session()->connection()), |
2873 new ClientDelegate(client_->client())); | 2873 new ClientDelegate(client_->client())); |
2874 initialized_ = true; | 2874 initialized_ = true; |
2875 ASSERT_TRUE(client_->client()->connected()); | 2875 ASSERT_TRUE(client_->client()->connected()); |
2876 | 2876 |
2877 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); | 2877 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); |
2878 SetPacketLossPercentage(1); | 2878 SetPacketLossPercentage(1); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2943 client_->WaitForResponse(); | 2943 client_->WaitForResponse(); |
2944 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 2944 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
2945 QuicConnectionStats client_stats = | 2945 QuicConnectionStats client_stats = |
2946 client_->client()->session()->connection()->GetStats(); | 2946 client_->client()->session()->connection()->GetStats(); |
2947 EXPECT_EQ(0u, client_stats.packets_lost); | 2947 EXPECT_EQ(0u, client_stats.packets_lost); |
2948 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 2948 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
2949 } | 2949 } |
2950 } // namespace | 2950 } // namespace |
2951 } // namespace test | 2951 } // namespace test |
2952 } // namespace net | 2952 } // namespace net |
OLD | NEW |