OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_SOCKET_WEBSOCKET_TRANSPORT_CONNECT_SUB_JOB_H_ | |
6 #define NET_SOCKET_WEBSOCKET_TRANSPORT_CONNECT_SUB_JOB_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/containers/linked_list.h" | |
tyoshino (SeeGerritForStatus)
2014/06/20 12:12:07
remove
Adam Rice
2014/06/23 10:06:26
Done.
| |
10 #include "base/macros.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "net/base/address_list.h" | |
13 #include "net/base/load_states.h" | |
14 #include "net/socket/websocket_endpoint_lock_manager.h" | |
15 #include "net/socket/websocket_transport_client_socket_pool.h" | |
16 | |
17 namespace net { | |
18 | |
19 class BoundNetLog; | |
20 class ClientSocketFactory; | |
21 class IPEndPoint; | |
22 class StreamSocket; | |
23 | |
24 // Attempts to connect to a subset of the addresses required by a | |
25 // WebSocketTransportConnectJob, specifically either the IPv4 or IPv6 | |
26 // addresses. Each address is tried in turn, and parent_job->OnSubJobComplete() | |
27 // is called when the first address succeeds or the last address fails. | |
28 class WebSocketTransportConnectSubJob | |
29 : public WebSocketEndpointLockManager::Waiter { | |
30 public: | |
31 typedef WebSocketTransportConnectJob::SubJobType SubJobType; | |
32 | |
33 WebSocketTransportConnectSubJob(const AddressList& addresses, | |
34 WebSocketTransportConnectJob* parent_job, | |
35 SubJobType type); | |
36 | |
37 virtual ~WebSocketTransportConnectSubJob(); | |
38 | |
39 // Start connecting. | |
40 int Start(); | |
41 | |
42 bool started() { return next_state_ != STATE_NONE; } | |
43 | |
44 LoadState GetLoadState() const; | |
45 | |
46 SubJobType type() const { return type_; } | |
47 | |
48 scoped_ptr<StreamSocket> PassSocket() { return transport_socket_.Pass(); } | |
49 | |
50 // Implementation of WebSocketEndpointLockManager::EndpointWaiter. | |
51 virtual void GotEndpointLock() OVERRIDE; | |
52 | |
53 private: | |
54 enum State { | |
55 STATE_NONE, | |
56 STATE_OBTAIN_LOCK, | |
57 STATE_OBTAIN_LOCK_COMPLETE, | |
58 STATE_TRANSPORT_CONNECT, | |
59 STATE_TRANSPORT_CONNECT_COMPLETE, | |
60 }; | |
61 | |
62 ClientSocketFactory* client_socket_factory() const; | |
63 | |
64 const BoundNetLog& net_log() const; | |
65 | |
66 const IPEndPoint& CurrentAddress() const; | |
67 | |
68 void OnIOComplete(int result); | |
69 int DoLoop(int result); | |
70 int DoEndpointLock(); | |
71 int DoEndpointLockComplete(); | |
72 int DoTransportConnect(); | |
73 int DoTransportConnectComplete(int result); | |
74 | |
75 WebSocketTransportConnectJob* const parent_job_; | |
76 | |
77 const AddressList addresses_; | |
78 size_t current_address_index_; | |
79 | |
80 State next_state_; | |
81 const SubJobType type_; | |
82 | |
83 scoped_ptr<StreamSocket> transport_socket_; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportConnectSubJob); | |
86 }; | |
87 | |
88 } // namespace net | |
89 | |
90 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CONNECT_SUB_JOB_H_ | |
OLD | NEW |