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

Side by Side Diff: net/socket/client_socket_pool_base.h

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed net tests compilation issues, Added tests Created 4 years, 10 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
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 // A ClientSocketPoolBase is used to restrict the number of sockets open at 5 // A ClientSocketPoolBase is used to restrict the number of sockets open at
6 // a time. It also maintains a list of idle persistent sockets for reuse. 6 // a time. It also maintains a list of idle persistent sockets for reuse.
7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle 7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle
8 // the core logic of (1) restricting the number of active (connected or 8 // the core logic of (1) restricting the number of active (connected or
9 // connecting) sockets per "group" (generally speaking, the hostname), (2) 9 // connecting) sockets per "group" (generally speaking, the hostname), (2)
10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) 10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "net/base/priority_queue.h" 49 #include "net/base/priority_queue.h"
50 #include "net/base/request_priority.h" 50 #include "net/base/request_priority.h"
51 #include "net/log/net_log.h" 51 #include "net/log/net_log.h"
52 #include "net/socket/client_socket_handle.h" 52 #include "net/socket/client_socket_handle.h"
53 #include "net/socket/client_socket_pool.h" 53 #include "net/socket/client_socket_pool.h"
54 #include "net/socket/stream_socket.h" 54 #include "net/socket/stream_socket.h"
55 55
56 namespace net { 56 namespace net {
57 57
58 class ClientSocketHandle; 58 class ClientSocketHandle;
59 class SocketPerformanceWatcherFactory;
59 60
60 // ConnectJob provides an abstract interface for "connecting" a socket. 61 // ConnectJob provides an abstract interface for "connecting" a socket.
61 // The connection may involve host resolution, tcp connection, ssl connection, 62 // The connection may involve host resolution, tcp connection, ssl connection,
62 // etc. 63 // etc.
63 class NET_EXPORT_PRIVATE ConnectJob { 64 class NET_EXPORT_PRIVATE ConnectJob {
64 public: 65 public:
65 class NET_EXPORT_PRIVATE Delegate { 66 class NET_EXPORT_PRIVATE Delegate {
66 public: 67 public:
67 Delegate() {} 68 Delegate() {}
68 virtual ~Delegate() {} 69 virtual ~Delegate() {}
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 ConnectJobFactory() {} 223 ConnectJobFactory() {}
223 virtual ~ConnectJobFactory() {} 224 virtual ~ConnectJobFactory() {}
224 225
225 virtual scoped_ptr<ConnectJob> NewConnectJob( 226 virtual scoped_ptr<ConnectJob> NewConnectJob(
226 const std::string& group_name, 227 const std::string& group_name,
227 const Request& request, 228 const Request& request,
228 ConnectJob::Delegate* delegate) const = 0; 229 ConnectJob::Delegate* delegate) const = 0;
229 230
230 virtual base::TimeDelta ConnectionTimeout() const = 0; 231 virtual base::TimeDelta ConnectionTimeout() const = 0;
231 232
233 virtual void SetSocketPerformanceWatcherFactory(
234 SocketPerformanceWatcherFactory*
235 socket_performance_watcher_factory) = 0;
236
232 private: 237 private:
233 DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory); 238 DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory);
234 }; 239 };
235 240
236 ClientSocketPoolBaseHelper( 241 ClientSocketPoolBaseHelper(
237 HigherLayeredPool* pool, 242 HigherLayeredPool* pool,
238 int max_sockets, 243 int max_sockets,
239 int max_sockets_per_group, 244 int max_sockets_per_group,
240 base::TimeDelta unused_idle_socket_timeout, 245 base::TimeDelta unused_idle_socket_timeout,
241 base::TimeDelta used_idle_socket_timeout, 246 base::TimeDelta used_idle_socket_timeout,
242 ConnectJobFactory* connect_job_factory); 247 ConnectJobFactory* connect_job_factory);
243 248
249 void SetSocketPerformanceWatcherFactory(
250 SocketPerformanceWatcherFactory* socket_performance_watcher_factory) {
251 connect_job_factory_->SetSocketPerformanceWatcherFactory(
252 socket_performance_watcher_factory);
253 }
254
244 ~ClientSocketPoolBaseHelper() override; 255 ~ClientSocketPoolBaseHelper() override;
245 256
246 // Adds a lower layered pool to |this|, and adds |this| as a higher layered 257 // Adds a lower layered pool to |this|, and adds |this| as a higher layered
247 // pool on top of |lower_pool|. 258 // pool on top of |lower_pool|.
248 void AddLowerLayeredPool(LowerLayeredPool* lower_pool); 259 void AddLowerLayeredPool(LowerLayeredPool* lower_pool);
249 260
250 // See LowerLayeredPool::IsStalled for documentation on this function. 261 // See LowerLayeredPool::IsStalled for documentation on this function.
251 bool IsStalled() const; 262 bool IsStalled() const;
252 263
253 // See LowerLayeredPool for documentation on these functions. It is expected 264 // See LowerLayeredPool for documentation on these functions. It is expected
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 ConnectJobFactory() {} 721 ConnectJobFactory() {}
711 virtual ~ConnectJobFactory() {} 722 virtual ~ConnectJobFactory() {}
712 723
713 virtual scoped_ptr<ConnectJob> NewConnectJob( 724 virtual scoped_ptr<ConnectJob> NewConnectJob(
714 const std::string& group_name, 725 const std::string& group_name,
715 const Request& request, 726 const Request& request,
716 ConnectJob::Delegate* delegate) const = 0; 727 ConnectJob::Delegate* delegate) const = 0;
717 728
718 virtual base::TimeDelta ConnectionTimeout() const = 0; 729 virtual base::TimeDelta ConnectionTimeout() const = 0;
719 730
731 virtual void SetSocketPerformanceWatcherFactory(
732 SocketPerformanceWatcherFactory* socket_performance_watcher_factory) {}
733
720 private: 734 private:
721 DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory); 735 DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory);
722 }; 736 };
723 737
724 // |max_sockets| is the maximum number of sockets to be maintained by this 738 // |max_sockets| is the maximum number of sockets to be maintained by this
725 // ClientSocketPool. |max_sockets_per_group| specifies the maximum number of 739 // ClientSocketPool. |max_sockets_per_group| specifies the maximum number of
726 // sockets a "group" can have. |unused_idle_socket_timeout| specifies how 740 // sockets a "group" can have. |unused_idle_socket_timeout| specifies how
727 // long to leave an unused idle socket open before closing it. 741 // long to leave an unused idle socket open before closing it.
728 // |used_idle_socket_timeout| specifies how long to leave a previously used 742 // |used_idle_socket_timeout| specifies how long to leave a previously used
729 // idle socket open before closing it. 743 // idle socket open before closing it.
730 ClientSocketPoolBase(HigherLayeredPool* self, 744 ClientSocketPoolBase(HigherLayeredPool* self,
731 int max_sockets, 745 int max_sockets,
732 int max_sockets_per_group, 746 int max_sockets_per_group,
733 base::TimeDelta unused_idle_socket_timeout, 747 base::TimeDelta unused_idle_socket_timeout,
734 base::TimeDelta used_idle_socket_timeout, 748 base::TimeDelta used_idle_socket_timeout,
735 ConnectJobFactory* connect_job_factory) 749 ConnectJobFactory* connect_job_factory)
736 : helper_(self, 750 : helper_(self,
737 max_sockets, 751 max_sockets,
738 max_sockets_per_group, 752 max_sockets_per_group,
739 unused_idle_socket_timeout, 753 unused_idle_socket_timeout,
740 used_idle_socket_timeout, 754 used_idle_socket_timeout,
741 new ConnectJobFactoryAdaptor(connect_job_factory)) {} 755 new ConnectJobFactoryAdaptor(connect_job_factory)) {}
742 756
757 void SetSocketPerformanceWatcherFactory(
758 SocketPerformanceWatcherFactory* socket_performance_watcher_factory) {
759 helper_.SetSocketPerformanceWatcherFactory(
760 socket_performance_watcher_factory);
761 }
762
743 virtual ~ClientSocketPoolBase() {} 763 virtual ~ClientSocketPoolBase() {}
744 764
745 // These member functions simply forward to ClientSocketPoolBaseHelper. 765 // These member functions simply forward to ClientSocketPoolBaseHelper.
746 void AddLowerLayeredPool(LowerLayeredPool* lower_pool) { 766 void AddLowerLayeredPool(LowerLayeredPool* lower_pool) {
747 helper_.AddLowerLayeredPool(lower_pool); 767 helper_.AddLowerLayeredPool(lower_pool);
748 } 768 }
749 769
750 void AddHigherLayeredPool(HigherLayeredPool* higher_pool) { 770 void AddHigherLayeredPool(HigherLayeredPool* higher_pool) {
751 helper_.AddHigherLayeredPool(higher_pool); 771 helper_.AddHigherLayeredPool(higher_pool);
752 } 772 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 ConnectJob::Delegate* delegate) const override { 895 ConnectJob::Delegate* delegate) const override {
876 const Request& casted_request = static_cast<const Request&>(request); 896 const Request& casted_request = static_cast<const Request&>(request);
877 return connect_job_factory_->NewConnectJob( 897 return connect_job_factory_->NewConnectJob(
878 group_name, casted_request, delegate); 898 group_name, casted_request, delegate);
879 } 899 }
880 900
881 base::TimeDelta ConnectionTimeout() const override { 901 base::TimeDelta ConnectionTimeout() const override {
882 return connect_job_factory_->ConnectionTimeout(); 902 return connect_job_factory_->ConnectionTimeout();
883 } 903 }
884 904
905 void SetSocketPerformanceWatcherFactory(
906 SocketPerformanceWatcherFactory* socket_performance_watcher_factory) {
907 connect_job_factory_->SetSocketPerformanceWatcherFactory(
908 socket_performance_watcher_factory);
909 }
910
885 const scoped_ptr<ConnectJobFactory> connect_job_factory_; 911 const scoped_ptr<ConnectJobFactory> connect_job_factory_;
886 }; 912 };
887 913
888 internal::ClientSocketPoolBaseHelper helper_; 914 internal::ClientSocketPoolBaseHelper helper_;
889 915
890 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); 916 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase);
891 }; 917 };
892 918
893 } // namespace net 919 } // namespace net
894 920
895 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ 921 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698