| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // | 75 // |
| 76 // Profiling information for the request is saved to |net_log| if non-NULL. | 76 // Profiling information for the request is saved to |net_log| if non-NULL. |
| 77 // | 77 // |
| 78 template <typename PoolType> | 78 template <typename PoolType> |
| 79 int Init(const std::string& group_name, | 79 int Init(const std::string& group_name, |
| 80 const scoped_refptr<typename PoolType::SocketParams>& socket_params, | 80 const scoped_refptr<typename PoolType::SocketParams>& socket_params, |
| 81 RequestPriority priority, | 81 RequestPriority priority, |
| 82 ClientSocketPool::RespectLimits respect_limits, | 82 ClientSocketPool::RespectLimits respect_limits, |
| 83 const CompletionCallback& callback, | 83 const CompletionCallback& callback, |
| 84 PoolType* pool, | 84 PoolType* pool, |
| 85 const BoundNetLog& net_log); | 85 const NetLogWithSource& net_log); |
| 86 | 86 |
| 87 // An initialized handle can be reset, which causes it to return to the | 87 // An initialized handle can be reset, which causes it to return to the |
| 88 // un-initialized state. This releases the underlying socket, which in the | 88 // un-initialized state. This releases the underlying socket, which in the |
| 89 // case of a socket that still has an established connection, indicates that | 89 // case of a socket that still has an established connection, indicates that |
| 90 // the socket may be kept alive for use by a subsequent ClientSocketHandle. | 90 // the socket may be kept alive for use by a subsequent ClientSocketHandle. |
| 91 // | 91 // |
| 92 // NOTE: To prevent the socket from being kept alive, be sure to call its | 92 // NOTE: To prevent the socket from being kept alive, be sure to call its |
| 93 // Disconnect method. This will result in the ClientSocketPool deleting the | 93 // Disconnect method. This will result in the ClientSocketPool deleting the |
| 94 // StreamSocket. | 94 // StreamSocket. |
| 95 void Reset(); | 95 void Reset(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 // Template function implementation: | 230 // Template function implementation: |
| 231 template <typename PoolType> | 231 template <typename PoolType> |
| 232 int ClientSocketHandle::Init( | 232 int ClientSocketHandle::Init( |
| 233 const std::string& group_name, | 233 const std::string& group_name, |
| 234 const scoped_refptr<typename PoolType::SocketParams>& socket_params, | 234 const scoped_refptr<typename PoolType::SocketParams>& socket_params, |
| 235 RequestPriority priority, | 235 RequestPriority priority, |
| 236 ClientSocketPool::RespectLimits respect_limits, | 236 ClientSocketPool::RespectLimits respect_limits, |
| 237 const CompletionCallback& callback, | 237 const CompletionCallback& callback, |
| 238 PoolType* pool, | 238 PoolType* pool, |
| 239 const BoundNetLog& net_log) { | 239 const NetLogWithSource& net_log) { |
| 240 requesting_source_ = net_log.source(); | 240 requesting_source_ = net_log.source(); |
| 241 | 241 |
| 242 CHECK(!group_name.empty()); | 242 CHECK(!group_name.empty()); |
| 243 ResetInternal(true); | 243 ResetInternal(true); |
| 244 ResetErrorState(); | 244 ResetErrorState(); |
| 245 pool_ = pool; | 245 pool_ = pool; |
| 246 group_name_ = group_name; | 246 group_name_ = group_name; |
| 247 init_time_ = base::TimeTicks::Now(); | 247 init_time_ = base::TimeTicks::Now(); |
| 248 int rv = pool_->RequestSocket(group_name, &socket_params, priority, | 248 int rv = pool_->RequestSocket(group_name, &socket_params, priority, |
| 249 respect_limits, this, callback_, net_log); | 249 respect_limits, this, callback_, net_log); |
| 250 if (rv == ERR_IO_PENDING) { | 250 if (rv == ERR_IO_PENDING) { |
| 251 user_callback_ = callback; | 251 user_callback_ = callback; |
| 252 } else { | 252 } else { |
| 253 HandleInitCompletion(rv); | 253 HandleInitCompletion(rv); |
| 254 } | 254 } |
| 255 return rv; | 255 return rv; |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace net | 258 } // namespace net |
| 259 | 259 |
| 260 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 260 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| OLD | NEW |