| OLD | NEW |
| 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 #ifndef NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| 6 #define NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 17 #include "net/base/load_states.h" | 17 #include "net/base/load_states.h" |
| 18 #include "net/base/load_timing_info.h" | 18 #include "net/base/load_timing_info.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
| 21 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
| 22 #include "net/http/http_response_info.h" | 22 #include "net/http/http_response_info.h" |
| 23 #include "net/log/net_log.h" | 23 #include "net/log/net_log.h" |
| 24 #include "net/socket/client_socket_pool.h" | 24 #include "net/socket/client_socket_pool.h" |
| 25 #include "net/socket/connection_attempts.h" | 25 #include "net/socket/connection_attempts.h" |
| 26 #include "net/socket/stream_socket.h" | 26 #include "net/socket/stream_socket.h" |
| 27 #include "net/ssl/ssl_failure_state.h" | |
| 28 | 27 |
| 29 namespace net { | 28 namespace net { |
| 30 | 29 |
| 31 // A container for a StreamSocket. | 30 // A container for a StreamSocket. |
| 32 // | 31 // |
| 33 // The handle's |group_name| uniquely identifies the origin and type of the | 32 // The handle's |group_name| uniquely identifies the origin and type of the |
| 34 // connection. It is used by the ClientSocketPool to group similar connected | 33 // connection. It is used by the ClientSocketPool to group similar connected |
| 35 // client socket objects. | 34 // client socket objects. |
| 36 // | 35 // |
| 37 class NET_EXPORT ClientSocketHandle { | 36 class NET_EXPORT ClientSocketHandle { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // SetSocket() may also be used if this handle is used as simply for | 132 // SetSocket() may also be used if this handle is used as simply for |
| 134 // socket storage (e.g., http://crbug.com/37810). | 133 // socket storage (e.g., http://crbug.com/37810). |
| 135 void SetSocket(std::unique_ptr<StreamSocket> s); | 134 void SetSocket(std::unique_ptr<StreamSocket> s); |
| 136 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } | 135 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } |
| 137 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } | 136 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } |
| 138 void set_pool_id(int id) { pool_id_ = id; } | 137 void set_pool_id(int id) { pool_id_ = id; } |
| 139 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } | 138 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } |
| 140 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { | 139 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { |
| 141 ssl_error_response_info_ = ssl_error_state; | 140 ssl_error_response_info_ = ssl_error_state; |
| 142 } | 141 } |
| 143 void set_ssl_failure_state(SSLFailureState ssl_failure_state) { | |
| 144 ssl_failure_state_ = ssl_failure_state; | |
| 145 } | |
| 146 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { | 142 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { |
| 147 pending_http_proxy_connection_.reset(connection); | 143 pending_http_proxy_connection_.reset(connection); |
| 148 } | 144 } |
| 149 void set_connection_attempts(const ConnectionAttempts& attempts) { | 145 void set_connection_attempts(const ConnectionAttempts& attempts) { |
| 150 connection_attempts_ = attempts; | 146 connection_attempts_ = attempts; |
| 151 } | 147 } |
| 152 | 148 |
| 153 // Only valid if there is no |socket_|. | 149 // Only valid if there is no |socket_|. |
| 154 bool is_ssl_error() const { | 150 bool is_ssl_error() const { |
| 155 DCHECK(!socket_); | 151 DCHECK(!socket_); |
| 156 return is_ssl_error_; | 152 return is_ssl_error_; |
| 157 } | 153 } |
| 158 // On an ERR_PROXY_AUTH_REQUESTED error, the |headers| and |auth_challenge| | 154 // On an ERR_PROXY_AUTH_REQUESTED error, the |headers| and |auth_challenge| |
| 159 // fields are filled in. On an ERR_SSL_CLIENT_AUTH_CERT_NEEDED error, | 155 // fields are filled in. On an ERR_SSL_CLIENT_AUTH_CERT_NEEDED error, |
| 160 // the |cert_request_info| field is set. | 156 // the |cert_request_info| field is set. |
| 161 const HttpResponseInfo& ssl_error_response_info() const { | 157 const HttpResponseInfo& ssl_error_response_info() const { |
| 162 return ssl_error_response_info_; | 158 return ssl_error_response_info_; |
| 163 } | 159 } |
| 164 SSLFailureState ssl_failure_state() const { return ssl_failure_state_; } | |
| 165 ClientSocketHandle* release_pending_http_proxy_connection() { | 160 ClientSocketHandle* release_pending_http_proxy_connection() { |
| 166 return pending_http_proxy_connection_.release(); | 161 return pending_http_proxy_connection_.release(); |
| 167 } | 162 } |
| 168 // If the connection failed, returns the connection attempts made. (If it | 163 // If the connection failed, returns the connection attempts made. (If it |
| 169 // succeeded, they will be returned through the socket instead; see | 164 // succeeded, they will be returned through the socket instead; see |
| 170 // |StreamSocket::GetConnectionAttempts|.) | 165 // |StreamSocket::GetConnectionAttempts|.) |
| 171 const ConnectionAttempts& connection_attempts() { | 166 const ConnectionAttempts& connection_attempts() { |
| 172 return connection_attempts_; | 167 return connection_attempts_; |
| 173 } | 168 } |
| 174 | 169 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 HigherLayeredPool* higher_pool_; | 207 HigherLayeredPool* higher_pool_; |
| 213 std::unique_ptr<StreamSocket> socket_; | 208 std::unique_ptr<StreamSocket> socket_; |
| 214 std::string group_name_; | 209 std::string group_name_; |
| 215 SocketReuseType reuse_type_; | 210 SocketReuseType reuse_type_; |
| 216 CompletionCallback callback_; | 211 CompletionCallback callback_; |
| 217 CompletionCallback user_callback_; | 212 CompletionCallback user_callback_; |
| 218 base::TimeDelta idle_time_; | 213 base::TimeDelta idle_time_; |
| 219 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. | 214 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. |
| 220 bool is_ssl_error_; | 215 bool is_ssl_error_; |
| 221 HttpResponseInfo ssl_error_response_info_; | 216 HttpResponseInfo ssl_error_response_info_; |
| 222 SSLFailureState ssl_failure_state_; | |
| 223 std::unique_ptr<ClientSocketHandle> pending_http_proxy_connection_; | 217 std::unique_ptr<ClientSocketHandle> pending_http_proxy_connection_; |
| 224 std::vector<ConnectionAttempt> connection_attempts_; | 218 std::vector<ConnectionAttempt> connection_attempts_; |
| 225 base::TimeTicks init_time_; | 219 base::TimeTicks init_time_; |
| 226 base::TimeDelta setup_time_; | 220 base::TimeDelta setup_time_; |
| 227 | 221 |
| 228 NetLog::Source requesting_source_; | 222 NetLog::Source requesting_source_; |
| 229 | 223 |
| 230 // Timing information is set when a connection is successfully established. | 224 // Timing information is set when a connection is successfully established. |
| 231 LoadTimingInfo::ConnectTiming connect_timing_; | 225 LoadTimingInfo::ConnectTiming connect_timing_; |
| 232 | 226 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 257 user_callback_ = callback; | 251 user_callback_ = callback; |
| 258 } else { | 252 } else { |
| 259 HandleInitCompletion(rv); | 253 HandleInitCompletion(rv); |
| 260 } | 254 } |
| 261 return rv; | 255 return rv; |
| 262 } | 256 } |
| 263 | 257 |
| 264 } // namespace net | 258 } // namespace net |
| 265 | 259 |
| 266 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 260 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| OLD | NEW |