| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 15 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
| 16 #include "net/base/load_states.h" | 16 #include "net/base/load_states.h" |
| 17 #include "net/base/load_timing_info.h" | 17 #include "net/base/load_timing_info.h" |
| 18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| 20 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 21 #include "net/http/http_response_info.h" | 21 #include "net/http/http_response_info.h" |
| 22 #include "net/log/net_log.h" | 22 #include "net/log/net_log.h" |
| 23 #include "net/socket/client_socket_pool.h" | 23 #include "net/socket/client_socket_pool.h" |
| 24 #include "net/socket/connection_attempts.h" | 24 #include "net/socket/connection_attempts.h" |
| 25 #include "net/socket/stream_socket.h" | 25 #include "net/socket/stream_socket.h" |
| 26 #include "net/ssl/ssl_failure_state.h" |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 | 29 |
| 29 // A container for a StreamSocket. | 30 // A container for a StreamSocket. |
| 30 // | 31 // |
| 31 // 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 |
| 32 // connection. It is used by the ClientSocketPool to group similar connected | 33 // connection. It is used by the ClientSocketPool to group similar connected |
| 33 // client socket objects. | 34 // client socket objects. |
| 34 // | 35 // |
| 35 class NET_EXPORT ClientSocketHandle { | 36 class NET_EXPORT ClientSocketHandle { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // SetSocket() may also be used if this handle is used as simply for | 129 // SetSocket() may also be used if this handle is used as simply for |
| 129 // socket storage (e.g., http://crbug.com/37810). | 130 // socket storage (e.g., http://crbug.com/37810). |
| 130 void SetSocket(scoped_ptr<StreamSocket> s); | 131 void SetSocket(scoped_ptr<StreamSocket> s); |
| 131 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } | 132 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } |
| 132 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } | 133 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } |
| 133 void set_pool_id(int id) { pool_id_ = id; } | 134 void set_pool_id(int id) { pool_id_ = id; } |
| 134 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } | 135 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } |
| 135 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { | 136 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { |
| 136 ssl_error_response_info_ = ssl_error_state; | 137 ssl_error_response_info_ = ssl_error_state; |
| 137 } | 138 } |
| 139 void set_ssl_failure_state(SSLFailureState ssl_failure_state) { |
| 140 ssl_failure_state_ = ssl_failure_state; |
| 141 } |
| 138 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { | 142 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { |
| 139 pending_http_proxy_connection_.reset(connection); | 143 pending_http_proxy_connection_.reset(connection); |
| 140 } | 144 } |
| 141 void set_connection_attempts(const ConnectionAttempts& attempts) { | 145 void set_connection_attempts(const ConnectionAttempts& attempts) { |
| 142 connection_attempts_ = attempts; | 146 connection_attempts_ = attempts; |
| 143 } | 147 } |
| 144 | 148 |
| 145 // Only valid if there is no |socket_|. | 149 // Only valid if there is no |socket_|. |
| 146 bool is_ssl_error() const { | 150 bool is_ssl_error() const { |
| 147 DCHECK(socket_.get() == NULL); | 151 DCHECK(socket_.get() == NULL); |
| 148 return is_ssl_error_; | 152 return is_ssl_error_; |
| 149 } | 153 } |
| 150 // 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| |
| 151 // 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, |
| 152 // the |cert_request_info| field is set. | 156 // the |cert_request_info| field is set. |
| 153 const HttpResponseInfo& ssl_error_response_info() const { | 157 const HttpResponseInfo& ssl_error_response_info() const { |
| 154 return ssl_error_response_info_; | 158 return ssl_error_response_info_; |
| 155 } | 159 } |
| 160 SSLFailureState ssl_failure_state() const { return ssl_failure_state_; } |
| 156 ClientSocketHandle* release_pending_http_proxy_connection() { | 161 ClientSocketHandle* release_pending_http_proxy_connection() { |
| 157 return pending_http_proxy_connection_.release(); | 162 return pending_http_proxy_connection_.release(); |
| 158 } | 163 } |
| 159 const ConnectionAttempts& connection_attempts() { | 164 const ConnectionAttempts& connection_attempts() { |
| 160 return connection_attempts_; | 165 return connection_attempts_; |
| 161 } | 166 } |
| 162 | 167 |
| 163 StreamSocket* socket() { return socket_.get(); } | 168 StreamSocket* socket() { return socket_.get(); } |
| 164 | 169 |
| 165 // SetSocket() must be called with a new socket before this handle | 170 // SetSocket() must be called with a new socket before this handle |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 HigherLayeredPool* higher_pool_; | 205 HigherLayeredPool* higher_pool_; |
| 201 scoped_ptr<StreamSocket> socket_; | 206 scoped_ptr<StreamSocket> socket_; |
| 202 std::string group_name_; | 207 std::string group_name_; |
| 203 SocketReuseType reuse_type_; | 208 SocketReuseType reuse_type_; |
| 204 CompletionCallback callback_; | 209 CompletionCallback callback_; |
| 205 CompletionCallback user_callback_; | 210 CompletionCallback user_callback_; |
| 206 base::TimeDelta idle_time_; | 211 base::TimeDelta idle_time_; |
| 207 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. | 212 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. |
| 208 bool is_ssl_error_; | 213 bool is_ssl_error_; |
| 209 HttpResponseInfo ssl_error_response_info_; | 214 HttpResponseInfo ssl_error_response_info_; |
| 215 SSLFailureState ssl_failure_state_; |
| 210 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; | 216 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; |
| 211 std::vector<ConnectionAttempt> connection_attempts_; | 217 std::vector<ConnectionAttempt> connection_attempts_; |
| 212 base::TimeTicks init_time_; | 218 base::TimeTicks init_time_; |
| 213 base::TimeDelta setup_time_; | 219 base::TimeDelta setup_time_; |
| 214 | 220 |
| 215 NetLog::Source requesting_source_; | 221 NetLog::Source requesting_source_; |
| 216 | 222 |
| 217 // Timing information is set when a connection is successfully established. | 223 // Timing information is set when a connection is successfully established. |
| 218 LoadTimingInfo::ConnectTiming connect_timing_; | 224 LoadTimingInfo::ConnectTiming connect_timing_; |
| 219 | 225 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 243 user_callback_ = callback; | 249 user_callback_ = callback; |
| 244 } else { | 250 } else { |
| 245 HandleInitCompletion(rv); | 251 HandleInitCompletion(rv); |
| 246 } | 252 } |
| 247 return rv; | 253 return rv; |
| 248 } | 254 } |
| 249 | 255 |
| 250 } // namespace net | 256 } // namespace net |
| 251 | 257 |
| 252 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 258 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| OLD | NEW |