| 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 <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.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" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // reuse information. |load_timing_info| must have all default values when | 125 // reuse information. |load_timing_info| must have all default values when |
| 126 // called. Returns false and makes no changes to |load_timing_info| when | 126 // called. Returns false and makes no changes to |load_timing_info| when |
| 127 // |socket_| is NULL. | 127 // |socket_| is NULL. |
| 128 bool GetLoadTimingInfo(bool is_reused, | 128 bool GetLoadTimingInfo(bool is_reused, |
| 129 LoadTimingInfo* load_timing_info) const; | 129 LoadTimingInfo* load_timing_info) const; |
| 130 | 130 |
| 131 // Used by ClientSocketPool to initialize the ClientSocketHandle. | 131 // Used by ClientSocketPool to initialize the ClientSocketHandle. |
| 132 // | 132 // |
| 133 // SetSocket() may also be used if this handle is used as simply for | 133 // SetSocket() may also be used if this handle is used as simply for |
| 134 // socket storage (e.g., http://crbug.com/37810). | 134 // socket storage (e.g., http://crbug.com/37810). |
| 135 void SetSocket(scoped_ptr<StreamSocket> s); | 135 void SetSocket(std::unique_ptr<StreamSocket> s); |
| 136 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } | 136 void set_reuse_type(SocketReuseType reuse_type) { reuse_type_ = reuse_type; } |
| 137 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } | 137 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } |
| 138 void set_pool_id(int id) { pool_id_ = id; } | 138 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; } | 139 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) { | 140 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { |
| 141 ssl_error_response_info_ = ssl_error_state; | 141 ssl_error_response_info_ = ssl_error_state; |
| 142 } | 142 } |
| 143 void set_ssl_failure_state(SSLFailureState ssl_failure_state) { | 143 void set_ssl_failure_state(SSLFailureState ssl_failure_state) { |
| 144 ssl_failure_state_ = ssl_failure_state; | 144 ssl_failure_state_ = ssl_failure_state; |
| 145 } | 145 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 169 // succeeded, they will be returned through the socket instead; see | 169 // succeeded, they will be returned through the socket instead; see |
| 170 // |StreamSocket::GetConnectionAttempts|.) | 170 // |StreamSocket::GetConnectionAttempts|.) |
| 171 const ConnectionAttempts& connection_attempts() { | 171 const ConnectionAttempts& connection_attempts() { |
| 172 return connection_attempts_; | 172 return connection_attempts_; |
| 173 } | 173 } |
| 174 | 174 |
| 175 StreamSocket* socket() { return socket_.get(); } | 175 StreamSocket* socket() { return socket_.get(); } |
| 176 | 176 |
| 177 // SetSocket() must be called with a new socket before this handle | 177 // SetSocket() must be called with a new socket before this handle |
| 178 // is destroyed if is_initialized() is true. | 178 // is destroyed if is_initialized() is true. |
| 179 scoped_ptr<StreamSocket> PassSocket(); | 179 std::unique_ptr<StreamSocket> PassSocket(); |
| 180 | 180 |
| 181 // These may only be used if is_initialized() is true. | 181 // These may only be used if is_initialized() is true. |
| 182 const std::string& group_name() const { return group_name_; } | 182 const std::string& group_name() const { return group_name_; } |
| 183 int id() const { return pool_id_; } | 183 int id() const { return pool_id_; } |
| 184 bool is_reused() const { return reuse_type_ == REUSED_IDLE; } | 184 bool is_reused() const { return reuse_type_ == REUSED_IDLE; } |
| 185 base::TimeDelta idle_time() const { return idle_time_; } | 185 base::TimeDelta idle_time() const { return idle_time_; } |
| 186 SocketReuseType reuse_type() const { return reuse_type_; } | 186 SocketReuseType reuse_type() const { return reuse_type_; } |
| 187 const LoadTimingInfo::ConnectTiming& connect_timing() const { | 187 const LoadTimingInfo::ConnectTiming& connect_timing() const { |
| 188 return connect_timing_; | 188 return connect_timing_; |
| 189 } | 189 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 203 // not to try to cancel the request with the ClientSocketPool. Does not | 203 // not to try to cancel the request with the ClientSocketPool. Does not |
| 204 // reset the supplemental error state. | 204 // reset the supplemental error state. |
| 205 void ResetInternal(bool cancel); | 205 void ResetInternal(bool cancel); |
| 206 | 206 |
| 207 // Resets the supplemental error state. | 207 // Resets the supplemental error state. |
| 208 void ResetErrorState(); | 208 void ResetErrorState(); |
| 209 | 209 |
| 210 bool is_initialized_; | 210 bool is_initialized_; |
| 211 ClientSocketPool* pool_; | 211 ClientSocketPool* pool_; |
| 212 HigherLayeredPool* higher_pool_; | 212 HigherLayeredPool* higher_pool_; |
| 213 scoped_ptr<StreamSocket> socket_; | 213 std::unique_ptr<StreamSocket> socket_; |
| 214 std::string group_name_; | 214 std::string group_name_; |
| 215 SocketReuseType reuse_type_; | 215 SocketReuseType reuse_type_; |
| 216 CompletionCallback callback_; | 216 CompletionCallback callback_; |
| 217 CompletionCallback user_callback_; | 217 CompletionCallback user_callback_; |
| 218 base::TimeDelta idle_time_; | 218 base::TimeDelta idle_time_; |
| 219 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. | 219 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. |
| 220 bool is_ssl_error_; | 220 bool is_ssl_error_; |
| 221 HttpResponseInfo ssl_error_response_info_; | 221 HttpResponseInfo ssl_error_response_info_; |
| 222 SSLFailureState ssl_failure_state_; | 222 SSLFailureState ssl_failure_state_; |
| 223 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; | 223 std::unique_ptr<ClientSocketHandle> pending_http_proxy_connection_; |
| 224 std::vector<ConnectionAttempt> connection_attempts_; | 224 std::vector<ConnectionAttempt> connection_attempts_; |
| 225 base::TimeTicks init_time_; | 225 base::TimeTicks init_time_; |
| 226 base::TimeDelta setup_time_; | 226 base::TimeDelta setup_time_; |
| 227 | 227 |
| 228 NetLog::Source requesting_source_; | 228 NetLog::Source requesting_source_; |
| 229 | 229 |
| 230 // Timing information is set when a connection is successfully established. | 230 // Timing information is set when a connection is successfully established. |
| 231 LoadTimingInfo::ConnectTiming connect_timing_; | 231 LoadTimingInfo::ConnectTiming connect_timing_; |
| 232 | 232 |
| 233 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); | 233 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 257 user_callback_ = callback; | 257 user_callback_ = callback; |
| 258 } else { | 258 } else { |
| 259 HandleInitCompletion(rv); | 259 HandleInitCompletion(rv); |
| 260 } | 260 } |
| 261 return rv; | 261 return rv; |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace net | 264 } // namespace net |
| 265 | 265 |
| 266 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 266 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| OLD | NEW |