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

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

Issue 848006: Generalize the net module's LoadLog facility from a passive container, to an event stream (NetLog). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Split up RequestTracker into ConnectJobTracker+RequestTracker+RequestTrackerBase, address comments Created 10 years, 9 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/socket/client_socket.h ('k') | net/socket/client_socket_pool.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // otherwise it will be set to a new connected socket. Consumers can then 48 // otherwise it will be set to a new connected socket. Consumers can then
49 // call is_reused() to see if the socket was reused. If not reusing an 49 // call is_reused() to see if the socket was reused. If not reusing an
50 // existing socket, ClientSocketPool may need to establish a new 50 // existing socket, ClientSocketPool may need to establish a new
51 // connection using |socket_params|. 51 // connection using |socket_params|.
52 // 52 //
53 // This method returns ERR_IO_PENDING if it cannot complete synchronously, in 53 // This method returns ERR_IO_PENDING if it cannot complete synchronously, in
54 // which case the consumer will be notified of completion via |callback|. 54 // which case the consumer will be notified of completion via |callback|.
55 // 55 //
56 // Init may be called multiple times. 56 // Init may be called multiple times.
57 // 57 //
58 // Profiling information for the request is saved to |load_log| if non-NULL. 58 // Profiling information for the request is saved to |net_log| if non-NULL.
59 // 59 //
60 template <typename SocketParams, typename PoolType> 60 template <typename SocketParams, typename PoolType>
61 int Init(const std::string& group_name, 61 int Init(const std::string& group_name,
62 const SocketParams& socket_params, 62 const SocketParams& socket_params,
63 RequestPriority priority, 63 RequestPriority priority,
64 CompletionCallback* callback, 64 CompletionCallback* callback,
65 PoolType* pool, 65 PoolType* pool,
66 LoadLog* load_log); 66 const BoundNetLog& net_log);
67 67
68 // An initialized handle can be reset, which causes it to return to the 68 // An initialized handle can be reset, which causes it to return to the
69 // un-initialized state. This releases the underlying socket, which in the 69 // un-initialized state. This releases the underlying socket, which in the
70 // case of a socket that still has an established connection, indicates that 70 // case of a socket that still has an established connection, indicates that
71 // the socket may be kept alive for use by a subsequent ClientSocketHandle. 71 // the socket may be kept alive for use by a subsequent ClientSocketHandle.
72 // 72 //
73 // NOTE: To prevent the socket from being kept alive, be sure to call its 73 // NOTE: To prevent the socket from being kept alive, be sure to call its
74 // Disconnect method. This will result in the ClientSocketPool deleting the 74 // Disconnect method. This will result in the ClientSocketPool deleting the
75 // ClientSocket. 75 // ClientSocket.
76 void Reset(); 76 void Reset();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle); 143 DISALLOW_COPY_AND_ASSIGN(ClientSocketHandle);
144 }; 144 };
145 145
146 // Template function implementation: 146 // Template function implementation:
147 template <typename SocketParams, typename PoolType> 147 template <typename SocketParams, typename PoolType>
148 int ClientSocketHandle::Init(const std::string& group_name, 148 int ClientSocketHandle::Init(const std::string& group_name,
149 const SocketParams& socket_params, 149 const SocketParams& socket_params,
150 RequestPriority priority, 150 RequestPriority priority,
151 CompletionCallback* callback, 151 CompletionCallback* callback,
152 PoolType* pool, 152 PoolType* pool,
153 LoadLog* load_log) { 153 const BoundNetLog& net_log) {
154 CHECK(!group_name.empty()); 154 CHECK(!group_name.empty());
155 // Note that this will result in a link error if the SocketParams has not been 155 // Note that this will result in a link error if the SocketParams has not been
156 // registered for the PoolType via REGISTER_SOCKET_PARAMS_FOR_POOL (defined in 156 // registered for the PoolType via REGISTER_SOCKET_PARAMS_FOR_POOL (defined in
157 // client_socket_pool.h). 157 // client_socket_pool.h).
158 CheckIsValidSocketParamsForPool<PoolType, SocketParams>(); 158 CheckIsValidSocketParamsForPool<PoolType, SocketParams>();
159 ResetInternal(true); 159 ResetInternal(true);
160 pool_ = pool; 160 pool_ = pool;
161 group_name_ = group_name; 161 group_name_ = group_name;
162 init_time_ = base::TimeTicks::Now(); 162 init_time_ = base::TimeTicks::Now();
163 int rv = pool_->RequestSocket( 163 int rv = pool_->RequestSocket(
164 group_name, &socket_params, priority, this, &callback_, load_log); 164 group_name, &socket_params, priority, this, &callback_, net_log);
165 if (rv == ERR_IO_PENDING) { 165 if (rv == ERR_IO_PENDING) {
166 user_callback_ = callback; 166 user_callback_ = callback;
167 } else { 167 } else {
168 HandleInitCompletion(rv); 168 HandleInitCompletion(rv);
169 } 169 }
170 return rv; 170 return rv;
171 } 171 }
172 172
173 } // namespace net 173 } // namespace net
174 174
175 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ 175 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_
OLDNEW
« no previous file with comments | « net/socket/client_socket.h ('k') | net/socket/client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698