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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual ~TCPConnectJob(); | 30 virtual ~TCPConnectJob(); |
31 | 31 |
32 // ConnectJob methods. | 32 // ConnectJob methods. |
33 | 33 |
34 // Begins the host resolution and the TCP connect. Returns OK on success | 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. | 35 // and ERR_IO_PENDING if it cannot immediately service the request. |
36 // Otherwise, it returns a net error code. | 36 // Otherwise, it returns a net error code. |
37 virtual int Connect(); | 37 virtual int Connect(); |
38 | 38 |
39 private: | 39 private: |
40 // Handles asynchronous completion of IO. |result| represents the result of | 40 enum State { |
41 // the IO operation. | 41 kStateResolveHost, |
| 42 kStateResolveHostComplete, |
| 43 kStateTCPConnect, |
| 44 kStateTCPConnectComplete, |
| 45 kStateNone, |
| 46 }; |
| 47 |
42 void OnIOComplete(int result); | 48 void OnIOComplete(int result); |
43 | 49 |
44 // Handles both asynchronous and synchronous completion of IO. |result| | 50 // Runs the state transition loop. |
45 // represents the result of the IO operation. |synchronous| indicates | 51 int DoLoop(int result); |
46 // whether or not the previous IO operation completed synchronously or | |
47 // asynchronously. OnIOCompleteInternal returns the result of the next IO | |
48 // operation that executes, or just the value of |result|. | |
49 int OnIOCompleteInternal(int result, bool synchronous); | |
50 | 52 |
51 const std::string group_name_; | 53 int DoResolveHost(); |
| 54 int DoResolveHostComplete(int result); |
| 55 int DoTCPConnect(); |
| 56 int DoTCPConnectComplete(int result); |
| 57 |
52 const HostResolver::RequestInfo resolve_info_; | 58 const HostResolver::RequestInfo resolve_info_; |
53 const ClientSocketHandle* const handle_; | |
54 ClientSocketFactory* const client_socket_factory_; | 59 ClientSocketFactory* const client_socket_factory_; |
55 CompletionCallbackImpl<TCPConnectJob> callback_; | 60 CompletionCallbackImpl<TCPConnectJob> callback_; |
56 scoped_ptr<ClientSocket> socket_; | |
57 Delegate* const delegate_; | |
58 SingleRequestHostResolver resolver_; | 61 SingleRequestHostResolver resolver_; |
59 AddressList addresses_; | 62 AddressList addresses_; |
| 63 State next_state_; |
60 | 64 |
61 // The time the Connect() method was called (if it got called). | 65 // The time the Connect() method was called (if it got called). |
62 base::TimeTicks connect_start_time_; | 66 base::TimeTicks connect_start_time_; |
63 | 67 |
64 DISALLOW_COPY_AND_ASSIGN(TCPConnectJob); | 68 DISALLOW_COPY_AND_ASSIGN(TCPConnectJob); |
65 }; | 69 }; |
66 | 70 |
67 class TCPClientSocketPool : public ClientSocketPool { | 71 class TCPClientSocketPool : public ClientSocketPool { |
68 public: | 72 public: |
69 TCPClientSocketPool(int max_sockets_per_group, | 73 TCPClientSocketPool(int max_sockets_per_group, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // the posting of the task and the execution, then we'll hit the DCHECK that | 132 // the posting of the task and the execution, then we'll hit the DCHECK that |
129 // |ClientSocketPoolBase::group_map_| is empty. | 133 // |ClientSocketPoolBase::group_map_| is empty. |
130 scoped_refptr<ClientSocketPoolBase> base_; | 134 scoped_refptr<ClientSocketPoolBase> base_; |
131 | 135 |
132 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketPool); | 136 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketPool); |
133 }; | 137 }; |
134 | 138 |
135 } // namespace net | 139 } // namespace net |
136 | 140 |
137 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ | 141 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |