OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/load_states.h" | 16 #include "net/base/load_states.h" |
17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
18 #include "net/base/net_log.h" | 18 #include "net/base/net_log.h" |
19 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
| 20 #include "net/http/http_proxy_tunnel_client_socket.h" |
20 #include "net/http/http_response_info.h" | 21 #include "net/http/http_response_info.h" |
| 22 #include "net/http/http_stream.h" |
21 #include "net/socket/client_socket.h" | 23 #include "net/socket/client_socket.h" |
22 #include "net/socket/client_socket_pool.h" | 24 #include "net/socket/client_socket_pool.h" |
23 | 25 |
24 namespace net { | 26 namespace net { |
25 | 27 |
26 // A container for a ClientSocket. | 28 // A container for a ClientSocket. |
27 // | 29 // |
28 // The handle's |group_name| uniquely identifies the origin and type of the | 30 // The handle's |group_name| uniquely identifies the origin and type of the |
29 // connection. It is used by the ClientSocketPool to group similar connected | 31 // connection. It is used by the ClientSocketPool to group similar connected |
30 // client socket objects. | 32 // client socket objects. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 104 |
103 // Used by ClientSocketPool to initialize the ClientSocketHandle. | 105 // Used by ClientSocketPool to initialize the ClientSocketHandle. |
104 void set_is_reused(bool is_reused) { is_reused_ = is_reused; } | 106 void set_is_reused(bool is_reused) { is_reused_ = is_reused; } |
105 void set_socket(ClientSocket* s) { socket_.reset(s); } | 107 void set_socket(ClientSocket* s) { socket_.reset(s); } |
106 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } | 108 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } |
107 void set_pool_id(int id) { pool_id_ = id; } | 109 void set_pool_id(int id) { pool_id_ = id; } |
108 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } | 110 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } |
109 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { | 111 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { |
110 ssl_error_response_info_ = ssl_error_state; | 112 ssl_error_response_info_ = ssl_error_state; |
111 } | 113 } |
| 114 void set_pending_https_proxy_response_socket( |
| 115 HttpProxyTunnelClientSocket* socket) { |
| 116 pending_https_proxy_response_socket_.reset(socket); |
| 117 } |
112 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { | 118 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { |
113 pending_http_proxy_connection_.reset(connection); | 119 pending_http_proxy_connection_.reset(connection); |
114 } | 120 } |
115 | 121 |
116 // Only valid if there is no |socket_|. | 122 // Only valid if there is no |socket_|. |
117 bool is_ssl_error() const { | 123 bool is_ssl_error() const { |
118 DCHECK(socket_.get() == NULL); | 124 DCHECK(socket_.get() == NULL); |
119 return is_ssl_error_; | 125 return is_ssl_error_; |
120 } | 126 } |
121 // On an ERR_PROXY_AUTH_REQUESTED error, the |headers| and |auth_challenge| | 127 // On an ERR_PROXY_AUTH_REQUESTED error, the |headers| and |auth_challenge| |
122 // fields are filled in. On an ERR_SSL_CLIENT_AUTH_CERT_NEEDED error, | 128 // fields are filled in. On an ERR_SSL_CLIENT_AUTH_CERT_NEEDED error, |
123 // the |cert_request_info| field is set. | 129 // the |cert_request_info| field is set. |
124 const HttpResponseInfo& ssl_error_response_info() const { | 130 const HttpResponseInfo& ssl_error_response_info() const { |
125 return ssl_error_response_info_; | 131 return ssl_error_response_info_; |
126 } | 132 } |
| 133 HttpProxyTunnelClientSocket* release_pending_https_proxy_response_socket() { |
| 134 return pending_https_proxy_response_socket_.release(); |
| 135 } |
127 ClientSocketHandle* release_pending_http_proxy_connection() { | 136 ClientSocketHandle* release_pending_http_proxy_connection() { |
128 return pending_http_proxy_connection_.release(); | 137 return pending_http_proxy_connection_.release(); |
129 } | 138 } |
130 | 139 |
131 // These may only be used if is_initialized() is true. | 140 // These may only be used if is_initialized() is true. |
132 const std::string& group_name() const { return group_name_; } | 141 const std::string& group_name() const { return group_name_; } |
133 int id() const { return pool_id_; } | 142 int id() const { return pool_id_; } |
134 ClientSocket* socket() { return socket_.get(); } | 143 ClientSocket* socket() { return socket_.get(); } |
135 ClientSocket* release_socket() { return socket_.release(); } | 144 ClientSocket* release_socket() { return socket_.release(); } |
136 bool is_reused() const { return is_reused_; } | 145 bool is_reused() const { return is_reused_; } |
(...skipping 28 matching lines...) Expand all Loading... |
165 ClientSocketPool* pool_; | 174 ClientSocketPool* pool_; |
166 scoped_ptr<ClientSocket> socket_; | 175 scoped_ptr<ClientSocket> socket_; |
167 std::string group_name_; | 176 std::string group_name_; |
168 bool is_reused_; | 177 bool is_reused_; |
169 CompletionCallbackImpl<ClientSocketHandle> callback_; | 178 CompletionCallbackImpl<ClientSocketHandle> callback_; |
170 CompletionCallback* user_callback_; | 179 CompletionCallback* user_callback_; |
171 base::TimeDelta idle_time_; | 180 base::TimeDelta idle_time_; |
172 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. | 181 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. |
173 bool is_ssl_error_; | 182 bool is_ssl_error_; |
174 HttpResponseInfo ssl_error_response_info_; | 183 HttpResponseInfo ssl_error_response_info_; |
| 184 scoped_ptr<HttpProxyTunnelClientSocket> pending_https_proxy_response_socket_; |
175 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; | 185 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; |
176 base::TimeTicks init_time_; | 186 base::TimeTicks init_time_; |
177 base::TimeDelta setup_time_; | 187 base::TimeDelta setup_time_; |
178 | 188 |
179 NetLog::Source requesting_source_; | 189 NetLog::Source requesting_source_; |
180 | 190 |
181 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); | 191 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); |
182 }; | 192 }; |
183 | 193 |
184 // Template function implementation: | 194 // Template function implementation: |
(...skipping 22 matching lines...) Expand all Loading... |
207 user_callback_ = callback; | 217 user_callback_ = callback; |
208 } else { | 218 } else { |
209 HandleInitCompletion(rv); | 219 HandleInitCompletion(rv); |
210 } | 220 } |
211 return rv; | 221 return rv; |
212 } | 222 } |
213 | 223 |
214 } // namespace net | 224 } // namespace net |
215 | 225 |
216 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 226 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
OLD | NEW |