Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: net/socket/client_socket_handle.h

Issue 8898036: base::Bind: Convert proxy_resolving_client_socket.[cc,h] and deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Possible test fix. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_service_unittest.cc ('k') | net/socket/client_socket_handle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // to allow the caller to determine what went wrong. 67 // to allow the caller to determine what went wrong.
68 // 68 //
69 // Init may be called multiple times. 69 // Init may be called multiple times.
70 // 70 //
71 // Profiling information for the request is saved to |net_log| if non-NULL. 71 // Profiling information for the request is saved to |net_log| if non-NULL.
72 // 72 //
73 template <typename SocketParams, typename PoolType> 73 template <typename SocketParams, typename PoolType>
74 int Init(const std::string& group_name, 74 int Init(const std::string& group_name,
75 const scoped_refptr<SocketParams>& socket_params, 75 const scoped_refptr<SocketParams>& socket_params,
76 RequestPriority priority, 76 RequestPriority priority,
77 OldCompletionCallback* callback, 77 const CompletionCallback& callback,
78 PoolType* pool, 78 PoolType* pool,
79 const BoundNetLog& net_log); 79 const BoundNetLog& net_log);
80 80
81 // An initialized handle can be reset, which causes it to return to the 81 // An initialized handle can be reset, which causes it to return to the
82 // un-initialized state. This releases the underlying socket, which in the 82 // un-initialized state. This releases the underlying socket, which in the
83 // case of a socket that still has an established connection, indicates that 83 // case of a socket that still has an established connection, indicates that
84 // the socket may be kept alive for use by a subsequent ClientSocketHandle. 84 // the socket may be kept alive for use by a subsequent ClientSocketHandle.
85 // 85 //
86 // NOTE: To prevent the socket from being kept alive, be sure to call its 86 // NOTE: To prevent the socket from being kept alive, be sure to call its
87 // Disconnect method. This will result in the ClientSocketPool deleting the 87 // Disconnect method. This will result in the ClientSocketPool deleting the
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Resets the supplemental error state. 166 // Resets the supplemental error state.
167 void ResetErrorState(); 167 void ResetErrorState();
168 168
169 bool is_initialized_; 169 bool is_initialized_;
170 ClientSocketPool* pool_; 170 ClientSocketPool* pool_;
171 LayeredPool* layered_pool_; 171 LayeredPool* layered_pool_;
172 scoped_ptr<StreamSocket> socket_; 172 scoped_ptr<StreamSocket> socket_;
173 std::string group_name_; 173 std::string group_name_;
174 bool is_reused_; 174 bool is_reused_;
175 OldCompletionCallbackImpl<ClientSocketHandle> callback_; 175 OldCompletionCallbackImpl<ClientSocketHandle> callback_;
176 OldCompletionCallback* user_callback_; 176 CompletionCallback user_callback_;
177 base::TimeDelta idle_time_; 177 base::TimeDelta idle_time_;
178 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. 178 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation.
179 bool is_ssl_error_; 179 bool is_ssl_error_;
180 HttpResponseInfo ssl_error_response_info_; 180 HttpResponseInfo ssl_error_response_info_;
181 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; 181 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_;
182 base::TimeTicks init_time_; 182 base::TimeTicks init_time_;
183 base::TimeDelta setup_time_; 183 base::TimeDelta setup_time_;
184 184
185 NetLog::Source requesting_source_; 185 NetLog::Source requesting_source_;
186 186
187 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); 187 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle);
188 }; 188 };
189 189
190 // Template function implementation: 190 // Template function implementation:
191 template <typename SocketParams, typename PoolType> 191 template <typename SocketParams, typename PoolType>
192 int ClientSocketHandle::Init(const std::string& group_name, 192 int ClientSocketHandle::Init(const std::string& group_name,
193 const scoped_refptr<SocketParams>& socket_params, 193 const scoped_refptr<SocketParams>& socket_params,
194 RequestPriority priority, 194 RequestPriority priority,
195 OldCompletionCallback* callback, 195 const CompletionCallback& callback,
196 PoolType* pool, 196 PoolType* pool,
197 const BoundNetLog& net_log) { 197 const BoundNetLog& net_log) {
198 requesting_source_ = net_log.source(); 198 requesting_source_ = net_log.source();
199 199
200 CHECK(!group_name.empty()); 200 CHECK(!group_name.empty());
201 // Note that this will result in a compile error if the SocketParams has not 201 // Note that this will result in a compile error if the SocketParams has not
202 // been registered for the PoolType via REGISTER_SOCKET_PARAMS_FOR_POOL 202 // been registered for the PoolType via REGISTER_SOCKET_PARAMS_FOR_POOL
203 // (defined in client_socket_pool.h). 203 // (defined in client_socket_pool.h).
204 CheckIsValidSocketParamsForPool<PoolType, SocketParams>(); 204 CheckIsValidSocketParamsForPool<PoolType, SocketParams>();
205 ResetInternal(true); 205 ResetInternal(true);
206 ResetErrorState(); 206 ResetErrorState();
207 pool_ = pool; 207 pool_ = pool;
208 group_name_ = group_name; 208 group_name_ = group_name;
209 init_time_ = base::TimeTicks::Now(); 209 init_time_ = base::TimeTicks::Now();
210 int rv = pool_->RequestSocket( 210 int rv = pool_->RequestSocket(
211 group_name, &socket_params, priority, this, &callback_, net_log); 211 group_name, &socket_params, priority, this, &callback_, net_log);
212 if (rv == ERR_IO_PENDING) { 212 if (rv == ERR_IO_PENDING) {
213 user_callback_ = callback; 213 user_callback_ = callback;
214 } else { 214 } else {
215 HandleInitCompletion(rv); 215 HandleInitCompletion(rv);
216 } 216 }
217 return rv; 217 return rv;
218 } 218 }
219 219
220 } // namespace net 220 } // namespace net
221 221
222 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ 222 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_
OLDNEW
« no previous file with comments | « net/proxy/proxy_service_unittest.cc ('k') | net/socket/client_socket_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698