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

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

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ 5 #ifndef NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
6 #define NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ 6 #define NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 RequestPriority priority, 46 RequestPriority priority,
47 const scoped_refptr<TransportSocketParams>& params, 47 const scoped_refptr<TransportSocketParams>& params,
48 base::TimeDelta timeout_duration, 48 base::TimeDelta timeout_duration,
49 const CompletionCallback& callback, 49 const CompletionCallback& callback,
50 ClientSocketFactory* client_socket_factory, 50 ClientSocketFactory* client_socket_factory,
51 HostResolver* host_resolver, 51 HostResolver* host_resolver,
52 ClientSocketHandle* handle, 52 ClientSocketHandle* handle,
53 Delegate* delegate, 53 Delegate* delegate,
54 NetLog* pool_net_log, 54 NetLog* pool_net_log,
55 const BoundNetLog& request_net_log); 55 const BoundNetLog& request_net_log);
56 virtual ~WebSocketTransportConnectJob(); 56 ~WebSocketTransportConnectJob() override;
57 57
58 // Unlike normal socket pools, the WebSocketTransportClientPool uses 58 // Unlike normal socket pools, the WebSocketTransportClientPool uses
59 // early-binding of sockets. 59 // early-binding of sockets.
60 ClientSocketHandle* handle() const { return handle_; } 60 ClientSocketHandle* handle() const { return handle_; }
61 61
62 // Stash the callback from RequestSocket() here for convenience. 62 // Stash the callback from RequestSocket() here for convenience.
63 const CompletionCallback& callback() const { return callback_; } 63 const CompletionCallback& callback() const { return callback_; }
64 64
65 const BoundNetLog& request_net_log() const { return request_net_log_; } 65 const BoundNetLog& request_net_log() const { return request_net_log_; }
66 66
67 // ConnectJob methods. 67 // ConnectJob methods.
68 virtual LoadState GetLoadState() const override; 68 LoadState GetLoadState() const override;
69 69
70 private: 70 private:
71 friend class WebSocketTransportConnectSubJob; 71 friend class WebSocketTransportConnectSubJob;
72 friend class TransportConnectJobHelper; 72 friend class TransportConnectJobHelper;
73 friend class WebSocketEndpointLockManager; 73 friend class WebSocketEndpointLockManager;
74 74
75 // Although it is not strictly necessary, it makes the code simpler if each 75 // Although it is not strictly necessary, it makes the code simpler if each
76 // subjob knows what type it is. 76 // subjob knows what type it is.
77 enum SubJobType { SUB_JOB_IPV4, SUB_JOB_IPV6 }; 77 enum SubJobType { SUB_JOB_IPV4, SUB_JOB_IPV6 };
78 78
79 int DoResolveHost(); 79 int DoResolveHost();
80 int DoResolveHostComplete(int result); 80 int DoResolveHostComplete(int result);
81 int DoTransportConnect(); 81 int DoTransportConnect();
82 int DoTransportConnectComplete(int result); 82 int DoTransportConnectComplete(int result);
83 83
84 // Called back from a SubJob when it completes. 84 // Called back from a SubJob when it completes.
85 void OnSubJobComplete(int result, WebSocketTransportConnectSubJob* job); 85 void OnSubJobComplete(int result, WebSocketTransportConnectSubJob* job);
86 86
87 // Called from |fallback_timer_|. 87 // Called from |fallback_timer_|.
88 void StartIPv4JobAsync(); 88 void StartIPv4JobAsync();
89 89
90 // Begins the host resolution and the TCP connect. Returns OK on success 90 // Begins the host resolution and the TCP connect. Returns OK on success
91 // and ERR_IO_PENDING if it cannot immediately service the request. 91 // and ERR_IO_PENDING if it cannot immediately service the request.
92 // Otherwise, it returns a net error code. 92 // Otherwise, it returns a net error code.
93 virtual int ConnectInternal() override; 93 int ConnectInternal() override;
94 94
95 TransportConnectJobHelper helper_; 95 TransportConnectJobHelper helper_;
96 96
97 // The addresses are divided into IPv4 and IPv6, which are performed partially 97 // The addresses are divided into IPv4 and IPv6, which are performed partially
98 // in parallel. If the list of IPv6 addresses is non-empty, then the IPv6 jobs 98 // in parallel. If the list of IPv6 addresses is non-empty, then the IPv6 jobs
99 // go first, followed after |kIPv6FallbackTimerInMs| by the IPv4 99 // go first, followed after |kIPv6FallbackTimerInMs| by the IPv4
100 // addresses. First sub-job to establish a connection wins. 100 // addresses. First sub-job to establish a connection wins.
101 scoped_ptr<WebSocketTransportConnectSubJob> ipv4_job_; 101 scoped_ptr<WebSocketTransportConnectSubJob> ipv4_job_;
102 scoped_ptr<WebSocketTransportConnectSubJob> ipv6_job_; 102 scoped_ptr<WebSocketTransportConnectSubJob> ipv6_job_;
103 103
(...skipping 12 matching lines...) Expand all
116 class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool 116 class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool
117 : public TransportClientSocketPool { 117 : public TransportClientSocketPool {
118 public: 118 public:
119 WebSocketTransportClientSocketPool(int max_sockets, 119 WebSocketTransportClientSocketPool(int max_sockets,
120 int max_sockets_per_group, 120 int max_sockets_per_group,
121 ClientSocketPoolHistograms* histograms, 121 ClientSocketPoolHistograms* histograms,
122 HostResolver* host_resolver, 122 HostResolver* host_resolver,
123 ClientSocketFactory* client_socket_factory, 123 ClientSocketFactory* client_socket_factory,
124 NetLog* net_log); 124 NetLog* net_log);
125 125
126 virtual ~WebSocketTransportClientSocketPool(); 126 ~WebSocketTransportClientSocketPool() override;
127 127
128 // Allow another connection to be started to the IPEndPoint that this |handle| 128 // Allow another connection to be started to the IPEndPoint that this |handle|
129 // is connected to. Used when the WebSocket handshake completes successfully. 129 // is connected to. Used when the WebSocket handshake completes successfully.
130 // This only works if the socket is connected, however the caller does not 130 // This only works if the socket is connected, however the caller does not
131 // need to explicitly check for this. Instead, ensure that dead sockets are 131 // need to explicitly check for this. Instead, ensure that dead sockets are
132 // returned to ReleaseSocket() in a timely fashion. 132 // returned to ReleaseSocket() in a timely fashion.
133 static void UnlockEndpoint(ClientSocketHandle* handle); 133 static void UnlockEndpoint(ClientSocketHandle* handle);
134 134
135 // ClientSocketPool implementation. 135 // ClientSocketPool implementation.
136 virtual int RequestSocket(const std::string& group_name, 136 int RequestSocket(const std::string& group_name,
137 const void* resolve_info, 137 const void* resolve_info,
138 RequestPriority priority, 138 RequestPriority priority,
139 ClientSocketHandle* handle, 139 ClientSocketHandle* handle,
140 const CompletionCallback& callback, 140 const CompletionCallback& callback,
141 const BoundNetLog& net_log) override; 141 const BoundNetLog& net_log) override;
142 virtual void RequestSockets(const std::string& group_name, 142 void RequestSockets(const std::string& group_name,
143 const void* params, 143 const void* params,
144 int num_sockets, 144 int num_sockets,
145 const BoundNetLog& net_log) override; 145 const BoundNetLog& net_log) override;
146 virtual void CancelRequest(const std::string& group_name, 146 void CancelRequest(const std::string& group_name,
147 ClientSocketHandle* handle) override; 147 ClientSocketHandle* handle) override;
148 virtual void ReleaseSocket(const std::string& group_name, 148 void ReleaseSocket(const std::string& group_name,
149 scoped_ptr<StreamSocket> socket, 149 scoped_ptr<StreamSocket> socket,
150 int id) override; 150 int id) override;
151 virtual void FlushWithError(int error) override; 151 void FlushWithError(int error) override;
152 virtual void CloseIdleSockets() override; 152 void CloseIdleSockets() override;
153 virtual int IdleSocketCount() const override; 153 int IdleSocketCount() const override;
154 virtual int IdleSocketCountInGroup( 154 int IdleSocketCountInGroup(const std::string& group_name) const override;
155 const std::string& group_name) const override; 155 LoadState GetLoadState(const std::string& group_name,
156 virtual LoadState GetLoadState( 156 const ClientSocketHandle* handle) const override;
157 const std::string& group_name, 157 base::DictionaryValue* GetInfoAsValue(
158 const ClientSocketHandle* handle) const override;
159 virtual base::DictionaryValue* GetInfoAsValue(
160 const std::string& name, 158 const std::string& name,
161 const std::string& type, 159 const std::string& type,
162 bool include_nested_pools) const override; 160 bool include_nested_pools) const override;
163 virtual base::TimeDelta ConnectionTimeout() const override; 161 base::TimeDelta ConnectionTimeout() const override;
164 virtual ClientSocketPoolHistograms* histograms() const override; 162 ClientSocketPoolHistograms* histograms() const override;
165 163
166 // HigherLayeredPool implementation. 164 // HigherLayeredPool implementation.
167 virtual bool IsStalled() const override; 165 bool IsStalled() const override;
168 166
169 private: 167 private:
170 class ConnectJobDelegate : public ConnectJob::Delegate { 168 class ConnectJobDelegate : public ConnectJob::Delegate {
171 public: 169 public:
172 explicit ConnectJobDelegate(WebSocketTransportClientSocketPool* owner); 170 explicit ConnectJobDelegate(WebSocketTransportClientSocketPool* owner);
173 virtual ~ConnectJobDelegate(); 171 ~ConnectJobDelegate() override;
174 172
175 virtual void OnConnectJobComplete(int result, ConnectJob* job) override; 173 void OnConnectJobComplete(int result, ConnectJob* job) override;
176 174
177 private: 175 private:
178 WebSocketTransportClientSocketPool* owner_; 176 WebSocketTransportClientSocketPool* owner_;
179 177
180 DISALLOW_COPY_AND_ASSIGN(ConnectJobDelegate); 178 DISALLOW_COPY_AND_ASSIGN(ConnectJobDelegate);
181 }; 179 };
182 180
183 // Store the arguments from a call to RequestSocket() that has stalled so we 181 // Store the arguments from a call to RequestSocket() that has stalled so we
184 // can replay it when there are available socket slots. 182 // can replay it when there are available socket slots.
185 struct StalledRequest { 183 struct StalledRequest {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 bool flushing_; 237 bool flushing_;
240 238
241 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; 239 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_;
242 240
243 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); 241 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool);
244 }; 242 };
245 243
246 } // namespace net 244 } // namespace net
247 245
248 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ 246 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
OLDNEW
« no previous file with comments | « net/socket/websocket_endpoint_lock_manager_unittest.cc ('k') | net/socket/websocket_transport_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698