| 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 <string> | 6 #include <string> |
| 7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 void StopServer() { | 431 void StopServer() { |
| 432 if (!server_started_) | 432 if (!server_started_) |
| 433 return; | 433 return; |
| 434 if (server_thread_.get()) { | 434 if (server_thread_.get()) { |
| 435 server_thread_->Quit(); | 435 server_thread_->Quit(); |
| 436 server_thread_->Join(); | 436 server_thread_->Join(); |
| 437 } | 437 } |
| 438 } | 438 } |
| 439 | 439 |
| 440 void AddToCache(StringPiece path, int response_code, StringPiece body) { | 440 void AddToCache(StringPiece path, int response_code, StringPiece body) { |
| 441 QuicInMemoryCache::GetInstance()->AddSimpleResponse("www.google.com", path, | 441 QuicInMemoryCache::GetInstance()->AddSimpleResponse( |
| 442 response_code, body); | 442 "www.google.com", path, response_code, body); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void SetPacketLossPercentage(int32 loss) { | 445 void SetPacketLossPercentage(int32 loss) { |
| 446 // TODO(rtenneti): enable when we can do random packet loss tests in | 446 // TODO(rtenneti): enable when we can do random packet loss tests in |
| 447 // chrome's tree. | 447 // chrome's tree. |
| 448 if (loss != 0 && loss != 100) | 448 if (loss != 0 && loss != 100) |
| 449 return; | 449 return; |
| 450 client_writer_->set_fake_packet_loss_percentage(loss); | 450 client_writer_->set_fake_packet_loss_percentage(loss); |
| 451 server_writer_->set_fake_packet_loss_percentage(loss); | 451 server_writer_->set_fake_packet_loss_percentage(loss); |
| 452 } | 452 } |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 // TODO(jokulik): Until we support redundant SREJ packets, don't | 1372 // TODO(jokulik): Until we support redundant SREJ packets, don't |
| 1373 // drop handshake packets for stateless rejects. | 1373 // drop handshake packets for stateless rejects. |
| 1374 SetPacketLossPercentage(1); | 1374 SetPacketLossPercentage(1); |
| 1375 } | 1375 } |
| 1376 ASSERT_TRUE(Initialize()); | 1376 ASSERT_TRUE(Initialize()); |
| 1377 string large_body; | 1377 string large_body; |
| 1378 GenerateBody(&large_body, 10240); | 1378 GenerateBody(&large_body, 10240); |
| 1379 int max_streams = 100; | 1379 int max_streams = 100; |
| 1380 | 1380 |
| 1381 AddToCache("/large_response", 200, large_body); | 1381 AddToCache("/large_response", 200, large_body); |
| 1382 ; | |
| 1383 | 1382 |
| 1384 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1383 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 1385 SetPacketLossPercentage(10); | 1384 SetPacketLossPercentage(10); |
| 1386 | 1385 |
| 1387 for (int i = 0; i < max_streams; ++i) { | 1386 for (int i = 0; i < max_streams; ++i) { |
| 1388 EXPECT_LT(0, client_->SendRequest("/large_response")); | 1387 EXPECT_LT(0, client_->SendRequest("/large_response")); |
| 1389 } | 1388 } |
| 1390 | 1389 |
| 1391 // WaitForEvents waits 50ms and returns true if there are outstanding | 1390 // WaitForEvents waits 50ms and returns true if there are outstanding |
| 1392 // requests. | 1391 // requests. |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 // There will be buffered data to write in the client's stream. | 2133 // There will be buffered data to write in the client's stream. |
| 2135 ReliableQuicStream* stream = client_->client()->session()->GetStream(5); | 2134 ReliableQuicStream* stream = client_->client()->session()->GetStream(5); |
| 2136 EXPECT_TRUE(stream != nullptr && stream->HasBufferedData()); | 2135 EXPECT_TRUE(stream != nullptr && stream->HasBufferedData()); |
| 2137 } | 2136 } |
| 2138 } | 2137 } |
| 2139 | 2138 |
| 2140 } // namespace | 2139 } // namespace |
| 2141 } // namespace test | 2140 } // namespace test |
| 2142 } // namespace tools | 2141 } // namespace tools |
| 2143 } // namespace net | 2142 } // namespace net |
| OLD | NEW |