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

Side by Side Diff: net/socket/transport_client_socket_pool_unittest.cc

Issue 8572018: Remove referrer from TransportSocketParams and SOCKSSocketParams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/transport_client_socket_pool.cc ('k') | net/spdy/spdy_http_stream_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/socket/transport_client_socket_pool.h" 5 #include "net/socket/transport_client_socket_pool.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 int delay_ms_; 358 int delay_ms_;
359 }; 359 };
360 360
361 class TransportClientSocketPoolTest : public testing::Test { 361 class TransportClientSocketPoolTest : public testing::Test {
362 protected: 362 protected:
363 TransportClientSocketPoolTest() 363 TransportClientSocketPoolTest()
364 : connect_backup_jobs_enabled_( 364 : connect_backup_jobs_enabled_(
365 ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true)), 365 ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true)),
366 params_( 366 params_(
367 new TransportSocketParams(HostPortPair("www.google.com", 80), 367 new TransportSocketParams(HostPortPair("www.google.com", 80),
368 kDefaultPriority, GURL(), false, false)), 368 kDefaultPriority, false, false)),
369 low_params_( 369 low_params_(
370 new TransportSocketParams(HostPortPair("www.google.com", 80), 370 new TransportSocketParams(HostPortPair("www.google.com", 80),
371 LOW, GURL(), false, false)), 371 LOW, false, false)),
372 histograms_(new ClientSocketPoolHistograms("TCPUnitTest")), 372 histograms_(new ClientSocketPoolHistograms("TCPUnitTest")),
373 host_resolver_(new MockHostResolver), 373 host_resolver_(new MockHostResolver),
374 pool_(kMaxSockets, 374 pool_(kMaxSockets,
375 kMaxSocketsPerGroup, 375 kMaxSocketsPerGroup,
376 histograms_.get(), 376 histograms_.get(),
377 host_resolver_.get(), 377 host_resolver_.get(),
378 &client_socket_factory_, 378 &client_socket_factory_,
379 NULL) { 379 NULL) {
380 } 380 }
381 381
382 ~TransportClientSocketPoolTest() { 382 ~TransportClientSocketPoolTest() {
383 internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( 383 internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
384 connect_backup_jobs_enabled_); 384 connect_backup_jobs_enabled_);
385 } 385 }
386 386
387 int StartRequest(const std::string& group_name, RequestPriority priority) { 387 int StartRequest(const std::string& group_name, RequestPriority priority) {
388 scoped_refptr<TransportSocketParams> params(new TransportSocketParams( 388 scoped_refptr<TransportSocketParams> params(new TransportSocketParams(
389 HostPortPair("www.google.com", 80), MEDIUM, GURL(), false, false)); 389 HostPortPair("www.google.com", 80), MEDIUM, false, false));
390 return test_base_.StartRequestUsingPool( 390 return test_base_.StartRequestUsingPool(
391 &pool_, group_name, priority, params); 391 &pool_, group_name, priority, params);
392 } 392 }
393 393
394 int GetOrderOfRequest(size_t index) { 394 int GetOrderOfRequest(size_t index) {
395 return test_base_.GetOrderOfRequest(index); 395 return test_base_.GetOrderOfRequest(index);
396 } 396 }
397 397
398 bool ReleaseOneConnection(ClientSocketPoolTest::KeepAlive keep_alive) { 398 bool ReleaseOneConnection(ClientSocketPoolTest::KeepAlive keep_alive) {
399 return test_base_.ReleaseOneConnection(keep_alive); 399 return test_base_.ReleaseOneConnection(keep_alive);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 handle.Reset(); 514 handle.Reset();
515 } 515 }
516 516
517 TEST_F(TransportClientSocketPoolTest, InitHostResolutionFailure) { 517 TEST_F(TransportClientSocketPoolTest, InitHostResolutionFailure) {
518 host_resolver_->rules()->AddSimulatedFailure("unresolvable.host.name"); 518 host_resolver_->rules()->AddSimulatedFailure("unresolvable.host.name");
519 TestOldCompletionCallback callback; 519 TestOldCompletionCallback callback;
520 ClientSocketHandle handle; 520 ClientSocketHandle handle;
521 HostPortPair host_port_pair("unresolvable.host.name", 80); 521 HostPortPair host_port_pair("unresolvable.host.name", 80);
522 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( 522 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
523 host_port_pair, kDefaultPriority, GURL(), false, false)); 523 host_port_pair, kDefaultPriority, false, false));
524 EXPECT_EQ(ERR_IO_PENDING, 524 EXPECT_EQ(ERR_IO_PENDING,
525 handle.Init("a", dest, kDefaultPriority, &callback, &pool_, 525 handle.Init("a", dest, kDefaultPriority, &callback, &pool_,
526 BoundNetLog())); 526 BoundNetLog()));
527 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback.WaitForResult()); 527 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback.WaitForResult());
528 } 528 }
529 529
530 TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) { 530 TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) {
531 client_socket_factory_.set_client_socket_type( 531 client_socket_factory_.set_client_socket_type(
532 MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET); 532 MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET);
533 TestOldCompletionCallback callback; 533 TestOldCompletionCallback callback;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 // run through the MessageLoop once to get it completely released. 773 // run through the MessageLoop once to get it completely released.
774 handle_->socket()->Disconnect(); 774 handle_->socket()->Disconnect();
775 handle_->Reset(); 775 handle_->Reset();
776 { 776 {
777 MessageLoop::ScopedNestableTaskAllower nestable( 777 MessageLoop::ScopedNestableTaskAllower nestable(
778 MessageLoop::current()); 778 MessageLoop::current());
779 MessageLoop::current()->RunAllPending(); 779 MessageLoop::current()->RunAllPending();
780 } 780 }
781 within_callback_ = true; 781 within_callback_ = true;
782 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( 782 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
783 HostPortPair("www.google.com", 80), LOWEST, GURL(), false, false)); 783 HostPortPair("www.google.com", 80), LOWEST, false, false));
784 int rv = handle_->Init("a", dest, LOWEST, this, pool_, BoundNetLog()); 784 int rv = handle_->Init("a", dest, LOWEST, this, pool_, BoundNetLog());
785 EXPECT_EQ(OK, rv); 785 EXPECT_EQ(OK, rv);
786 } 786 }
787 } 787 }
788 788
789 int WaitForResult() { 789 int WaitForResult() {
790 return callback_.WaitForResult(); 790 return callback_.WaitForResult();
791 } 791 }
792 792
793 private: 793 private:
794 ClientSocketHandle* const handle_; 794 ClientSocketHandle* const handle_;
795 TransportClientSocketPool* const pool_; 795 TransportClientSocketPool* const pool_;
796 bool within_callback_; 796 bool within_callback_;
797 TestOldCompletionCallback callback_; 797 TestOldCompletionCallback callback_;
798 }; 798 };
799 799
800 TEST_F(TransportClientSocketPoolTest, RequestTwice) { 800 TEST_F(TransportClientSocketPoolTest, RequestTwice) {
801 ClientSocketHandle handle; 801 ClientSocketHandle handle;
802 RequestSocketCallback callback(&handle, &pool_); 802 RequestSocketCallback callback(&handle, &pool_);
803 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( 803 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
804 HostPortPair("www.google.com", 80), LOWEST, GURL(), false, false)); 804 HostPortPair("www.google.com", 80), LOWEST, false, false));
805 int rv = handle.Init("a", dest, LOWEST, &callback, &pool_, 805 int rv = handle.Init("a", dest, LOWEST, &callback, &pool_,
806 BoundNetLog()); 806 BoundNetLog());
807 ASSERT_EQ(ERR_IO_PENDING, rv); 807 ASSERT_EQ(ERR_IO_PENDING, rv);
808 808
809 // The callback is going to request "www.google.com". We want it to complete 809 // The callback is going to request "www.google.com". We want it to complete
810 // synchronously this time. 810 // synchronously this time.
811 host_resolver_->set_synchronous_mode(true); 811 host_resolver_->set_synchronous_mode(true);
812 812
813 EXPECT_EQ(OK, callback.WaitForResult()); 813 EXPECT_EQ(OK, callback.WaitForResult());
814 814
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 EXPECT_TRUE(handle.socket()); 1227 EXPECT_TRUE(handle.socket());
1228 IPEndPoint endpoint; 1228 IPEndPoint endpoint;
1229 handle.socket()->GetLocalAddress(&endpoint); 1229 handle.socket()->GetLocalAddress(&endpoint);
1230 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); 1230 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size());
1231 EXPECT_EQ(1, client_socket_factory_.allocation_count()); 1231 EXPECT_EQ(1, client_socket_factory_.allocation_count());
1232 } 1232 }
1233 1233
1234 } // namespace 1234 } // namespace
1235 1235
1236 } // namespace net 1236 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/transport_client_socket_pool.cc ('k') | net/spdy/spdy_http_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698