OLD | NEW |
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_POOL_BASE_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
6 #define NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
17 #include "net/base/address_list.h" | 17 #include "net/base/address_list.h" |
18 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
19 #include "net/base/host_resolver.h" | 19 #include "net/base/host_resolver.h" |
| 20 #include "net/base/load_log.h" |
20 #include "net/base/load_states.h" | 21 #include "net/base/load_states.h" |
21 #include "net/socket/client_socket.h" | 22 #include "net/socket/client_socket.h" |
22 #include "net/socket/client_socket_pool.h" | 23 #include "net/socket/client_socket_pool.h" |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 | 26 |
26 class ClientSocketHandle; | 27 class ClientSocketHandle; |
27 class ClientSocketPoolBase; | 28 class ClientSocketPoolBase; |
28 | 29 |
29 // ConnectJob provides an abstract interface for "connecting" a socket. | 30 // ConnectJob provides an abstract interface for "connecting" a socket. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // A Request is allocated per call to RequestSocket that results in | 103 // A Request is allocated per call to RequestSocket that results in |
103 // ERR_IO_PENDING. | 104 // ERR_IO_PENDING. |
104 struct Request { | 105 struct Request { |
105 // HostResolver::RequestInfo has no default constructor, so fudge something. | 106 // HostResolver::RequestInfo has no default constructor, so fudge something. |
106 Request() | 107 Request() |
107 : handle(NULL), | 108 : handle(NULL), |
108 callback(NULL), | 109 callback(NULL), |
109 priority(0), | 110 priority(0), |
110 resolve_info(std::string(), 0) {} | 111 resolve_info(std::string(), 0) {} |
111 | 112 |
112 Request(ClientSocketHandle* handle, | 113 Request(LoadLog* load_log, |
| 114 ClientSocketHandle* handle, |
113 CompletionCallback* callback, | 115 CompletionCallback* callback, |
114 int priority, | 116 int priority, |
115 const HostResolver::RequestInfo& resolve_info) | 117 const HostResolver::RequestInfo& resolve_info) |
116 : handle(handle), callback(callback), priority(priority), | 118 : load_log(load_log), handle(handle), callback(callback), |
117 resolve_info(resolve_info) { | 119 priority(priority), resolve_info(resolve_info) { |
118 } | 120 } |
119 | 121 |
| 122 scoped_refptr<LoadLog> load_log; |
120 ClientSocketHandle* handle; | 123 ClientSocketHandle* handle; |
121 CompletionCallback* callback; | 124 CompletionCallback* callback; |
122 int priority; | 125 int priority; |
123 HostResolver::RequestInfo resolve_info; | 126 HostResolver::RequestInfo resolve_info; |
124 }; | 127 }; |
125 | 128 |
126 class ConnectJobFactory { | 129 class ConnectJobFactory { |
127 public: | 130 public: |
128 ConnectJobFactory() {} | 131 ConnectJobFactory() {} |
129 virtual ~ConnectJobFactory() {} | 132 virtual ~ConnectJobFactory() {} |
130 | 133 |
131 virtual ConnectJob* NewConnectJob( | 134 virtual ConnectJob* NewConnectJob( |
132 const std::string& group_name, | 135 const std::string& group_name, |
133 const Request& request, | 136 const Request& request, |
134 ConnectJob::Delegate* delegate) const = 0; | 137 ConnectJob::Delegate* delegate) const = 0; |
135 | 138 |
136 private: | 139 private: |
137 DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory); | 140 DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory); |
138 }; | 141 }; |
139 | 142 |
140 ClientSocketPoolBase(int max_sockets, | 143 ClientSocketPoolBase(int max_sockets, |
141 int max_sockets_per_group, | 144 int max_sockets_per_group, |
142 ConnectJobFactory* connect_job_factory); | 145 ConnectJobFactory* connect_job_factory); |
143 | 146 |
144 ~ClientSocketPoolBase(); | 147 ~ClientSocketPoolBase(); |
145 | 148 |
146 int RequestSocket(const std::string& group_name, | 149 int RequestSocket(LoadLog* load_log, |
| 150 const std::string& group_name, |
147 const HostResolver::RequestInfo& resolve_info, | 151 const HostResolver::RequestInfo& resolve_info, |
148 int priority, | 152 int priority, |
149 ClientSocketHandle* handle, | 153 ClientSocketHandle* handle, |
150 CompletionCallback* callback); | 154 CompletionCallback* callback); |
151 | 155 |
152 void CancelRequest(const std::string& group_name, | 156 void CancelRequest(const std::string& group_name, |
153 const ClientSocketHandle* handle); | 157 const ClientSocketHandle* handle); |
154 | 158 |
155 void ReleaseSocket(const std::string& group_name, | 159 void ReleaseSocket(const std::string& group_name, |
156 ClientSocket* socket); | 160 ClientSocket* socket); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 344 |
341 // Controls whether or not we use late binding of sockets. | 345 // Controls whether or not we use late binding of sockets. |
342 static bool g_late_binding; | 346 static bool g_late_binding; |
343 | 347 |
344 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 348 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
345 }; | 349 }; |
346 | 350 |
347 } // namespace net | 351 } // namespace net |
348 | 352 |
349 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 353 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |