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

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

Issue 2994003: Refactor how ClientSocketPoolBaseHelper avoids re-entrancy. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Merge. Created 10 years, 5 months 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
« no previous file with comments | « net/http/http_proxy_client_socket_pool.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) 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // NOTE: To prevent the socket from being kept alive, be sure to call its 84 // NOTE: To prevent the socket from being kept alive, be sure to call its
85 // Disconnect method. This will result in the ClientSocketPool deleting the 85 // Disconnect method. This will result in the ClientSocketPool deleting the
86 // ClientSocket. 86 // ClientSocket.
87 void Reset(); 87 void Reset();
88 88
89 // Used after Init() is called, but before the ClientSocketPool has 89 // Used after Init() is called, but before the ClientSocketPool has
90 // initialized the ClientSocketHandle. 90 // initialized the ClientSocketHandle.
91 LoadState GetLoadState() const; 91 LoadState GetLoadState() const;
92 92
93 // Returns true when Init() has completed successfully. 93 // Returns true when Init() has completed successfully.
94 bool is_initialized() const { return socket_ != NULL; } 94 bool is_initialized() const { return is_initialized_; }
95 95
96 // Returns the time tick when Init() was called. 96 // Returns the time tick when Init() was called.
97 base::TimeTicks init_time() const { return init_time_; } 97 base::TimeTicks init_time() const { return init_time_; }
98 98
99 // Returns the time between Init() and when is_initialized() becomes true. 99 // Returns the time between Init() and when is_initialized() becomes true.
100 base::TimeDelta setup_time() const { return setup_time_; } 100 base::TimeDelta setup_time() const { return setup_time_; }
101 101
102 // Used by ClientSocketPool to initialize the ClientSocketHandle. 102 // Used by ClientSocketPool to initialize the ClientSocketHandle.
103 void set_is_reused(bool is_reused) { is_reused_ = is_reused; } 103 void set_is_reused(bool is_reused) { is_reused_ = is_reused; }
104 void set_socket(ClientSocket* s) { socket_.reset(s); } 104 void set_socket(ClientSocket* s) { socket_.reset(s); }
105 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } 105 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; }
106 void set_pool_id(int id) { pool_id_ = id; } 106 void set_pool_id(int id) { pool_id_ = id; }
107 void set_tunnel_auth_response_info( 107 void set_tunnel_auth_response_info(
108 const scoped_refptr<HttpResponseHeaders>& headers, 108 const scoped_refptr<HttpResponseHeaders>& headers,
109 const scoped_refptr<AuthChallengeInfo>& auth_challenge) { 109 const scoped_refptr<AuthChallengeInfo>& auth_challenge) {
110 tunnel_auth_response_info_.headers = headers; 110 tunnel_auth_response_info_.headers = headers;
111 tunnel_auth_response_info_.auth_challenge = auth_challenge; 111 tunnel_auth_response_info_.auth_challenge = auth_challenge;
112 } 112 }
113 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } 113 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; }
114 114
115 // These may only be used if is_initialized() is true. 115 // These may only be used if is_initialized() is true.
116 const std::string& group_name() const { return group_name_; } 116 const std::string& group_name() const { return group_name_; }
117 int id() const { return pool_id_; }
117 ClientSocket* socket() { return socket_.get(); } 118 ClientSocket* socket() { return socket_.get(); }
118 ClientSocket* release_socket() { return socket_.release(); } 119 ClientSocket* release_socket() { return socket_.release(); }
119 const HttpResponseInfo& tunnel_auth_response_info() const { 120 const HttpResponseInfo& tunnel_auth_response_info() const {
120 return tunnel_auth_response_info_; 121 return tunnel_auth_response_info_;
121 } 122 }
122 // Only valid if there is no |socket_|. 123 // Only valid if there is no |socket_|.
123 bool is_ssl_error() const { 124 bool is_ssl_error() const {
124 DCHECK(socket_.get() == NULL); 125 DCHECK(socket_.get() == NULL);
125 return is_ssl_error_; 126 return is_ssl_error_;
126 } 127 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void HandleInitCompletion(int result); 159 void HandleInitCompletion(int result);
159 160
160 // Resets the state of the ClientSocketHandle. |cancel| indicates whether or 161 // Resets the state of the ClientSocketHandle. |cancel| indicates whether or
161 // not to try to cancel the request with the ClientSocketPool. Does not 162 // not to try to cancel the request with the ClientSocketPool. Does not
162 // reset the supplemental error state. 163 // reset the supplemental error state.
163 void ResetInternal(bool cancel); 164 void ResetInternal(bool cancel);
164 165
165 // Resets the supplemental error state. 166 // Resets the supplemental error state.
166 void ResetErrorState(); 167 void ResetErrorState();
167 168
169 bool is_initialized_;
168 scoped_refptr<ClientSocketPool> pool_; 170 scoped_refptr<ClientSocketPool> pool_;
169 scoped_ptr<ClientSocket> socket_; 171 scoped_ptr<ClientSocket> socket_;
170 std::string group_name_; 172 std::string group_name_;
171 bool is_reused_; 173 bool is_reused_;
172 CompletionCallbackImpl<ClientSocketHandle> callback_; 174 CompletionCallbackImpl<ClientSocketHandle> callback_;
173 CompletionCallback* user_callback_; 175 CompletionCallback* user_callback_;
174 base::TimeDelta idle_time_; 176 base::TimeDelta idle_time_;
175 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. 177 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation.
176 bool is_ssl_error_; 178 bool is_ssl_error_;
177 HttpResponseInfo tunnel_auth_response_info_; 179 HttpResponseInfo tunnel_auth_response_info_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 user_callback_ = callback; 211 user_callback_ = callback;
210 } else { 212 } else {
211 HandleInitCompletion(rv); 213 HandleInitCompletion(rv);
212 } 214 }
213 return rv; 215 return rv;
214 } 216 }
215 217
216 } // namespace net 218 } // namespace net
217 219
218 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ 220 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool.cc ('k') | net/socket/client_socket_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698