Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Unified Diff: net/socket/client_socket_pool_base_unittest.cc

Issue 1982263003: Remove Windows XP specific socket cleanup timer from net/socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/socket_descriptor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_pool_base_unittest.cc
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 446c8e35062f3c9d3d08bba54ecfcce0df1acb8b..5a9dd3d3f48dc903721a86415f288bef2238e6c8 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -664,15 +664,11 @@ class ClientSocketPoolBaseTest : public testing::Test {
connect_backup_jobs_enabled_ =
internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true);
- cleanup_timer_enabled_ =
- internal::ClientSocketPoolBaseHelper::cleanup_timer_enabled();
}
~ClientSocketPoolBaseTest() override {
internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
connect_backup_jobs_enabled_);
- internal::ClientSocketPoolBaseHelper::set_cleanup_timer_enabled(
- cleanup_timer_enabled_);
}
void CreatePool(int max_sockets, int max_sockets_per_group) {
@@ -731,7 +727,6 @@ class ClientSocketPoolBaseTest : public testing::Test {
TestNetLog net_log_;
bool connect_backup_jobs_enabled_;
- bool cleanup_timer_enabled_;
MockClientSocketFactory client_socket_factory_;
TestConnectJobFactory* connect_job_factory_;
scoped_refptr<TestSocketParams> params_;
@@ -2062,134 +2057,6 @@ TEST_F(ClientSocketPoolBaseTest, AdditionalErrorStateAsynchronous) {
EXPECT_FALSE(handle.ssl_error_response_info().headers.get() == NULL);
}
-// Make sure we can reuse sockets when the cleanup timer is disabled.
-TEST_F(ClientSocketPoolBaseTest, DisableCleanupTimerReuse) {
- // Disable cleanup timer.
- internal::ClientSocketPoolBaseHelper::set_cleanup_timer_enabled(false);
-
- CreatePoolWithIdleTimeouts(
- kDefaultMaxSockets, kDefaultMaxSocketsPerGroup,
- base::TimeDelta(), // Time out unused sockets immediately.
- base::TimeDelta::FromDays(1)); // Don't time out used sockets.
-
- connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
-
- ClientSocketHandle handle;
- TestCompletionCallback callback;
- int rv = handle.Init("a", params_, LOWEST,
- ClientSocketPool::RespectLimits::ENABLED,
- callback.callback(), pool_.get(), BoundNetLog());
- ASSERT_EQ(ERR_IO_PENDING, rv);
- EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle));
- ASSERT_EQ(OK, callback.WaitForResult());
-
- // Use and release the socket.
- EXPECT_EQ(1, handle.socket()->Write(NULL, 1, CompletionCallback()));
- TestLoadTimingInfoConnectedNotReused(handle);
- handle.Reset();
-
- // Should now have one idle socket.
- ASSERT_EQ(1, pool_->IdleSocketCount());
-
- // Request a new socket. This should reuse the old socket and complete
- // synchronously.
- BoundTestNetLog log;
- rv = handle.Init("a", params_, LOWEST,
- ClientSocketPool::RespectLimits::ENABLED,
- CompletionCallback(), pool_.get(), log.bound());
- ASSERT_EQ(OK, rv);
- EXPECT_TRUE(handle.is_reused());
- TestLoadTimingInfoConnectedReused(handle);
-
- ASSERT_TRUE(pool_->HasGroup("a"));
- EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
- EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a"));
-
- TestNetLogEntry::List entries;
- log.GetEntries(&entries);
- EXPECT_TRUE(LogContainsEntryWithType(
- entries, 1, NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET));
-}
-
-#if defined(OS_IOS)
-// TODO(droger): Enable this test (crbug.com/512595).
-#define MAYBE_DisableCleanupTimerNoReuse DISABLED_DisableCleanupTimerNoReuse
-#else
-#define MAYBE_DisableCleanupTimerNoReuse DisableCleanupTimerNoReuse
-#endif
-// Make sure we cleanup old unused sockets when the cleanup timer is disabled.
-TEST_F(ClientSocketPoolBaseTest, MAYBE_DisableCleanupTimerNoReuse) {
- // Disable cleanup timer.
- internal::ClientSocketPoolBaseHelper::set_cleanup_timer_enabled(false);
-
- CreatePoolWithIdleTimeouts(
- kDefaultMaxSockets, kDefaultMaxSocketsPerGroup,
- base::TimeDelta(), // Time out unused sockets immediately
- base::TimeDelta()); // Time out used sockets immediately
-
- connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
-
- // Startup two mock pending connect jobs, which will sit in the MessageLoop.
-
- ClientSocketHandle handle;
- TestCompletionCallback callback;
- int rv = handle.Init("a", params_, LOWEST,
- ClientSocketPool::RespectLimits::ENABLED,
- callback.callback(), pool_.get(), BoundNetLog());
- ASSERT_EQ(ERR_IO_PENDING, rv);
- EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle));
-
- ClientSocketHandle handle2;
- TestCompletionCallback callback2;
- rv = handle2.Init("a", params_, LOWEST,
- ClientSocketPool::RespectLimits::ENABLED,
- callback2.callback(), pool_.get(), BoundNetLog());
- ASSERT_EQ(ERR_IO_PENDING, rv);
- EXPECT_EQ(LOAD_STATE_CONNECTING, pool_->GetLoadState("a", &handle2));
-
- // Cancel one of the requests. Wait for the other, which will get the first
- // job. Release the socket. Run the loop again to make sure the second
- // socket is sitting idle and the first one is released (since ReleaseSocket()
- // just posts a DoReleaseSocket() task).
-
- handle.Reset();
- ASSERT_EQ(OK, callback2.WaitForResult());
- // Use the socket.
- EXPECT_EQ(1, handle2.socket()->Write(NULL, 1, CompletionCallback()));
- handle2.Reset();
-
- // We post all of our delayed tasks with a 2ms delay. I.e. they don't
- // actually become pending until 2ms after they have been created. In order
- // to flush all tasks, we need to wait so that we know there are no
- // soon-to-be-pending tasks waiting.
- base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
- base::MessageLoop::current()->RunUntilIdle();
-
- // Both sockets should now be idle.
- ASSERT_EQ(2, pool_->IdleSocketCount());
-
- // Request a new socket. This should cleanup the unused and timed out ones.
- // A new socket will be created rather than reusing the idle one.
- BoundTestNetLog log;
- TestCompletionCallback callback3;
- rv = handle.Init("a", params_, LOWEST,
- ClientSocketPool::RespectLimits::ENABLED,
- callback3.callback(), pool_.get(), log.bound());
- ASSERT_EQ(ERR_IO_PENDING, rv);
- ASSERT_EQ(OK, callback3.WaitForResult());
- EXPECT_FALSE(handle.is_reused());
-
- // Make sure the idle socket is closed.
- ASSERT_TRUE(pool_->HasGroup("a"));
- EXPECT_EQ(0, pool_->IdleSocketCountInGroup("a"));
- EXPECT_EQ(1, pool_->NumActiveSocketsInGroup("a"));
-
- TestNetLogEntry::List entries;
- log.GetEntries(&entries);
- EXPECT_FALSE(LogContainsEntryWithType(
- entries, 1, NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET));
-}
-
TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSockets) {
mmenke 2016/05/18 21:59:45 Think it makes more sense to remove this test, and
martijnc 2016/05/19 19:51:41 Done.
CreatePoolWithIdleTimeouts(
kDefaultMaxSockets, kDefaultMaxSocketsPerGroup,
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/socket_descriptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698