| 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_TCP_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ |
| 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/time.h" |
| 14 #include "base/timer.h" |
| 13 #include "net/socket/client_socket_pool_base.h" | 15 #include "net/socket/client_socket_pool_base.h" |
| 14 #include "net/socket/client_socket_pool.h" | 16 #include "net/socket/client_socket_pool.h" |
| 15 | 17 |
| 16 namespace net { | 18 namespace net { |
| 17 | 19 |
| 18 class ClientSocketFactory; | 20 class ClientSocketFactory; |
| 19 | 21 |
| 20 // TCPConnectJob handles the host resolution necessary for socket creation | 22 // TCPConnectJob handles the host resolution necessary for socket creation |
| 21 // and the tcp connect. | 23 // and the tcp connect. |
| 22 class TCPConnectJob : public ConnectJob { | 24 class TCPConnectJob : public ConnectJob { |
| 23 public: | 25 public: |
| 24 TCPConnectJob(const std::string& group_name, | 26 TCPConnectJob(const std::string& group_name, |
| 25 const HostResolver::RequestInfo& resolve_info, | 27 const HostResolver::RequestInfo& resolve_info, |
| 26 const ClientSocketHandle* handle, | 28 const ClientSocketHandle* handle, |
| 29 base::TimeDelta timeout_duration, |
| 27 ClientSocketFactory* client_socket_factory, | 30 ClientSocketFactory* client_socket_factory, |
| 28 HostResolver* host_resolver, | 31 HostResolver* host_resolver, |
| 29 Delegate* delegate); | 32 Delegate* delegate); |
| 30 virtual ~TCPConnectJob(); | 33 virtual ~TCPConnectJob(); |
| 31 | 34 |
| 32 // ConnectJob methods. | 35 // ConnectJob methods. |
| 33 | 36 |
| 34 // Begins the host resolution and the TCP connect. Returns OK on success | |
| 35 // and ERR_IO_PENDING if it cannot immediately service the request. | |
| 36 // Otherwise, it returns a net error code. | |
| 37 virtual int Connect(); | |
| 38 | |
| 39 private: | 37 private: |
| 40 enum State { | 38 enum State { |
| 41 kStateResolveHost, | 39 kStateResolveHost, |
| 42 kStateResolveHostComplete, | 40 kStateResolveHostComplete, |
| 43 kStateTCPConnect, | 41 kStateTCPConnect, |
| 44 kStateTCPConnectComplete, | 42 kStateTCPConnectComplete, |
| 45 kStateNone, | 43 kStateNone, |
| 46 }; | 44 }; |
| 47 | 45 |
| 46 // Begins the host resolution and the TCP connect. Returns OK on success |
| 47 // and ERR_IO_PENDING if it cannot immediately service the request. |
| 48 // Otherwise, it returns a net error code. |
| 49 virtual int ConnectInternal(); |
| 50 |
| 48 void OnIOComplete(int result); | 51 void OnIOComplete(int result); |
| 49 | 52 |
| 50 // Runs the state transition loop. | 53 // Runs the state transition loop. |
| 51 int DoLoop(int result); | 54 int DoLoop(int result); |
| 52 | 55 |
| 53 int DoResolveHost(); | 56 int DoResolveHost(); |
| 54 int DoResolveHostComplete(int result); | 57 int DoResolveHostComplete(int result); |
| 55 int DoTCPConnect(); | 58 int DoTCPConnect(); |
| 56 int DoTCPConnectComplete(int result); | 59 int DoTCPConnectComplete(int result); |
| 57 | 60 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // the posting of the task and the execution, then we'll hit the DCHECK that | 136 // the posting of the task and the execution, then we'll hit the DCHECK that |
| 134 // |ClientSocketPoolBase::group_map_| is empty. | 137 // |ClientSocketPoolBase::group_map_| is empty. |
| 135 scoped_refptr<ClientSocketPoolBase> base_; | 138 scoped_refptr<ClientSocketPoolBase> base_; |
| 136 | 139 |
| 137 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketPool); | 140 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketPool); |
| 138 }; | 141 }; |
| 139 | 142 |
| 140 } // namespace net | 143 } // namespace net |
| 141 | 144 |
| 142 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ | 145 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |