Chromium Code Reviews| Index: net/socket/websocket_transport_connect_sub_job.h |
| diff --git a/net/socket/websocket_transport_connect_sub_job.h b/net/socket/websocket_transport_connect_sub_job.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..93d08884b63090da92d7e84155a8d5065a21adc2 |
| --- /dev/null |
| +++ b/net/socket/websocket_transport_connect_sub_job.h |
| @@ -0,0 +1,90 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef NET_SOCKET_WEBSOCKET_TRANSPORT_CONNECT_SUB_JOB_H_ |
| +#define NET_SOCKET_WEBSOCKET_TRANSPORT_CONNECT_SUB_JOB_H_ |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/containers/linked_list.h" |
|
tyoshino (SeeGerritForStatus)
2014/06/20 12:12:07
remove
Adam Rice
2014/06/23 10:06:26
Done.
|
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "net/base/address_list.h" |
| +#include "net/base/load_states.h" |
| +#include "net/socket/websocket_endpoint_lock_manager.h" |
| +#include "net/socket/websocket_transport_client_socket_pool.h" |
| + |
| +namespace net { |
| + |
| +class BoundNetLog; |
| +class ClientSocketFactory; |
| +class IPEndPoint; |
| +class StreamSocket; |
| + |
| +// Attempts to connect to a subset of the addresses required by a |
| +// WebSocketTransportConnectJob, specifically either the IPv4 or IPv6 |
| +// addresses. Each address is tried in turn, and parent_job->OnSubJobComplete() |
| +// is called when the first address succeeds or the last address fails. |
| +class WebSocketTransportConnectSubJob |
| + : public WebSocketEndpointLockManager::Waiter { |
| + public: |
| + typedef WebSocketTransportConnectJob::SubJobType SubJobType; |
| + |
| + WebSocketTransportConnectSubJob(const AddressList& addresses, |
| + WebSocketTransportConnectJob* parent_job, |
| + SubJobType type); |
| + |
| + virtual ~WebSocketTransportConnectSubJob(); |
| + |
| + // Start connecting. |
| + int Start(); |
| + |
| + bool started() { return next_state_ != STATE_NONE; } |
| + |
| + LoadState GetLoadState() const; |
| + |
| + SubJobType type() const { return type_; } |
| + |
| + scoped_ptr<StreamSocket> PassSocket() { return transport_socket_.Pass(); } |
| + |
| + // Implementation of WebSocketEndpointLockManager::EndpointWaiter. |
| + virtual void GotEndpointLock() OVERRIDE; |
| + |
| + private: |
| + enum State { |
| + STATE_NONE, |
| + STATE_OBTAIN_LOCK, |
| + STATE_OBTAIN_LOCK_COMPLETE, |
| + STATE_TRANSPORT_CONNECT, |
| + STATE_TRANSPORT_CONNECT_COMPLETE, |
| + }; |
| + |
| + ClientSocketFactory* client_socket_factory() const; |
| + |
| + const BoundNetLog& net_log() const; |
| + |
| + const IPEndPoint& CurrentAddress() const; |
| + |
| + void OnIOComplete(int result); |
| + int DoLoop(int result); |
| + int DoEndpointLock(); |
| + int DoEndpointLockComplete(); |
| + int DoTransportConnect(); |
| + int DoTransportConnectComplete(int result); |
| + |
| + WebSocketTransportConnectJob* const parent_job_; |
| + |
| + const AddressList addresses_; |
| + size_t current_address_index_; |
| + |
| + State next_state_; |
| + const SubJobType type_; |
| + |
| + scoped_ptr<StreamSocket> transport_socket_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WebSocketTransportConnectSubJob); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CONNECT_SUB_JOB_H_ |