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

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

Issue 1027693004: Delete the ClientSocketPoolHistograms class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small xml fix Created 5 years, 9 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/socket/client_socket_pool_base.h ('k') | net/socket/client_socket_pool_histograms.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 10 matching lines...) Expand all
21 #include "net/base/load_timing_info.h" 21 #include "net/base/load_timing_info.h"
22 #include "net/base/load_timing_info_test_util.h" 22 #include "net/base/load_timing_info_test_util.h"
23 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/base/net_log.h" 24 #include "net/base/net_log.h"
25 #include "net/base/net_log_unittest.h" 25 #include "net/base/net_log_unittest.h"
26 #include "net/base/request_priority.h" 26 #include "net/base/request_priority.h"
27 #include "net/base/test_completion_callback.h" 27 #include "net/base/test_completion_callback.h"
28 #include "net/http/http_response_headers.h" 28 #include "net/http/http_response_headers.h"
29 #include "net/socket/client_socket_factory.h" 29 #include "net/socket/client_socket_factory.h"
30 #include "net/socket/client_socket_handle.h" 30 #include "net/socket/client_socket_handle.h"
31 #include "net/socket/client_socket_pool_histograms.h"
32 #include "net/socket/socket_test_util.h" 31 #include "net/socket/socket_test_util.h"
33 #include "net/socket/ssl_client_socket.h" 32 #include "net/socket/ssl_client_socket.h"
34 #include "net/socket/stream_socket.h" 33 #include "net/socket/stream_socket.h"
35 #include "net/udp/datagram_client_socket.h" 34 #include "net/udp/datagram_client_socket.h"
36 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
37 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
38 37
39 using ::testing::Invoke; 38 using ::testing::Invoke;
40 using ::testing::Return; 39 using ::testing::Return;
41 40
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 DISALLOW_COPY_AND_ASSIGN(TestConnectJobFactory); 474 DISALLOW_COPY_AND_ASSIGN(TestConnectJobFactory);
476 }; 475 };
477 476
478 class TestClientSocketPool : public ClientSocketPool { 477 class TestClientSocketPool : public ClientSocketPool {
479 public: 478 public:
480 typedef TestSocketParams SocketParams; 479 typedef TestSocketParams SocketParams;
481 480
482 TestClientSocketPool( 481 TestClientSocketPool(
483 int max_sockets, 482 int max_sockets,
484 int max_sockets_per_group, 483 int max_sockets_per_group,
485 ClientSocketPoolHistograms* histograms,
486 base::TimeDelta unused_idle_socket_timeout, 484 base::TimeDelta unused_idle_socket_timeout,
487 base::TimeDelta used_idle_socket_timeout, 485 base::TimeDelta used_idle_socket_timeout,
488 TestClientSocketPoolBase::ConnectJobFactory* connect_job_factory) 486 TestClientSocketPoolBase::ConnectJobFactory* connect_job_factory)
489 : base_(NULL, max_sockets, max_sockets_per_group, histograms, 487 : base_(NULL,
490 unused_idle_socket_timeout, used_idle_socket_timeout, 488 max_sockets,
489 max_sockets_per_group,
490 unused_idle_socket_timeout,
491 used_idle_socket_timeout,
491 connect_job_factory) {} 492 connect_job_factory) {}
492 493
493 ~TestClientSocketPool() override {} 494 ~TestClientSocketPool() override {}
494 495
495 int RequestSocket(const std::string& group_name, 496 int RequestSocket(const std::string& group_name,
496 const void* params, 497 const void* params,
497 net::RequestPriority priority, 498 net::RequestPriority priority,
498 ClientSocketHandle* handle, 499 ClientSocketHandle* handle,
499 const CompletionCallback& callback, 500 const CompletionCallback& callback,
500 const BoundNetLog& net_log) override { 501 const BoundNetLog& net_log) override {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 const std::string& name, 555 const std::string& name,
555 const std::string& type, 556 const std::string& type,
556 bool include_nested_pools) const override { 557 bool include_nested_pools) const override {
557 return base_.GetInfoAsValue(name, type); 558 return base_.GetInfoAsValue(name, type);
558 } 559 }
559 560
560 base::TimeDelta ConnectionTimeout() const override { 561 base::TimeDelta ConnectionTimeout() const override {
561 return base_.ConnectionTimeout(); 562 return base_.ConnectionTimeout();
562 } 563 }
563 564
564 ClientSocketPoolHistograms* histograms() const override {
565 return base_.histograms();
566 }
567
568 const TestClientSocketPoolBase* base() const { return &base_; } 565 const TestClientSocketPoolBase* base() const { return &base_; }
569 566
570 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { 567 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const {
571 return base_.NumUnassignedConnectJobsInGroup(group_name); 568 return base_.NumUnassignedConnectJobsInGroup(group_name);
572 } 569 }
573 570
574 int NumConnectJobsInGroup(const std::string& group_name) const { 571 int NumConnectJobsInGroup(const std::string& group_name) const {
575 return base_.NumConnectJobsInGroup(group_name); 572 return base_.NumConnectJobsInGroup(group_name);
576 } 573 }
577 574
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 648
652 private: 649 private:
653 bool have_result_; 650 bool have_result_;
654 bool waiting_for_result_; 651 bool waiting_for_result_;
655 int result_; 652 int result_;
656 }; 653 };
657 654
658 class ClientSocketPoolBaseTest : public testing::Test { 655 class ClientSocketPoolBaseTest : public testing::Test {
659 protected: 656 protected:
660 ClientSocketPoolBaseTest() 657 ClientSocketPoolBaseTest()
661 : params_(new TestSocketParams(false /* ignore_limits */)), 658 : params_(new TestSocketParams(false /* ignore_limits */)) {
662 histograms_("ClientSocketPoolTest") {
663 connect_backup_jobs_enabled_ = 659 connect_backup_jobs_enabled_ =
664 internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled(); 660 internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled();
665 internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true); 661 internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true);
666 cleanup_timer_enabled_ = 662 cleanup_timer_enabled_ =
667 internal::ClientSocketPoolBaseHelper::cleanup_timer_enabled(); 663 internal::ClientSocketPoolBaseHelper::cleanup_timer_enabled();
668 } 664 }
669 665
670 ~ClientSocketPoolBaseTest() override { 666 ~ClientSocketPoolBaseTest() override {
671 internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( 667 internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
672 connect_backup_jobs_enabled_); 668 connect_backup_jobs_enabled_);
(...skipping 11 matching lines...) Expand all
684 680
685 void CreatePoolWithIdleTimeouts( 681 void CreatePoolWithIdleTimeouts(
686 int max_sockets, int max_sockets_per_group, 682 int max_sockets, int max_sockets_per_group,
687 base::TimeDelta unused_idle_socket_timeout, 683 base::TimeDelta unused_idle_socket_timeout,
688 base::TimeDelta used_idle_socket_timeout) { 684 base::TimeDelta used_idle_socket_timeout) {
689 DCHECK(!pool_.get()); 685 DCHECK(!pool_.get());
690 connect_job_factory_ = new TestConnectJobFactory(&client_socket_factory_, 686 connect_job_factory_ = new TestConnectJobFactory(&client_socket_factory_,
691 &net_log_); 687 &net_log_);
692 pool_.reset(new TestClientSocketPool(max_sockets, 688 pool_.reset(new TestClientSocketPool(max_sockets,
693 max_sockets_per_group, 689 max_sockets_per_group,
694 &histograms_,
695 unused_idle_socket_timeout, 690 unused_idle_socket_timeout,
696 used_idle_socket_timeout, 691 used_idle_socket_timeout,
697 connect_job_factory_)); 692 connect_job_factory_));
698 } 693 }
699 694
700 int StartRequestWithParams( 695 int StartRequestWithParams(
701 const std::string& group_name, 696 const std::string& group_name,
702 RequestPriority priority, 697 RequestPriority priority,
703 const scoped_refptr<TestSocketParams>& params) { 698 const scoped_refptr<TestSocketParams>& params) {
704 return test_base_.StartRequestUsingPool( 699 return test_base_.StartRequestUsingPool(
(...skipping 20 matching lines...) Expand all
725 size_t requests_size() const { return test_base_.requests_size(); } 720 size_t requests_size() const { return test_base_.requests_size(); }
726 ScopedVector<TestSocketRequest>* requests() { return test_base_.requests(); } 721 ScopedVector<TestSocketRequest>* requests() { return test_base_.requests(); }
727 size_t completion_count() const { return test_base_.completion_count(); } 722 size_t completion_count() const { return test_base_.completion_count(); }
728 723
729 CapturingNetLog net_log_; 724 CapturingNetLog net_log_;
730 bool connect_backup_jobs_enabled_; 725 bool connect_backup_jobs_enabled_;
731 bool cleanup_timer_enabled_; 726 bool cleanup_timer_enabled_;
732 MockClientSocketFactory client_socket_factory_; 727 MockClientSocketFactory client_socket_factory_;
733 TestConnectJobFactory* connect_job_factory_; 728 TestConnectJobFactory* connect_job_factory_;
734 scoped_refptr<TestSocketParams> params_; 729 scoped_refptr<TestSocketParams> params_;
735 ClientSocketPoolHistograms histograms_;
736 scoped_ptr<TestClientSocketPool> pool_; 730 scoped_ptr<TestClientSocketPool> pool_;
737 ClientSocketPoolTest test_base_; 731 ClientSocketPoolTest test_base_;
738 }; 732 };
739 733
740 // Even though a timeout is specified, it doesn't time out on a synchronous 734 // Even though a timeout is specified, it doesn't time out on a synchronous
741 // completion. 735 // completion.
742 TEST_F(ClientSocketPoolBaseTest, ConnectJob_NoTimeoutOnSynchronousCompletion) { 736 TEST_F(ClientSocketPoolBaseTest, ConnectJob_NoTimeoutOnSynchronousCompletion) {
743 TestConnectJobDelegate delegate; 737 TestConnectJobDelegate delegate;
744 ClientSocketHandle ignored; 738 ClientSocketHandle ignored;
745 TestClientSocketPoolBase::Request request( 739 TestClientSocketPoolBase::Request request(
(...skipping 3364 matching lines...) Expand 10 before | Expand all | Expand 10 after
4110 request(1)->handle()->Reset(); 4104 request(1)->handle()->Reset();
4111 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a")); 4105 ASSERT_EQ(1, pool_->NumConnectJobsInGroup("a"));
4112 4106
4113 EXPECT_EQ(OK, request(2)->WaitForResult()); 4107 EXPECT_EQ(OK, request(2)->WaitForResult());
4114 EXPECT_FALSE(request(1)->have_result()); 4108 EXPECT_FALSE(request(1)->have_result());
4115 } 4109 }
4116 4110
4117 } // namespace 4111 } // namespace
4118 4112
4119 } // namespace net 4113 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.h ('k') | net/socket/client_socket_pool_histograms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698