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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "net/base/tcp_client_socket_pool.h" 5 #include "net/base/tcp_client_socket_pool.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "net/base/client_socket.h" 9 #include "net/base/client_socket.h"
10 #include "net/base/client_socket_factory.h" 10 #include "net/base/client_socket_factory.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 reqs[kMaxSocketsPerGroup + i].get()) << 505 reqs[kMaxSocketsPerGroup + i].get()) <<
506 "Request " << kMaxSocketsPerGroup + i << " was not in order."; 506 "Request " << kMaxSocketsPerGroup + i << " was not in order.";
507 } 507 }
508 508
509 EXPECT_EQ(request_order_[arraysize(reqs) - 2], 509 EXPECT_EQ(request_order_[arraysize(reqs) - 2],
510 reqs[arraysize(reqs) - 1].get()) << 510 reqs[arraysize(reqs) - 1].get()) <<
511 "The last request with priority 1 should not have been inserted " 511 "The last request with priority 1 should not have been inserted "
512 "earlier into the queue."; 512 "earlier into the queue.";
513 } 513 }
514 514
515 class RequestSocketCallback : public CallbackRunner< Tuple1<int> > {
516 public:
517 RequestSocketCallback(ClientSocketHandle* handle)
518 : handle_(handle),
519 within_callback_(false) {}
520
521 virtual void RunWithParams(const Tuple1<int>& params) {
522 callback_.RunWithParams(params);
523 ASSERT_EQ(OK, params.a);
524
525 if (!within_callback_) {
526 handle_->Reset();
527 within_callback_ = true;
528 int rv = handle_->Init(
529 "a", HostResolver::RequestInfo("www.google.com", 80), 0, this);
530 EXPECT_EQ(OK, rv);
531 }
532 }
533
534 int WaitForResult() {
535 return callback_.WaitForResult();
536 }
537
538 private:
539 ClientSocketHandle* const handle_;
540 bool within_callback_;
541 TestCompletionCallback callback_;
542 };
543
544 TEST_F(TCPClientSocketPoolTest, RequestTwice) {
545 ClientSocketHandle handle(pool_.get());
546 RequestSocketCallback callback(&handle);
547 int rv = handle.Init(
548 "a", HostResolver::RequestInfo("www.google.com", 80), 0, &callback);
549 ASSERT_EQ(ERR_IO_PENDING, rv);
550
551 EXPECT_EQ(OK, callback.WaitForResult());
552
553 handle.Reset();
554 // The handle's Reset method may have posted a task.
555 MessageLoop::current()->RunAllPending();
556 }
557
515 } // namespace 558 } // namespace
516 559
517 } // namespace net 560 } // namespace net
OLDNEW
« 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