summaryrefslogtreecommitdiffstats
path: root/net/socket/socket_test_util.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 20:26:13 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 20:26:13 +0000
commit2431756ea7ceea7ac837522d948c3628cf83b647 (patch)
tree89e8921ce9f257f2dfeeb2491fb0ea246d4d1050 /net/socket/socket_test_util.cc
parent252c50a4cdb5a9506938b231f4bd19afd5365757 (diff)
downloadchromium_src-2431756ea7ceea7ac837522d948c3628cf83b647.zip
chromium_src-2431756ea7ceea7ac837522d948c3628cf83b647.tar.gz
chromium_src-2431756ea7ceea7ac837522d948c3628cf83b647.tar.bz2
Stop refcounting ClientSocketPool.
Establishes that HttpNetworkSession owns all the socket pools. Move out all the socket pools into a ClientSocketPoolManager. This is because of the dependency tree amongst socket pools, which dictates the order in which they must be constructed and destructed. In order to better establish it, I moved them out to their own class. HttpNetworkSession owns the ClientSocketPoolManager which owns the pools. We pass the pools as raw pointers everywhere. Note that ClientSocketPoolManager owns more pools than are publicly accessible via its interface. That's because some of them are wrapped by publicly exposed pools. Also, ClientSocketPoolHistograms used to be reference counted. That's because it can be shared by multiple ClientSocketPools. But it's effectively a global as well, so I make their lifetimes persist for the length of ClientSocketPoolManager too. I also removed internal refcounting in ClientSocketPoolBase. I had refcounted it before I knew about ScopedRunnableMethodFactory back when I first started. I cleaned up the unit tests a lot. Back when I was a young padawan, I didn't really know what I was doing, so I copy/pasted a metric asston of code. Turns out most of it was stupid, so I fixed it. I also stopped the use of implementation inheritance with ClientSocketPoolTest because it's discouraged by the style guide and more importantly because it caused the ClientSocketHandles within the TestSocketRequest vector to be destroyed _after_ the pools themselves were destroyed, which is bad since the handles will call pool_->Release() which blows up. BUG=56215,56215 TEST=Existing unit tests Review URL: http://codereview.chromium.org/3389020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/socket_test_util.cc')
-rw-r--r--net/socket/socket_test_util.cc40
1 files changed, 11 insertions, 29 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 785110d..0c181b6 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -1005,26 +1005,10 @@ const int ClientSocketPoolTest::kIndexOutOfBounds = -1;
// static
const int ClientSocketPoolTest::kRequestNotFound = -2;
-void ClientSocketPoolTest::SetUp() {
- completion_count_ = 0;
-}
-
-void ClientSocketPoolTest::TearDown() {
- // The tests often call Reset() on handles at the end which may post
- // DoReleaseSocket() tasks.
- // Pending tasks created by client_socket_pool_base_unittest.cc are
- // posted two milliseconds into the future and thus won't become
- // scheduled until that time.
- // We wait a few milliseconds to make sure that all such future tasks
- // are ready to run, before calling RunAllPending(). This will work
- // correctly even if Sleep() finishes late (and it should never finish
- // early), as all we have to ensure is that actual wall-time has progressed
- // past the scheduled starting time of the pending task.
- PlatformThread::Sleep(10);
- MessageLoop::current()->RunAllPending();
-}
-
-int ClientSocketPoolTest::GetOrderOfRequest(size_t index) {
+ClientSocketPoolTest::ClientSocketPoolTest() : completion_count_(0) {}
+ClientSocketPoolTest::~ClientSocketPoolTest() {}
+
+int ClientSocketPoolTest::GetOrderOfRequest(size_t index) const {
index--;
if (index >= requests_.size())
return kIndexOutOfBounds;
@@ -1108,7 +1092,7 @@ void MockTCPClientSocketPool::MockConnectJob::OnConnect(int rv) {
MockTCPClientSocketPool::MockTCPClientSocketPool(
int max_sockets,
int max_sockets_per_group,
- const scoped_refptr<ClientSocketPoolHistograms>& histograms,
+ ClientSocketPoolHistograms* histograms,
ClientSocketFactory* socket_factory)
: TCPClientSocketPool(max_sockets, max_sockets_per_group, histograms,
NULL, NULL, NULL),
@@ -1154,8 +1138,8 @@ MockTCPClientSocketPool::~MockTCPClientSocketPool() {}
MockSOCKSClientSocketPool::MockSOCKSClientSocketPool(
int max_sockets,
int max_sockets_per_group,
- const scoped_refptr<ClientSocketPoolHistograms>& histograms,
- const scoped_refptr<TCPClientSocketPool>& tcp_pool)
+ ClientSocketPoolHistograms* histograms,
+ TCPClientSocketPool* tcp_pool)
: SOCKSClientSocketPool(max_sockets, max_sockets_per_group, histograms,
NULL, tcp_pool, NULL),
tcp_pool_(tcp_pool) {
@@ -1201,14 +1185,12 @@ const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
MockSSLClientSocketPool::MockSSLClientSocketPool(
int max_sockets,
int max_sockets_per_group,
- const scoped_refptr<ClientSocketPoolHistograms>& histograms,
- ClientSocketFactory* socket_factory)
+ ClientSocketPoolHistograms* histograms,
+ ClientSocketFactory* socket_factory,
+ TCPClientSocketPool* tcp_pool)
: SSLClientSocketPool(max_sockets, max_sockets_per_group, histograms,
NULL, socket_factory,
- new MockTCPClientSocketPool(max_sockets,
- max_sockets_per_group,
- histograms,
- socket_factory),
+ tcp_pool,
NULL, NULL, NULL, NULL),
client_socket_factory_(socket_factory),
release_count_(0),