| 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/load_states.h" | 16 #include "net/base/load_states.h" |
| 16 #include "net/base/load_timing_info.h" | 17 #include "net/base/load_timing_info.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| 19 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 20 #include "net/http/http_response_info.h" | 21 #include "net/http/http_response_info.h" |
| 21 #include "net/log/net_log.h" | 22 #include "net/log/net_log.h" |
| 22 #include "net/socket/client_socket_pool.h" | 23 #include "net/socket/client_socket_pool.h" |
| 24 #include "net/socket/connection_attempts.h" |
| 23 #include "net/socket/stream_socket.h" | 25 #include "net/socket/stream_socket.h" |
| 24 | 26 |
| 25 namespace net { | 27 namespace net { |
| 26 | 28 |
| 27 // A container for a StreamSocket. | 29 // A container for a StreamSocket. |
| 28 // | 30 // |
| 29 // The handle's |group_name| uniquely identifies the origin and type of the | 31 // The handle's |group_name| uniquely identifies the origin and type of the |
| 30 // connection. It is used by the ClientSocketPool to group similar connected | 32 // connection. It is used by the ClientSocketPool to group similar connected |
| 31 // client socket objects. | 33 // client socket objects. |
| 32 // | 34 // |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } | 131 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } |
| 130 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } | 132 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } |
| 131 void set_pool_id(int id) { pool_id_ = id; } | 133 void set_pool_id(int id) { pool_id_ = id; } |
| 132 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } | 134 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } |
| 133 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { | 135 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { |
| 134 ssl_error_response_info_ = ssl_error_state; | 136 ssl_error_response_info_ = ssl_error_state; |
| 135 } | 137 } |
| 136 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { | 138 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { |
| 137 pending_http_proxy_connection_.reset(connection); | 139 pending_http_proxy_connection_.reset(connection); |
| 138 } | 140 } |
| 141 void set_connection_attempts(const ConnectionAttempts& attempts) { |
| 142 connection_attempts_ = attempts; |
| 143 } |
| 139 | 144 |
| 140 // Only valid if there is no |socket_|. | 145 // Only valid if there is no |socket_|. |
| 141 bool is_ssl_error() const { | 146 bool is_ssl_error() const { |
| 142 DCHECK(socket_.get() == NULL); | 147 DCHECK(socket_.get() == NULL); |
| 143 return is_ssl_error_; | 148 return is_ssl_error_; |
| 144 } | 149 } |
| 145 // On an ERR_PROXY_AUTH_REQUESTED error, the |headers| and |auth_challenge| | 150 // On an ERR_PROXY_AUTH_REQUESTED error, the |headers| and |auth_challenge| |
| 146 // fields are filled in. On an ERR_SSL_CLIENT_AUTH_CERT_NEEDED error, | 151 // fields are filled in. On an ERR_SSL_CLIENT_AUTH_CERT_NEEDED error, |
| 147 // the |cert_request_info| field is set. | 152 // the |cert_request_info| field is set. |
| 148 const HttpResponseInfo& ssl_error_response_info() const { | 153 const HttpResponseInfo& ssl_error_response_info() const { |
| 149 return ssl_error_response_info_; | 154 return ssl_error_response_info_; |
| 150 } | 155 } |
| 151 ClientSocketHandle* release_pending_http_proxy_connection() { | 156 ClientSocketHandle* release_pending_http_proxy_connection() { |
| 152 return pending_http_proxy_connection_.release(); | 157 return pending_http_proxy_connection_.release(); |
| 153 } | 158 } |
| 159 const ConnectionAttempts& connection_attempts() { |
| 160 return connection_attempts_; |
| 161 } |
| 154 | 162 |
| 155 StreamSocket* socket() { return socket_.get(); } | 163 StreamSocket* socket() { return socket_.get(); } |
| 156 | 164 |
| 157 // SetSocket() must be called with a new socket before this handle | 165 // SetSocket() must be called with a new socket before this handle |
| 158 // is destroyed if is_initialized() is true. | 166 // is destroyed if is_initialized() is true. |
| 159 scoped_ptr<StreamSocket> PassSocket(); | 167 scoped_ptr<StreamSocket> PassSocket(); |
| 160 | 168 |
| 161 // These may only be used if is_initialized() is true. | 169 // These may only be used if is_initialized() is true. |
| 162 const std::string& group_name() const { return group_name_; } | 170 const std::string& group_name() const { return group_name_; } |
| 163 int id() const { return pool_id_; } | 171 int id() const { return pool_id_; } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 193 scoped_ptr<StreamSocket> socket_; | 201 scoped_ptr<StreamSocket> socket_; |
| 194 std::string group_name_; | 202 std::string group_name_; |
| 195 SocketReuseType reuse_type_; | 203 SocketReuseType reuse_type_; |
| 196 CompletionCallback callback_; | 204 CompletionCallback callback_; |
| 197 CompletionCallback user_callback_; | 205 CompletionCallback user_callback_; |
| 198 base::TimeDelta idle_time_; | 206 base::TimeDelta idle_time_; |
| 199 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. | 207 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. |
| 200 bool is_ssl_error_; | 208 bool is_ssl_error_; |
| 201 HttpResponseInfo ssl_error_response_info_; | 209 HttpResponseInfo ssl_error_response_info_; |
| 202 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; | 210 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; |
| 211 std::vector<ConnectionAttempt> connection_attempts_; |
| 203 base::TimeTicks init_time_; | 212 base::TimeTicks init_time_; |
| 204 base::TimeDelta setup_time_; | 213 base::TimeDelta setup_time_; |
| 205 | 214 |
| 206 NetLog::Source requesting_source_; | 215 NetLog::Source requesting_source_; |
| 207 | 216 |
| 208 // Timing information is set when a connection is successfully established. | 217 // Timing information is set when a connection is successfully established. |
| 209 LoadTimingInfo::ConnectTiming connect_timing_; | 218 LoadTimingInfo::ConnectTiming connect_timing_; |
| 210 | 219 |
| 211 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); | 220 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); |
| 212 }; | 221 }; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 234 user_callback_ = callback; | 243 user_callback_ = callback; |
| 235 } else { | 244 } else { |
| 236 HandleInitCompletion(rv); | 245 HandleInitCompletion(rv); |
| 237 } | 246 } |
| 238 return rv; | 247 return rv; |
| 239 } | 248 } |
| 240 | 249 |
| 241 } // namespace net | 250 } // namespace net |
| 242 | 251 |
| 243 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 252 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| OLD | NEW |