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