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

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: Fix a header or two 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
« no previous file with comments | « net/net.gyp ('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) 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/load_timing_info.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 #include "net/base/net_export.h" 18 #include "net/base/net_export.h"
18 #include "net/base/net_log.h" 19 #include "net/base/net_log.h"
19 #include "net/base/request_priority.h" 20 #include "net/base/request_priority.h"
20 #include "net/http/http_response_info.h" 21 #include "net/http/http_response_info.h"
21 #include "net/socket/client_socket_pool.h" 22 #include "net/socket/client_socket_pool.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
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 100
100 // Returns true when Init() has completed successfully. 101 // Returns true when Init() has completed successfully.
101 bool is_initialized() const { return is_initialized_; } 102 bool is_initialized() const { return is_initialized_; }
102 103
103 // Returns the time tick when Init() was called. 104 // Returns the time tick when Init() was called.
104 base::TimeTicks init_time() const { return init_time_; } 105 base::TimeTicks init_time() const { return init_time_; }
105 106
106 // Returns the time between Init() and when is_initialized() becomes true. 107 // Returns the time between Init() and when is_initialized() becomes true.
107 base::TimeDelta setup_time() const { return setup_time_; } 108 base::TimeDelta setup_time() const { return setup_time_; }
108 109
110 // Sets the portion of LoadTimingInfo related to connection establishment, and
111 // the socket id. |is_reused| is needed because the handle may not have full
112 // reuse information. |load_timing_info| must have all default values when
113 // called. Returns false and makes no changes to |load_timing_info| when
114 // |socket_| is NULL.
115 bool GetLoadTimingInfo(bool is_reused,
116 LoadTimingInfo* load_timing_info) const;
117
109 // Used by ClientSocketPool to initialize the ClientSocketHandle. 118 // Used by ClientSocketPool to initialize the ClientSocketHandle.
110 void set_is_reused(bool is_reused) { is_reused_ = is_reused; } 119 void set_is_reused(bool is_reused) { is_reused_ = is_reused; }
111 void set_socket(StreamSocket* s) { socket_.reset(s); } 120 void set_socket(StreamSocket* s) { socket_.reset(s); }
112 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; } 121 void set_idle_time(base::TimeDelta idle_time) { idle_time_ = idle_time; }
113 void set_pool_id(int id) { pool_id_ = id; } 122 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; } 123 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) { 124 void set_ssl_error_response_info(const HttpResponseInfo& ssl_error_state) {
116 ssl_error_response_info_ = ssl_error_state; 125 ssl_error_response_info_ = ssl_error_state;
117 } 126 }
118 void set_pending_http_proxy_connection(ClientSocketHandle* connection) { 127 void set_pending_http_proxy_connection(ClientSocketHandle* connection) {
(...skipping 24 matching lines...) Expand all
143 base::TimeDelta idle_time() const { return idle_time_; } 152 base::TimeDelta idle_time() const { return idle_time_; }
144 SocketReuseType reuse_type() const { 153 SocketReuseType reuse_type() const {
145 if (is_reused()) { 154 if (is_reused()) {
146 return REUSED_IDLE; 155 return REUSED_IDLE;
147 } else if (idle_time() == base::TimeDelta()) { 156 } else if (idle_time() == base::TimeDelta()) {
148 return UNUSED; 157 return UNUSED;
149 } else { 158 } else {
150 return UNUSED_IDLE; 159 return UNUSED_IDLE;
151 } 160 }
152 } 161 }
162 const LoadTimingInfo::ConnectTiming& connect_timing() const {
163 return connect_timing_;
164 }
165 void set_connect_timing(const LoadTimingInfo::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 LoadTimingInfo::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
« no previous file with comments | « net/net.gyp ('k') | net/socket/client_socket_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698