| 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 <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // removes the higher pool if RemoveHigherLayeredPool has not been called. | 107 // removes the higher pool if RemoveHigherLayeredPool has not been called. |
| 108 void AddHigherLayeredPool(HigherLayeredPool* higher_pool); | 108 void AddHigherLayeredPool(HigherLayeredPool* higher_pool); |
| 109 | 109 |
| 110 // Removes a higher layered pool from the socket pool that |socket_| belongs | 110 // Removes a higher layered pool from the socket pool that |socket_| belongs |
| 111 // to. |higher_pool| must have been added by the above function. | 111 // to. |higher_pool| must have been added by the above function. |
| 112 void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool); | 112 void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool); |
| 113 | 113 |
| 114 // Returns true when Init() has completed successfully. | 114 // Returns true when Init() has completed successfully. |
| 115 bool is_initialized() const { return is_initialized_; } | 115 bool is_initialized() const { return is_initialized_; } |
| 116 | 116 |
| 117 // Returns the time tick when Init() was called. | |
| 118 base::TimeTicks init_time() const { return init_time_; } | |
| 119 | |
| 120 // Returns the time between Init() and when is_initialized() becomes true. | |
| 121 base::TimeDelta setup_time() const { return setup_time_; } | |
| 122 | |
| 123 // Sets the portion of LoadTimingInfo related to connection establishment, and | 117 // Sets the portion of LoadTimingInfo related to connection establishment, and |
| 124 // the socket id. |is_reused| is needed because the handle may not have full | 118 // the socket id. |is_reused| is needed because the handle may not have full |
| 125 // reuse information. |load_timing_info| must have all default values when | 119 // reuse information. |load_timing_info| must have all default values when |
| 126 // called. Returns false and makes no changes to |load_timing_info| when | 120 // called. Returns false and makes no changes to |load_timing_info| when |
| 127 // |socket_| is NULL. | 121 // |socket_| is NULL. |
| 128 bool GetLoadTimingInfo(bool is_reused, | 122 bool GetLoadTimingInfo(bool is_reused, |
| 129 LoadTimingInfo* load_timing_info) const; | 123 LoadTimingInfo* load_timing_info) const; |
| 130 | 124 |
| 131 // Used by ClientSocketPool to initialize the ClientSocketHandle. | 125 // Used by ClientSocketPool to initialize the ClientSocketHandle. |
| 132 // | 126 // |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 std::string group_name_; | 204 std::string group_name_; |
| 211 SocketReuseType reuse_type_; | 205 SocketReuseType reuse_type_; |
| 212 CompletionCallback callback_; | 206 CompletionCallback callback_; |
| 213 CompletionCallback user_callback_; | 207 CompletionCallback user_callback_; |
| 214 base::TimeDelta idle_time_; | 208 base::TimeDelta idle_time_; |
| 215 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. | 209 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. |
| 216 bool is_ssl_error_; | 210 bool is_ssl_error_; |
| 217 HttpResponseInfo ssl_error_response_info_; | 211 HttpResponseInfo ssl_error_response_info_; |
| 218 std::unique_ptr<ClientSocketHandle> pending_http_proxy_connection_; | 212 std::unique_ptr<ClientSocketHandle> pending_http_proxy_connection_; |
| 219 std::vector<ConnectionAttempt> connection_attempts_; | 213 std::vector<ConnectionAttempt> connection_attempts_; |
| 220 base::TimeTicks init_time_; | |
| 221 base::TimeDelta setup_time_; | |
| 222 | 214 |
| 223 NetLogSource requesting_source_; | 215 NetLogSource requesting_source_; |
| 224 | 216 |
| 225 // Timing information is set when a connection is successfully established. | 217 // Timing information is set when a connection is successfully established. |
| 226 LoadTimingInfo::ConnectTiming connect_timing_; | 218 LoadTimingInfo::ConnectTiming connect_timing_; |
| 227 | 219 |
| 228 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); | 220 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); |
| 229 }; | 221 }; |
| 230 | 222 |
| 231 // Template function implementation: | 223 // Template function implementation: |
| 232 template <typename PoolType> | 224 template <typename PoolType> |
| 233 int ClientSocketHandle::Init( | 225 int ClientSocketHandle::Init( |
| 234 const std::string& group_name, | 226 const std::string& group_name, |
| 235 const scoped_refptr<typename PoolType::SocketParams>& socket_params, | 227 const scoped_refptr<typename PoolType::SocketParams>& socket_params, |
| 236 RequestPriority priority, | 228 RequestPriority priority, |
| 237 ClientSocketPool::RespectLimits respect_limits, | 229 ClientSocketPool::RespectLimits respect_limits, |
| 238 const CompletionCallback& callback, | 230 const CompletionCallback& callback, |
| 239 PoolType* pool, | 231 PoolType* pool, |
| 240 const NetLogWithSource& net_log) { | 232 const NetLogWithSource& net_log) { |
| 241 requesting_source_ = net_log.source(); | 233 requesting_source_ = net_log.source(); |
| 242 | 234 |
| 243 CHECK(!group_name.empty()); | 235 CHECK(!group_name.empty()); |
| 244 ResetInternal(true); | 236 ResetInternal(true); |
| 245 ResetErrorState(); | 237 ResetErrorState(); |
| 246 pool_ = pool; | 238 pool_ = pool; |
| 247 group_name_ = group_name; | 239 group_name_ = group_name; |
| 248 init_time_ = base::TimeTicks::Now(); | |
| 249 int rv = pool_->RequestSocket(group_name, &socket_params, priority, | 240 int rv = pool_->RequestSocket(group_name, &socket_params, priority, |
| 250 respect_limits, this, callback_, net_log); | 241 respect_limits, this, callback_, net_log); |
| 251 if (rv == ERR_IO_PENDING) { | 242 if (rv == ERR_IO_PENDING) { |
| 252 user_callback_ = callback; | 243 user_callback_ = callback; |
| 253 } else { | 244 } else { |
| 254 HandleInitCompletion(rv); | 245 HandleInitCompletion(rv); |
| 255 } | 246 } |
| 256 return rv; | 247 return rv; |
| 257 } | 248 } |
| 258 | 249 |
| 259 } // namespace net | 250 } // namespace net |
| 260 | 251 |
| 261 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 252 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| OLD | NEW |