Commit dfcc7d6b authored by rch's avatar rch Committed by Commit bot

Move QuicClient::ClientQuicDataToResend from QuicClient to QuicClientBase.

Merge internal change: 134339524

Review-Url: https://codereview.chromium.org/2368183003
Cr-Commit-Position: refs/heads/master@{#421289}
parent 950c3c1b
...@@ -44,11 +44,6 @@ namespace net { ...@@ -44,11 +44,6 @@ namespace net {
const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET;
void QuicClient::ClientQuicDataToResend::Resend() {
client_->SendRequest(*headers_, body_, fin_);
headers_ = nullptr;
}
QuicClient::QuicClient(IPEndPoint server_address, QuicClient::QuicClient(IPEndPoint server_address,
const QuicServerId& server_id, const QuicServerId& server_id,
const QuicVersionVector& supported_versions, const QuicVersionVector& supported_versions,
...@@ -174,15 +169,9 @@ bool QuicClient::Connect() { ...@@ -174,15 +169,9 @@ bool QuicClient::Connect() {
while (EncryptionBeingEstablished()) { while (EncryptionBeingEstablished()) {
WaitForEvents(); WaitForEvents();
} }
if (FLAGS_enable_quic_stateless_reject_support && connected() && if (FLAGS_enable_quic_stateless_reject_support && connected()) {
!data_to_resend_on_connect_.empty()) { // Resend any previously queued data.
// A connection has been established and there was previously queued data ResendSavedData();
// to resend. Resend it and empty the queue.
std::vector<std::unique_ptr<QuicDataToResend>> old_data;
old_data.swap(data_to_resend_on_connect_);
for (const auto& data : old_data) {
data->Resend();
}
} }
if (session() != nullptr && if (session() != nullptr &&
session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) { session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) {
...@@ -211,7 +200,7 @@ void QuicClient::StartConnect() { ...@@ -211,7 +200,7 @@ void QuicClient::StartConnect() {
// If the last error was not a stateless reject, then the queued up data // If the last error was not a stateless reject, then the queued up data
// does not need to be resent. // does not need to be resent.
if (session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) { if (session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) {
data_to_resend_on_connect_.clear(); ClearDataToResend();
} }
// Before we destroy the last session and create a new one, gather its stats // Before we destroy the last session and create a new one, gather its stats
// and update the stats for the overall connection. // and update the stats for the overall connection.
...@@ -239,7 +228,7 @@ void QuicClient::Disconnect() { ...@@ -239,7 +228,7 @@ void QuicClient::Disconnect() {
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
} }
data_to_resend_on_connect_.clear(); ClearDataToResend();
CleanUpAllUDPSockets(); CleanUpAllUDPSockets();
...@@ -276,10 +265,7 @@ void QuicClient::SendRequest(const SpdyHeaderBlock& headers, ...@@ -276,10 +265,7 @@ void QuicClient::SendRequest(const SpdyHeaderBlock& headers,
if (rv == QUIC_PENDING) { if (rv == QUIC_PENDING) {
// May need to retry request if asynchronous rendezvous fails. // May need to retry request if asynchronous rendezvous fails.
std::unique_ptr<SpdyHeaderBlock> new_headers( AddPromiseDataToResend(headers, body, fin);
new SpdyHeaderBlock(headers.Clone()));
push_promise_data_to_resend_.reset(
new ClientQuicDataToResend(std::move(new_headers), body, fin, this));
return; return;
} }
...@@ -289,29 +275,8 @@ void QuicClient::SendRequest(const SpdyHeaderBlock& headers, ...@@ -289,29 +275,8 @@ void QuicClient::SendRequest(const SpdyHeaderBlock& headers,
return; return;
} }
stream->SendRequest(headers.Clone(), body, fin); stream->SendRequest(headers.Clone(), body, fin);
if (FLAGS_enable_quic_stateless_reject_support) {
// Record this in case we need to resend. // Record this in case we need to resend.
std::unique_ptr<SpdyHeaderBlock> new_headers( MaybeAddDataToResend(headers, body, fin);
new SpdyHeaderBlock(headers.Clone()));
auto data_to_resend =
new ClientQuicDataToResend(std::move(new_headers), body, fin, this);
MaybeAddQuicDataToResend(std::unique_ptr<QuicDataToResend>(data_to_resend));
}
}
void QuicClient::MaybeAddQuicDataToResend(
std::unique_ptr<QuicDataToResend> data_to_resend) {
DCHECK(FLAGS_enable_quic_stateless_reject_support);
if (session()->IsCryptoHandshakeConfirmed()) {
// The handshake is confirmed. No need to continue saving requests to
// resend.
data_to_resend_on_connect_.clear();
return;
}
// The handshake is not confirmed. Push the data onto the queue of data to
// resend if statelessly rejected.
data_to_resend_on_connect_.push_back(std::move(data_to_resend));
} }
void QuicClient::SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers, void QuicClient::SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers,
...@@ -431,23 +396,6 @@ void QuicClient::OnClose(QuicSpdyStream* stream) { ...@@ -431,23 +396,6 @@ void QuicClient::OnClose(QuicSpdyStream* stream) {
} }
} }
bool QuicClient::CheckVary(const SpdyHeaderBlock& client_request,
const SpdyHeaderBlock& promise_request,
const SpdyHeaderBlock& promise_response) {
return true;
}
void QuicClient::OnRendezvousResult(QuicSpdyStream* stream) {
std::unique_ptr<ClientQuicDataToResend> data_to_resend =
std::move(push_promise_data_to_resend_);
if (stream) {
stream->set_visitor(this);
stream->OnDataAvailable();
} else if (data_to_resend.get()) {
data_to_resend->Resend();
}
}
size_t QuicClient::latest_response_code() const { size_t QuicClient::latest_response_code() const {
QUIC_BUG_IF(!store_response_) << "Response not stored!"; QUIC_BUG_IF(!store_response_) << "Response not stored!";
return latest_response_code_; return latest_response_code_;
......
...@@ -38,9 +38,7 @@ class QuicClientPeer; ...@@ -38,9 +38,7 @@ class QuicClientPeer;
class QuicClient : public QuicClientBase, class QuicClient : public QuicClientBase,
public EpollCallbackInterface, public EpollCallbackInterface,
public QuicSpdyStream::Visitor, public ProcessPacketInterface {
public ProcessPacketInterface,
public QuicClientPushPromiseIndex::Delegate {
public: public:
class ResponseListener { class ResponseListener {
public: public:
...@@ -87,7 +85,7 @@ class QuicClient : public QuicClientBase, ...@@ -87,7 +85,7 @@ class QuicClient : public QuicClientBase,
// Sends an HTTP request and does not wait for response before returning. // Sends an HTTP request and does not wait for response before returning.
void SendRequest(const SpdyHeaderBlock& headers, void SendRequest(const SpdyHeaderBlock& headers,
base::StringPiece body, base::StringPiece body,
bool fin); bool fin) override;
// Sends an HTTP request and waits for response before returning. // Sends an HTTP request and waits for response before returning.
void SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers, void SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers,
...@@ -114,17 +112,6 @@ class QuicClient : public QuicClientBase, ...@@ -114,17 +112,6 @@ class QuicClient : public QuicClientBase,
// QuicSpdyStream::Visitor // QuicSpdyStream::Visitor
void OnClose(QuicSpdyStream* stream) override; void OnClose(QuicSpdyStream* stream) override;
bool CheckVary(const SpdyHeaderBlock& client_request,
const SpdyHeaderBlock& promise_request,
const SpdyHeaderBlock& promise_response) override;
void OnRendezvousResult(QuicSpdyStream*) override;
// If the crypto handshake has not yet been confirmed, adds the data to the
// queue of data to resend if the client receives a stateless reject.
// Otherwise, deletes the data.
void MaybeAddQuicDataToResend(
std::unique_ptr<QuicDataToResend> data_to_resend);
// If the client has at least one UDP socket, return address of the latest // If the client has at least one UDP socket, return address of the latest
// created one. Otherwise, return an empty socket address. // created one. Otherwise, return an empty socket address.
const IPEndPoint GetLatestClientAddress() const; const IPEndPoint GetLatestClientAddress() const;
...@@ -185,28 +172,6 @@ class QuicClient : public QuicClientBase, ...@@ -185,28 +172,6 @@ class QuicClient : public QuicClientBase,
private: private:
friend class net::test::QuicClientPeer; friend class net::test::QuicClientPeer;
// Specific QuicClient class for storing data to resend.
class ClientQuicDataToResend : public QuicDataToResend {
public:
ClientQuicDataToResend(std::unique_ptr<SpdyHeaderBlock> headers,
base::StringPiece body,
bool fin,
QuicClient* client)
: QuicDataToResend(std::move(headers), body, fin), client_(client) {
DCHECK(headers_);
DCHECK(client);
}
~ClientQuicDataToResend() override {}
void Resend() override;
private:
QuicClient* client_;
DISALLOW_COPY_AND_ASSIGN(ClientQuicDataToResend);
};
// Used during initialization: creates the UDP socket FD, sets socket options, // Used during initialization: creates the UDP socket FD, sets socket options,
// and binds the socket to our address. // and binds the socket to our address.
bool CreateUDPSocketAndBind(); bool CreateUDPSocketAndBind();
...@@ -257,10 +222,6 @@ class QuicClient : public QuicClientBase, ...@@ -257,10 +222,6 @@ class QuicClient : public QuicClientBase,
// HTTP/2 trailers from most recent response. // HTTP/2 trailers from most recent response.
std::string latest_response_trailers_; std::string latest_response_trailers_;
// Keeps track of any data that must be resent upon a subsequent successful
// connection, in case the client receives a stateless reject.
std::vector<std::unique_ptr<QuicDataToResend>> data_to_resend_on_connect_;
// Point to a QuicPacketReader object on the heap. The reader allocates more // Point to a QuicPacketReader object on the heap. The reader allocates more
// space than allowed on the stack. // space than allowed on the stack.
// //
...@@ -268,8 +229,6 @@ class QuicClient : public QuicClientBase, ...@@ -268,8 +229,6 @@ class QuicClient : public QuicClientBase,
// QuicPacketReader // QuicPacketReader
std::unique_ptr<QuicPacketReader> packet_reader_; std::unique_ptr<QuicPacketReader> packet_reader_;
std::unique_ptr<ClientQuicDataToResend> push_promise_data_to_resend_;
DISALLOW_COPY_AND_ASSIGN(QuicClient); DISALLOW_COPY_AND_ASSIGN(QuicClient);
}; };
......
...@@ -11,6 +11,11 @@ using base::StringPiece; ...@@ -11,6 +11,11 @@ using base::StringPiece;
namespace net { namespace net {
void QuicClientBase::ClientQuicDataToResend::Resend() {
client_->SendRequest(*headers_, body_, fin_);
headers_ = nullptr;
}
QuicClientBase::QuicDataToResend::QuicDataToResend( QuicClientBase::QuicDataToResend::QuicDataToResend(
std::unique_ptr<SpdyHeaderBlock> headers, std::unique_ptr<SpdyHeaderBlock> headers,
StringPiece body, StringPiece body,
...@@ -160,4 +165,69 @@ QuicConnectionId QuicClientBase::GenerateNewConnectionId() { ...@@ -160,4 +165,69 @@ QuicConnectionId QuicClientBase::GenerateNewConnectionId() {
return QuicRandom::GetInstance()->RandUint64(); return QuicRandom::GetInstance()->RandUint64();
} }
void QuicClientBase::MaybeAddDataToResend(const SpdyHeaderBlock& headers,
StringPiece body,
bool fin) {
if (!FLAGS_enable_quic_stateless_reject_support) {
return;
}
if (session()->IsCryptoHandshakeConfirmed()) {
// The handshake is confirmed. No need to continue saving requests to
// resend.
data_to_resend_on_connect_.clear();
return;
}
// The handshake is not confirmed. Push the data onto the queue of data to
// resend if statelessly rejected.
std::unique_ptr<SpdyHeaderBlock> new_headers(
new SpdyHeaderBlock(headers.Clone()));
std::unique_ptr<QuicDataToResend> data_to_resend(
new ClientQuicDataToResend(std::move(new_headers), body, fin, this));
MaybeAddQuicDataToResend(std::move(data_to_resend));
}
void QuicClientBase::MaybeAddQuicDataToResend(
std::unique_ptr<QuicDataToResend> data_to_resend) {
data_to_resend_on_connect_.push_back(std::move(data_to_resend));
}
void QuicClientBase::ClearDataToResend() {
data_to_resend_on_connect_.clear();
}
void QuicClientBase::ResendSavedData() {
for (const auto& data : data_to_resend_on_connect_) {
data->Resend();
}
data_to_resend_on_connect_.clear();
}
void QuicClientBase::AddPromiseDataToResend(const SpdyHeaderBlock& headers,
StringPiece body,
bool fin) {
std::unique_ptr<SpdyHeaderBlock> new_headers(
new SpdyHeaderBlock(headers.Clone()));
push_promise_data_to_resend_.reset(
new ClientQuicDataToResend(std::move(new_headers), body, fin, this));
}
bool QuicClientBase::CheckVary(const SpdyHeaderBlock& client_request,
const SpdyHeaderBlock& promise_request,
const SpdyHeaderBlock& promise_response) {
return true;
}
void QuicClientBase::OnRendezvousResult(QuicSpdyStream* stream) {
std::unique_ptr<ClientQuicDataToResend> data_to_resend =
std::move(push_promise_data_to_resend_);
if (stream) {
stream->set_visitor(this);
stream->OnDataAvailable();
} else if (data_to_resend.get()) {
data_to_resend->Resend();
}
}
} // namespace net } // namespace net
...@@ -31,7 +31,8 @@ namespace net { ...@@ -31,7 +31,8 @@ namespace net {
class ProofVerifier; class ProofVerifier;
class QuicServerId; class QuicServerId;
class QuicClientBase { class QuicClientBase : public QuicClientPushPromiseIndex::Delegate,
public QuicSpdyStream::Visitor {
public: public:
// The client uses these objects to keep track of any data to resend upon // 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 // receipt of a stateless reject. Recall that the client API allows callers
...@@ -69,7 +70,7 @@ class QuicClientBase { ...@@ -69,7 +70,7 @@ class QuicClientBase {
QuicAlarmFactory* alarm_factory, QuicAlarmFactory* alarm_factory,
std::unique_ptr<ProofVerifier> proof_verifier); std::unique_ptr<ProofVerifier> proof_verifier);
~QuicClientBase(); ~QuicClientBase() override;
// Initializes the client to create a connection. Should be called exactly // Initializes the client to create a connection. Should be called exactly
// once before calling StartConnect or Connect. Returns true if the // once before calling StartConnect or Connect. Returns true if the
...@@ -91,6 +92,11 @@ class QuicClientBase { ...@@ -91,6 +92,11 @@ class QuicClientBase {
// Wait for events until the handshake is confirmed. // Wait for events until the handshake is confirmed.
void WaitForCryptoHandshakeConfirmed(); void WaitForCryptoHandshakeConfirmed();
// Sends an HTTP request and does not wait for response before returning.
virtual void SendRequest(const SpdyHeaderBlock& headers,
base::StringPiece body,
bool fin) = 0;
// Wait up to 50ms, and handle any events which occur. // Wait up to 50ms, and handle any events which occur.
// Returns true if there are any outstanding requests. // Returns true if there are any outstanding requests.
virtual bool WaitForEvents() = 0; virtual bool WaitForEvents() = 0;
...@@ -204,6 +210,17 @@ class QuicClientBase { ...@@ -204,6 +210,17 @@ class QuicClientBase {
return &push_promise_index_; return &push_promise_index_;
} }
bool CheckVary(const SpdyHeaderBlock& client_request,
const SpdyHeaderBlock& promise_request,
const SpdyHeaderBlock& promise_response) override;
void OnRendezvousResult(QuicSpdyStream*) override;
// If the crypto handshake has not yet been confirmed, adds the data to the
// queue of data to resend if the client receives a stateless reject.
// Otherwise, deletes the data.
void MaybeAddQuicDataToResend(
std::unique_ptr<QuicDataToResend> data_to_resend);
protected: protected:
// Takes ownership of |connection|. // Takes ownership of |connection|.
virtual QuicClientSession* CreateQuicClientSession( virtual QuicClientSession* CreateQuicClientSession(
...@@ -222,6 +239,21 @@ class QuicClientBase { ...@@ -222,6 +239,21 @@ class QuicClientBase {
// connection ID). // connection ID).
virtual QuicConnectionId GenerateNewConnectionId(); virtual QuicConnectionId GenerateNewConnectionId();
// If the crypto handshake has not yet been confirmed, adds the data to the
// queue of data to resend if the client receives a stateless reject.
// Otherwise, deletes the data.
void MaybeAddDataToResend(const SpdyHeaderBlock& headers,
base::StringPiece body,
bool fin);
void ClearDataToResend();
void ResendSavedData();
void AddPromiseDataToResend(const SpdyHeaderBlock& headers,
base::StringPiece body,
bool fin);
QuicConnectionHelperInterface* helper() { return helper_.get(); } QuicConnectionHelperInterface* helper() { return helper_.get(); }
QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); } QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); }
...@@ -235,6 +267,28 @@ class QuicClientBase { ...@@ -235,6 +267,28 @@ class QuicClientBase {
} }
private: private:
// Specific QuicClient class for storing data to resend.
class ClientQuicDataToResend : public QuicDataToResend {
public:
ClientQuicDataToResend(std::unique_ptr<SpdyHeaderBlock> headers,
base::StringPiece body,
bool fin,
QuicClientBase* client)
: QuicDataToResend(std::move(headers), body, fin), client_(client) {
DCHECK(headers_);
DCHECK(client);
}
~ClientQuicDataToResend() override {}
void Resend() override;
private:
QuicClientBase* client_;
DISALLOW_COPY_AND_ASSIGN(ClientQuicDataToResend);
};
// |server_id_| is a tuple (hostname, port, is_https) of the server. // |server_id_| is a tuple (hostname, port, is_https) of the server.
QuicServerId server_id_; QuicServerId server_id_;
...@@ -290,6 +344,12 @@ class QuicClientBase { ...@@ -290,6 +344,12 @@ class QuicClientBase {
QuicClientPushPromiseIndex push_promise_index_; QuicClientPushPromiseIndex push_promise_index_;
// Keeps track of any data that must be resent upon a subsequent successful
// connection, in case the client receives a stateless reject.
std::vector<std::unique_ptr<QuicDataToResend>> data_to_resend_on_connect_;
std::unique_ptr<ClientQuicDataToResend> push_promise_data_to_resend_;
DISALLOW_COPY_AND_ASSIGN(QuicClientBase); DISALLOW_COPY_AND_ASSIGN(QuicClientBase);
}; };
......
...@@ -32,11 +32,6 @@ using base::StringPiece; ...@@ -32,11 +32,6 @@ using base::StringPiece;
namespace net { namespace net {
void QuicSimpleClient::ClientQuicDataToResend::Resend() {
client_->SendRequest(*headers_, body_, fin_);
headers_ = nullptr;
}
QuicSimpleClient::QuicSimpleClient( QuicSimpleClient::QuicSimpleClient(
IPEndPoint server_address, IPEndPoint server_address,
const QuicServerId& server_id, const QuicServerId& server_id,
...@@ -161,16 +156,9 @@ bool QuicSimpleClient::Connect() { ...@@ -161,16 +156,9 @@ bool QuicSimpleClient::Connect() {
while (EncryptionBeingEstablished()) { while (EncryptionBeingEstablished()) {
WaitForEvents(); WaitForEvents();
} }
if (FLAGS_enable_quic_stateless_reject_support && connected() && if (FLAGS_enable_quic_stateless_reject_support && connected()) {
!data_to_resend_on_connect_.empty()) { // Resend any previously queued data.
// A connection has been established and there was previously queued data ResendSavedData();
// to resend. Resend it and empty the queue.
std::vector<std::unique_ptr<QuicDataToResend>> old_data;
old_data.swap(data_to_resend_on_connect_);
for (const auto& data : old_data) {
data->Resend();
}
data_to_resend_on_connect_.clear();
} }
if (session() != nullptr && if (session() != nullptr &&
session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) { session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) {
...@@ -199,7 +187,7 @@ void QuicSimpleClient::StartConnect() { ...@@ -199,7 +187,7 @@ void QuicSimpleClient::StartConnect() {
// If the last error was not a stateless reject, then the queued up data // If the last error was not a stateless reject, then the queued up data
// does not need to be resent. // does not need to be resent.
if (session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) { if (session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) {
data_to_resend_on_connect_.clear(); ClearDataToResend();
} }
// Before we destroy the last session and create a new one, gather its stats // Before we destroy the last session and create a new one, gather its stats
// and update the stats for the overall connection. // and update the stats for the overall connection.
...@@ -224,7 +212,7 @@ void QuicSimpleClient::Disconnect() { ...@@ -224,7 +212,7 @@ void QuicSimpleClient::Disconnect() {
QUIC_PEER_GOING_AWAY, "Client disconnecting", QUIC_PEER_GOING_AWAY, "Client disconnecting",
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
} }
data_to_resend_on_connect_.clear(); ClearDataToResend();
reset_writer(); reset_writer();
packet_reader_.reset(); packet_reader_.reset();
...@@ -236,36 +224,26 @@ void QuicSimpleClient::Disconnect() { ...@@ -236,36 +224,26 @@ void QuicSimpleClient::Disconnect() {
void QuicSimpleClient::SendRequest(const SpdyHeaderBlock& headers, void QuicSimpleClient::SendRequest(const SpdyHeaderBlock& headers,
StringPiece body, StringPiece body,
bool fin) { bool fin) {
QuicClientPushPromiseIndex::TryHandle* handle;
QuicAsyncStatus rv = push_promise_index()->Try(headers, this, &handle);
if (rv == QUIC_SUCCESS)
return;
if (rv == QUIC_PENDING) {
// May need to retry request if asynchronous rendezvous fails.
AddPromiseDataToResend(headers, body, fin);
return;
}
QuicSpdyClientStream* stream = CreateReliableClientStream(); QuicSpdyClientStream* stream = CreateReliableClientStream();
if (stream == nullptr) { if (stream == nullptr) {
LOG(DFATAL) << "stream creation failed!"; QUIC_BUG << "stream creation failed!";
return; return;
} }
stream->set_visitor(this); stream->set_visitor(this);
stream->SendRequest(headers.Clone(), body, fin); stream->SendRequest(headers.Clone(), body, fin);
if (FLAGS_enable_quic_stateless_reject_support) {
// Record this in case we need to resend. // Record this in case we need to resend.
std::unique_ptr<SpdyHeaderBlock> new_headers( MaybeAddDataToResend(headers, body, fin);
new SpdyHeaderBlock(headers.Clone()));
auto data_to_resend =
new ClientQuicDataToResend(std::move(new_headers), body, fin, this);
MaybeAddQuicDataToResend(std::unique_ptr<QuicDataToResend>(data_to_resend));
}
}
void QuicSimpleClient::MaybeAddQuicDataToResend(
std::unique_ptr<QuicDataToResend> data_to_resend) {
DCHECK(FLAGS_enable_quic_stateless_reject_support);
if (session()->IsCryptoHandshakeConfirmed()) {
// The handshake is confirmed. No need to continue saving requests to
// resend.
data_to_resend_on_connect_.clear();
return;
}
// The handshake is not confirmed. Push the data onto the queue of data to
// resend if statelessly rejected.
data_to_resend_on_connect_.push_back(std::move(data_to_resend));
} }
void QuicSimpleClient::SendRequestAndWaitForResponse( void QuicSimpleClient::SendRequestAndWaitForResponse(
......
...@@ -38,7 +38,6 @@ class QuicClientPeer; ...@@ -38,7 +38,6 @@ class QuicClientPeer;
} // namespace test } // namespace test
class QuicSimpleClient : public QuicClientBase, class QuicSimpleClient : public QuicClientBase,
public QuicSpdyStream::Visitor,
public QuicChromiumPacketReader::Visitor { public QuicChromiumPacketReader::Visitor {
public: public:
class ResponseListener { class ResponseListener {
...@@ -84,7 +83,7 @@ class QuicSimpleClient : public QuicClientBase, ...@@ -84,7 +83,7 @@ class QuicSimpleClient : public QuicClientBase,
// Sends an HTTP request and does not wait for response before returning. // Sends an HTTP request and does not wait for response before returning.
void SendRequest(const SpdyHeaderBlock& headers, void SendRequest(const SpdyHeaderBlock& headers,
base::StringPiece body, base::StringPiece body,
bool fin); bool fin) override;
// Sends an HTTP request and waits for response before returning. // Sends an HTTP request and waits for response before returning.
void SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers, void SendRequestAndWaitForResponse(const SpdyHeaderBlock& headers,
...@@ -108,12 +107,6 @@ class QuicSimpleClient : public QuicClientBase, ...@@ -108,12 +107,6 @@ class QuicSimpleClient : public QuicClientBase,
// QuicSpdyStream::Visitor // QuicSpdyStream::Visitor
void OnClose(QuicSpdyStream* stream) override; void OnClose(QuicSpdyStream* stream) override;
// If the crypto handshake has not yet been confirmed, adds the data to the
// queue of data to resend if the client receives a stateless reject.
// Otherwise, deletes the data.
void MaybeAddQuicDataToResend(
std::unique_ptr<QuicDataToResend> data_to_resend);
void set_bind_to_address(const IPAddress& address) { void set_bind_to_address(const IPAddress& address) {
bind_to_address_ = address; bind_to_address_ = address;
} }
...@@ -145,28 +138,6 @@ class QuicSimpleClient : public QuicClientBase, ...@@ -145,28 +138,6 @@ class QuicSimpleClient : public QuicClientBase,
private: private:
friend class net::test::QuicClientPeer; friend class net::test::QuicClientPeer;
// Specific QuicClient class for storing data to resend.
class ClientQuicDataToResend : public QuicDataToResend {
public:
// Takes ownership of |headers|.
ClientQuicDataToResend(std::unique_ptr<SpdyHeaderBlock> headers,
base::StringPiece body,
bool fin,
QuicSimpleClient* client)
: QuicDataToResend(std::move(headers), body, fin), client_(client) {
DCHECK(client);
}
~ClientQuicDataToResend() override {}
void Resend() override;
private:
QuicSimpleClient* client_;
DISALLOW_COPY_AND_ASSIGN(ClientQuicDataToResend);
};
// Used during initialization: creates the UDP socket FD, sets socket options, // Used during initialization: creates the UDP socket FD, sets socket options,
// and binds the socket to our address. // and binds the socket to our address.
bool CreateUDPSocket(); bool CreateUDPSocket();
...@@ -217,10 +188,6 @@ class QuicSimpleClient : public QuicClientBase, ...@@ -217,10 +188,6 @@ class QuicSimpleClient : public QuicClientBase,
// Body of most recent response. // Body of most recent response.
std::string latest_response_body_; std::string latest_response_body_;
// Keeps track of any data that must be resent upon a subsequent successful
// connection, in case the client receives a stateless reject.
std::vector<std::unique_ptr<QuicDataToResend>> data_to_resend_on_connect_;
// The log used for the sockets. // The log used for the sockets.
NetLog net_log_; NetLog net_log_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment