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

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

Issue 11428150: LoadTiming implementation in net, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: tiny typo fix Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
15 #include "net/base/load_states.h" 15 #include "net/base/load_states.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
18 #include "net/base/net_log.h" 18 #include "net/base/net_log.h"
19 #include "net/base/request_priority.h" 19 #include "net/base/request_priority.h"
20 #include "net/http/http_response_info.h" 20 #include "net/http/http_response_info.h"
21 #include "net/socket/client_socket_pool.h" 21 #include "net/socket/client_socket_pool.h"
22 #include "net/socket/connect_timing.h"
22 #include "net/socket/stream_socket.h" 23 #include "net/socket/stream_socket.h"
23 24
24 namespace net { 25 namespace net {
25 26
27 struct LoadTimingInfo;
28
26 // A container for a StreamSocket. 29 // A container for a StreamSocket.
27 // 30 //
28 // The handle's |group_name| uniquely identifies the origin and type of the 31 // The handle's |group_name| uniquely identifies the origin and type of the
29 // connection. It is used by the ClientSocketPool to group similar connected 32 // connection. It is used by the ClientSocketPool to group similar connected
30 // client socket objects. 33 // client socket objects.
31 // 34 //
32 class NET_EXPORT ClientSocketHandle { 35 class NET_EXPORT ClientSocketHandle {
33 public: 36 public:
34 enum SocketReuseType { 37 enum SocketReuseType {
35 UNUSED = 0, // unused socket that just finished connecting 38 UNUSED = 0, // unused socket that just finished connecting
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 102
100 // Returns true when Init() has completed successfully. 103 // Returns true when Init() has completed successfully.
101 bool is_initialized() const { return is_initialized_; } 104 bool is_initialized() const { return is_initialized_; }
102 105
103 // Returns the time tick when Init() was called. 106 // Returns the time tick when Init() was called.
104 base::TimeTicks init_time() const { return init_time_; } 107 base::TimeTicks init_time() const { return init_time_; }
105 108
106 // Returns the time between Init() and when is_initialized() becomes true. 109 // Returns the time between Init() and when is_initialized() becomes true.
107 base::TimeDelta setup_time() const { return setup_time_; } 110 base::TimeDelta setup_time() const { return setup_time_; }
108 111
112 // Sets the portion of LoadTimingInfo related to connection establishment, and
113 // the socket id. |is_reused| is needed because the handle may not have full
114 // reuse information. |load_timing_info| must have all default values when
115 // called. Returns false and makes no changes to |load_timing_info| when
116 // |socket_| is NULL.
117 bool GetLoadTimingInfo(bool is_reused,
118 LoadTimingInfo* load_timing_info) const;
119
109 // Used by ClientSocketPool to initialize the ClientSocketHandle. 120 // Used by ClientSocketPool to initialize the ClientSocketHandle.
110 void set_is_reused(bool is_reused) { is_reused_ = is_reused; } 121 void set_is_reused(bool is_reused) { is_reused_ = is_reused; }
111 void set_socket(StreamSocket* s) { socket_.reset(s); } 122 void set_socket(StreamSocket* s) { socket_.reset(s); }
112 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } 123 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; }
113 void set_pool_id(int id) { pool_id_ = id; } 124 void set_pool_id(int id) { pool_id_ = id; }
114 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; } 125 void set_is_ssl_error(bool is_ssl_error) { is_ssl_error_ = is_ssl_error; }
115 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) { 126 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) {
116 ssl_error_response_info_ = ssl_error_state; 127 ssl_error_response_info_ = ssl_error_state;
117 } 128 }
118 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { 129 void set_pending_http_proxy_connection(ClientSocketHandle* connection) {
(...skipping 24 matching lines...) Expand all
143 base::TimeDelta idle_time() const { return idle_time_; } 154 base::TimeDelta idle_time() const { return idle_time_; }
144 SocketReuseType reuse_type() const { 155 SocketReuseType reuse_type() const {
145 if (is_reused()) { 156 if (is_reused()) {
146 return REUSED_IDLE; 157 return REUSED_IDLE;
147 } else if (idle_time() == base::TimeDelta()) { 158 } else if (idle_time() == base::TimeDelta()) {
148 return UNUSED; 159 return UNUSED;
149 } else { 160 } else {
150 return UNUSED_IDLE; 161 return UNUSED_IDLE;
151 } 162 }
152 } 163 }
164 const ConnectTiming& connect_timing() const { return connect_timing_; }
165 void set_connect_timing(const ConnectTiming& connect_timing) {
166 connect_timing_ = connect_timing;
167 }
153 168
154 private: 169 private:
155 // Called on asynchronous completion of an Init() request. 170 // Called on asynchronous completion of an Init() request.
156 void OnIOComplete(int result); 171 void OnIOComplete(int result);
157 172
158 // Called on completion (both asynchronous & synchronous) of an Init() 173 // Called on completion (both asynchronous & synchronous) of an Init()
159 // request. 174 // request.
160 void HandleInitCompletion(int result); 175 void HandleInitCompletion(int result);
161 176
162 // Resets the state of the ClientSocketHandle. |cancel| indicates whether or 177 // Resets the state of the ClientSocketHandle. |cancel| indicates whether or
(...skipping 15 matching lines...) Expand all
178 base::TimeDelta idle_time_; 193 base::TimeDelta idle_time_;
179 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation. 194 int pool_id_; // See ClientSocketPool::ReleaseSocket() for an explanation.
180 bool is_ssl_error_; 195 bool is_ssl_error_;
181 HttpResponseInfo ssl_error_response_info_; 196 HttpResponseInfo ssl_error_response_info_;
182 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_; 197 scoped_ptr<ClientSocketHandle> pending_http_proxy_connection_;
183 base::TimeTicks init_time_; 198 base::TimeTicks init_time_;
184 base::TimeDelta setup_time_; 199 base::TimeDelta setup_time_;
185 200
186 NetLog::Source requesting_source_; 201 NetLog::Source requesting_source_;
187 202
203 // Timing information is set when a connection is successfully established.
204 ConnectTiming connect_timing_;
205
188 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); 206 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle);
189 }; 207 };
190 208
191 // Template function implementation: 209 // Template function implementation:
192 template <typename SocketParams, typename PoolType> 210 template <typename SocketParams, typename PoolType>
193 int ClientSocketHandle::Init(const std::string& group_name, 211 int ClientSocketHandle::Init(const std::string& group_name,
194 const scoped_refptr<SocketParams>& socket_params, 212 const scoped_refptr<SocketParams>& socket_params,
195 RequestPriority priority, 213 RequestPriority priority,
196 const CompletionCallback& callback, 214 const CompletionCallback& callback,
197 PoolType* pool, 215 PoolType* pool,
(...skipping 16 matching lines...) Expand all
214 user_callback_ = callback; 232 user_callback_ = callback;
215 } else { 233 } else {
216 HandleInitCompletion(rv); 234 HandleInitCompletion(rv);
217 } 235 }
218 return rv; 236 return rv;
219 } 237 }
220 238
221 } // namespace net 239 } // namespace net
222 240
223 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ 241 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698