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

Unified Diff: net/base/tcp_client_socket_pool_unittest.cc

Issue 126168: Take 2. Make TCPClientSocketPool own the ConnectingSockets. (Closed)
Patch Set: Created 11 years, 6 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/base/tcp_client_socket_pool.cc ('k') | net/url_request/url_request_unittest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/tcp_client_socket_pool_unittest.cc
diff --git a/net/base/tcp_client_socket_pool_unittest.cc b/net/base/tcp_client_socket_pool_unittest.cc
index 2d19605118a5f9867c9567b176d66523d4f25c9f..53341904ede991fce488d9e27508cda64e11fe5e 100644
--- a/net/base/tcp_client_socket_pool_unittest.cc
+++ b/net/base/tcp_client_socket_pool_unittest.cc
@@ -512,6 +512,49 @@ TEST_F(TCPClientSocketPoolTest, CancelRequest) {
"earlier into the queue.";
}
+class RequestSocketCallback : public CallbackRunner< Tuple1<int> > {
+ public:
+ RequestSocketCallback(ClientSocketHandle* handle)
+ : handle_(handle),
+ within_callback_(false) {}
+
+ virtual void RunWithParams(const Tuple1<int>& params) {
+ callback_.RunWithParams(params);
+ ASSERT_EQ(OK, params.a);
+
+ if (!within_callback_) {
+ handle_->Reset();
+ within_callback_ = true;
+ int rv = handle_->Init(
+ "a", HostResolver::RequestInfo("www.google.com", 80), 0, this);
+ EXPECT_EQ(OK, rv);
+ }
+ }
+
+ int WaitForResult() {
+ return callback_.WaitForResult();
+ }
+
+ private:
+ ClientSocketHandle* const handle_;
+ bool within_callback_;
+ TestCompletionCallback callback_;
+};
+
+TEST_F(TCPClientSocketPoolTest, RequestTwice) {
+ ClientSocketHandle handle(pool_.get());
+ RequestSocketCallback callback(&handle);
+ int rv = handle.Init(
+ "a", HostResolver::RequestInfo("www.google.com", 80), 0, &callback);
+ ASSERT_EQ(ERR_IO_PENDING, rv);
+
+ EXPECT_EQ(OK, callback.WaitForResult());
+
+ handle.Reset();
+ // The handle's Reset method may have posted a task.
+ MessageLoop::current()->RunAllPending();
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/base/tcp_client_socket_pool.cc ('k') | net/url_request/url_request_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698