| Index: net/tools/quic/quic_client.h
|
| diff --git a/net/tools/quic/quic_client.h b/net/tools/quic/quic_client.h
|
| index dff173257e050eee1d1b7902a3277317e2d0052c..d2fdd21cdcec7598aed44d5d1a0550692f53fba8 100644
|
| --- a/net/tools/quic/quic_client.h
|
| +++ b/net/tools/quic/quic_client.h
|
| @@ -15,18 +15,14 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/string_piece.h"
|
| #include "net/base/ip_endpoint.h"
|
| -#include "net/quic/crypto/crypto_handshake.h"
|
| #include "net/quic/quic_config.h"
|
| -#include "net/quic/quic_framer.h"
|
| -#include "net/quic/quic_packet_creator.h"
|
| +#include "net/quic/quic_data_stream.h"
|
| #include "net/tools/balsa/balsa_headers.h"
|
| #include "net/tools/epoll_server/epoll_server.h"
|
| -#include "net/tools/quic/quic_client_session.h"
|
| -#include "net/tools/quic/quic_spdy_client_stream.h"
|
| +#include "net/tools/quic/quic_client_base.h"
|
|
|
| namespace net {
|
|
|
| -class ProofVerifier;
|
| class QuicServerId;
|
|
|
| namespace tools {
|
| @@ -37,7 +33,8 @@ namespace test {
|
| class QuicClientPeer;
|
| } // namespace test
|
|
|
| -class QuicClient : public EpollCallbackInterface,
|
| +class QuicClient : public QuicClientBase,
|
| + public EpollCallbackInterface,
|
| public QuicDataStream::Visitor {
|
| public:
|
| class ResponseListener {
|
| @@ -49,18 +46,6 @@ class QuicClient : public EpollCallbackInterface,
|
| const std::string& response_body) = 0;
|
| };
|
|
|
| - // A packet writer factory that always returns the same writer.
|
| - class DummyPacketWriterFactory : public QuicConnection::PacketWriterFactory {
|
| - public:
|
| - explicit DummyPacketWriterFactory(QuicPacketWriter* writer);
|
| - ~DummyPacketWriterFactory() override;
|
| -
|
| - QuicPacketWriter* Create(QuicConnection* connection) const override;
|
| -
|
| - private:
|
| - QuicPacketWriter* writer_;
|
| - };
|
| -
|
| // The client uses these objects to keep track of any data to resend upon
|
| // receipt of a stateless reject. Recall that the client API allows callers
|
| // to optimistically send data to the server prior to handshake-confirmation.
|
| @@ -103,10 +88,9 @@ class QuicClient : public EpollCallbackInterface,
|
|
|
| ~QuicClient() override;
|
|
|
| - // Initializes the client to create a connection. Should be called exactly
|
| - // once before calling StartConnect or Connect. Returns true if the
|
| - // initialization succeeds, false otherwise.
|
| - bool Initialize();
|
| + // From QuicClientBase
|
| + bool Initialize() override;
|
| + bool WaitForEvents() override;
|
|
|
| // "Connect" to the QUIC server, including performing synchronous crypto
|
| // handshake.
|
| @@ -117,11 +101,6 @@ class QuicClient : public EpollCallbackInterface,
|
| // completes.
|
| void StartConnect();
|
|
|
| - // Returns true if the crypto handshake has yet to establish encryption.
|
| - // Returns false if encryption is active (even if the server hasn't confirmed
|
| - // the handshake) or if the connection has been closed.
|
| - bool EncryptionBeingEstablished();
|
| -
|
| // Disconnects from the QUIC server.
|
| void Disconnect();
|
|
|
| @@ -140,20 +119,6 @@ class QuicClient : public EpollCallbackInterface,
|
| void SendRequestsAndWaitForResponse(
|
| const std::vector<std::string>& url_list);
|
|
|
| - // Returns a newly created QuicSpdyClientStream, owned by the
|
| - // QuicClient.
|
| - QuicSpdyClientStream* CreateReliableClientStream();
|
| -
|
| - // Wait for events until the stream with the given ID is closed.
|
| - void WaitForStreamToClose(QuicStreamId id);
|
| -
|
| - // Wait for events until the handshake is confirmed.
|
| - void WaitForCryptoHandshakeConfirmed();
|
| -
|
| - // Wait up to 50ms, and handle any events which occur.
|
| - // Returns true if there are any outstanding requests.
|
| - bool WaitForEvents();
|
| -
|
| // Migrate to a new socket during an active connection.
|
| bool MigrateSocket(const IPAddressNumber& new_host);
|
|
|
| @@ -175,11 +140,6 @@ class QuicClient : public EpollCallbackInterface,
|
| // Otherwise, deletes the data. Takes ownerership of |data_to_resend|.
|
| void MaybeAddQuicDataToResend(QuicDataToResend* data_to_resend);
|
|
|
| - QuicClientSession* session() { return session_.get(); }
|
| -
|
| - bool connected() const;
|
| - bool goaway_received() const;
|
| -
|
| void set_bind_to_address(IPAddressNumber address) {
|
| bind_to_address_ = address;
|
| }
|
| @@ -194,87 +154,18 @@ class QuicClient : public EpollCallbackInterface,
|
|
|
| int fd() { return fd_; }
|
|
|
| - const QuicServerId& server_id() const { return server_id_; }
|
| -
|
| - // This should only be set before the initial Connect()
|
| - void set_server_id(const QuicServerId& server_id) {
|
| - server_id_ = server_id;
|
| - }
|
| -
|
| - void SetUserAgentID(const std::string& user_agent_id) {
|
| - crypto_config_.set_user_agent_id(user_agent_id);
|
| - }
|
| -
|
| - // SetProofVerifier sets the ProofVerifier that will be used to verify the
|
| - // server's certificate and takes ownership of |verifier|.
|
| - void SetProofVerifier(ProofVerifier* verifier) {
|
| - // TODO(rtenneti): We should set ProofVerifier in QuicClientSession.
|
| - crypto_config_.SetProofVerifier(verifier);
|
| - }
|
| -
|
| - // SetChannelIDSource sets a ChannelIDSource that will be called, when the
|
| - // server supports channel IDs, to obtain a channel ID for signing a message
|
| - // proving possession of the channel ID. This object takes ownership of
|
| - // |source|.
|
| - void SetChannelIDSource(ChannelIDSource* source) {
|
| - crypto_config_.SetChannelIDSource(source);
|
| - }
|
| -
|
| - void SetSupportedVersions(const QuicVersionVector& versions) {
|
| - supported_versions_ = versions;
|
| - }
|
| -
|
| // Takes ownership of the listener.
|
| void set_response_listener(ResponseListener* listener) {
|
| response_listener_.reset(listener);
|
| }
|
|
|
| - QuicConfig* config() { return &config_; }
|
| -
|
| void set_store_response(bool val) { store_response_ = val; }
|
|
|
| size_t latest_response_code() const;
|
| const std::string& latest_response_headers() const;
|
| const std::string& latest_response_body() const;
|
|
|
| - // Change the initial maximum packet size of the connection. Has to be called
|
| - // before Connect()/StartConnect() in order to have any effect.
|
| - void set_initial_max_packet_length(QuicByteCount initial_max_packet_length) {
|
| - initial_max_packet_length_ = initial_max_packet_length;
|
| - }
|
| -
|
| - int num_stateless_rejects_received() const {
|
| - return num_stateless_rejects_received_;
|
| - }
|
| -
|
| - // The number of client hellos sent, taking stateless rejects into
|
| - // account. In the case of a stateless reject, the initial
|
| - // connection object may be torn down and a new one created. The
|
| - // user cannot rely upon the latest connection object to get the
|
| - // total number of client hellos sent, and should use this function
|
| - // instead.
|
| - int GetNumSentClientHellos();
|
| -
|
| - // Returns any errors that occurred at the connection-level (as
|
| - // opposed to the session-level). When a stateless reject occurs,
|
| - // the error of the last session may not reflect the overall state
|
| - // of the connection.
|
| - QuicErrorCode connection_error() const;
|
| -
|
| protected:
|
| - // Generates the next ConnectionId for |server_id_|. By default, if the
|
| - // cached server config contains a server-designated ID, that ID will be
|
| - // returned. Otherwise, the next random ID will be returned.
|
| - QuicConnectionId GetNextConnectionId();
|
| -
|
| - // Returns the next server-designated ConnectionId from the cached config for
|
| - // |server_id_|, if it exists. Otherwise, returns 0.
|
| - QuicConnectionId GetNextServerDesignatedConnectionId();
|
| -
|
| - // Generates a new, random connection ID (as opposed to a server-designated
|
| - // connection ID).
|
| - virtual QuicConnectionId GenerateNewConnectionId();
|
| -
|
| virtual QuicEpollConnectionHelper* CreateQuicConnectionHelper();
|
| virtual QuicPacketWriter* CreateQuicPacketWriter();
|
|
|
| @@ -283,12 +174,6 @@ class QuicClient : public EpollCallbackInterface,
|
| IPEndPoint* server_address,
|
| IPAddressNumber* client_ip);
|
|
|
| - virtual QuicClientSession* CreateQuicClientSession(
|
| - const QuicConfig& config,
|
| - QuicConnection* connection,
|
| - const QuicServerId& server_id,
|
| - QuicCryptoClientConfig* crypto_config);
|
| -
|
| EpollServer* epoll_server() { return epoll_server_; }
|
|
|
| // If the socket has been created, then unregister and close() the FD.
|
| @@ -333,14 +218,6 @@ class QuicClient : public EpollCallbackInterface,
|
| // Address of the server.
|
| const IPEndPoint server_address_;
|
|
|
| - // |server_id_| is a tuple (hostname, port, is_https) of the server.
|
| - QuicServerId server_id_;
|
| -
|
| - // config_ and crypto_config_ contain configuration and cached state about
|
| - // servers.
|
| - QuicConfig config_;
|
| - QuicCryptoClientConfig crypto_config_;
|
| -
|
| // Address of the client if the client is connected to the server.
|
| IPEndPoint client_address_;
|
|
|
| @@ -349,12 +226,6 @@ class QuicClient : public EpollCallbackInterface,
|
| // Local port to bind to. Initialize to 0.
|
| int local_port_;
|
|
|
| - // Writer used to actually send packets to the wire. Needs to outlive
|
| - // |session_|.
|
| - scoped_ptr<QuicPacketWriter> writer_;
|
| -
|
| - // Session which manages streams.
|
| - scoped_ptr<QuicClientSession> session_;
|
| // Listens for events on the client socket.
|
| EpollServer* epoll_server_;
|
| // UDP socket.
|
| @@ -377,13 +248,6 @@ class QuicClient : public EpollCallbackInterface,
|
| // because the socket would otherwise overflow.
|
| bool overflow_supported_;
|
|
|
| - // This vector contains QUIC versions which we currently support.
|
| - // This should be ordered such that the highest supported version is the first
|
| - // element, with subsequent elements in descending order (versions can be
|
| - // skipped as necessary). We will always pick supported_versions_[0] as the
|
| - // initial version to use.
|
| - QuicVersionVector supported_versions_;
|
| -
|
| // If true, store the latest response code, headers, and body.
|
| bool store_response_;
|
| // HTTP response code from most recent response.
|
| @@ -393,31 +257,6 @@ class QuicClient : public EpollCallbackInterface,
|
| // Body of most recent response.
|
| std::string latest_response_body_;
|
|
|
| - // The initial value of maximum packet size of the connection. If set to
|
| - // zero, the default is used.
|
| - QuicByteCount initial_max_packet_length_;
|
| -
|
| - // The number of stateless rejects received during the current/latest
|
| - // connection.
|
| - // TODO(jokulik): Consider some consistent naming scheme (or other) for member
|
| - // variables that are kept per-request, per-connection, and over the client's
|
| - // lifetime.
|
| - int num_stateless_rejects_received_;
|
| -
|
| - // The number of hellos sent during the current/latest connection.
|
| - int num_sent_client_hellos_;
|
| -
|
| - // Used to store any errors that occurred with the overall connection (as
|
| - // opposed to that associated with the last session object).
|
| - QuicErrorCode connection_error_;
|
| -
|
| - // True when the client is attempting to connect or re-connect the session (in
|
| - // the case of a stateless reject). Set to false between a call to
|
| - // Disconnect() and the subsequent call to StartConnect(). When
|
| - // connected_or_attempting_connect_ is false, the session object corresponds
|
| - // to the previous client-level connection.
|
| - bool connected_or_attempting_connect_;
|
| -
|
| // Keeps track of any data sent before the handshake.
|
| std::vector<QuicDataToResend*> data_sent_before_handshake_;
|
|
|
|
|