Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: net/tools/quic/test_tools/quic_test_client.h

Issue 2430973004: Landing Recent QUIC changes until 10:38 AM, Oct 17, 2016 UTC-4 (Closed)
Patch Set: Improving flagsaver logging Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/stateless_rejector.cc ('k') | net/tools/quic/test_tools/quic_test_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/test_tools/quic_test_client.h
diff --git a/net/tools/quic/test_tools/quic_test_client.h b/net/tools/quic/test_tools/quic_test_client.h
index 12b804bfa9299fc494b63698495f5541d3690cc3..88d00cb99cb36be68eab29be3d33d73bc9bf84f4 100644
--- a/net/tools/quic/test_tools/quic_test_client.h
+++ b/net/tools/quic/test_tools/quic_test_client.h
@@ -22,7 +22,6 @@
#include "net/tools/balsa/balsa_frame.h"
#include "net/tools/epoll_server/epoll_server.h"
#include "net/tools/quic/quic_client.h"
-#include "net/tools/quic/test_tools/simple_client.h"
#include "testing/gmock/include/gmock/gmock.h"
using base::StringPiece;
@@ -93,9 +92,8 @@ class MockableQuicClient : public QuicClient {
DISALLOW_COPY_AND_ASSIGN(MockableQuicClient);
};
-// A toy QUIC client used for testing, mostly following the SimpleClient APIs.
-class QuicTestClient : public test::SimpleClient,
- public QuicSpdyStream::Visitor,
+// A toy QUIC client used for testing.
+class QuicTestClient : public QuicSpdyStream::Visitor,
public QuicClientPushPromiseIndex::Delegate {
public:
QuicTestClient(IPEndPoint server_address,
@@ -123,48 +121,64 @@ class QuicTestClient : public test::SimpleClient,
bool last_data,
QuicAckListenerInterface* delegate);
- // From SimpleClient
// Clears any outstanding state and sends a simple GET of 'uri' to the
// server. Returns 0 if the request failed and no bytes were written.
- ssize_t SendRequest(const std::string& uri) override;
+ ssize_t SendRequest(const std::string& uri);
// Sends requests for all the urls and waits for the responses. To process
// the individual responses as they are returned, the caller should use the
// set the response_listener on the client().
void SendRequestsAndWaitForResponses(
const std::vector<std::string>& url_list);
- ssize_t SendMessage(const HTTPMessage& message) override;
- std::string SendCustomSynchronousRequest(const HTTPMessage& message) override;
- std::string SendSynchronousRequest(const std::string& uri) override;
- void Connect() override;
- void ResetConnection() override;
- void Disconnect() override;
- IPEndPoint local_address() const override;
- void ClearPerRequestState() override;
- bool WaitUntil(int timeout_ms, std::function<bool()> trigger) override;
- ssize_t Send(const void* buffer, size_t size) override;
- bool response_complete() const override;
- bool response_headers_complete() const override;
- const BalsaHeaders* response_headers() const override;
- int64_t response_size() const override;
- int response_header_size() const override;
- int64_t response_body_size() const override;
- size_t bytes_read() const override;
- size_t bytes_written() const override;
- bool buffer_body() const override;
- void set_buffer_body(bool buffer_body) override;
- bool ServerInLameDuckMode() const override;
- const std::string& response_body() override;
- bool connected() const override;
- // These functions are all unimplemented functions from SimpleClient, and log
- // DFATAL if called by users of SimpleClient.
- ssize_t SendAndWaitForResponse(const void* buffer, size_t size) override;
- void Bind(IPEndPoint* local_address) override;
- void MigrateSocket(const IPAddress& new_host) override;
- std::string SerializeMessage(const HTTPMessage& message) override;
- IPAddress bind_to_address() const override;
- void set_bind_to_address(const IPAddress& address) override;
- const IPEndPoint& address() const override;
- size_t requests_sent() const override;
+ ssize_t SendMessage(const HTTPMessage& message);
+ std::string SendCustomSynchronousRequest(const HTTPMessage& message);
+ std::string SendSynchronousRequest(const std::string& uri);
+ void Connect();
+ void ResetConnection();
+ void Disconnect();
+ IPEndPoint local_address() const;
+ void ClearPerRequestState();
+ bool WaitUntil(int timeout_ms, std::function<bool()> trigger);
+ ssize_t Send(const void* buffer, size_t size);
+ bool response_complete() const;
+ bool response_headers_complete() const;
+ const BalsaHeaders* response_headers() const;
+ int64_t response_size() const;
+ int response_header_size() const;
+ int64_t response_body_size() const;
+ size_t bytes_read() const;
+ size_t bytes_written() const;
+ bool buffer_body() const;
+ void set_buffer_body(bool buffer_body);
+ const std::string& response_body();
+ bool connected() const;
+
+ // Returns once a complete response or a connection close has been received
+ // from the server.
+ void WaitForResponse() { WaitForResponseForMs(-1); }
+
+ // Waits for some data or response from the server.
+ void WaitForInitialResponse() { WaitForInitialResponseForMs(-1); }
+
+ // Returns once a complete response or a connection close has been received
+ // from the server, or once the timeout expires. -1 for no timeout.
+ void WaitForResponseForMs(int timeout_ms) {
+ WaitUntil(timeout_ms, [this]() { return response_complete(); });
+ if (response_complete()) {
+ VLOG(1) << "Client received response:"
+ << response_headers()->DebugString() << response_body();
+ }
+ }
+
+ // Waits for some data or response from the server, or once the timeout
+ // expires. -1 for no timeout.
+ void WaitForInitialResponseForMs(int timeout_ms) {
+ WaitUntil(timeout_ms, [this]() { return response_size() != 0; });
+ }
+
+ void MigrateSocket(const IPAddress& new_host);
+ IPAddress bind_to_address() const;
+ void set_bind_to_address(IPAddress address);
+ const IPEndPoint& address() const;
// Returns the response trailers as received by the |stream_|.
const SpdyHeaderBlock& response_trailers() const;
@@ -243,13 +257,13 @@ class QuicTestClient : public test::SimpleClient,
override_sni_ = sni;
}
- protected:
- QuicTestClient();
-
void Initialize();
void set_client(MockableQuicClient* client) { client_.reset(client); }
+ protected:
+ QuicTestClient();
+
private:
class TestClientDataToResend : public QuicClient::QuicDataToResend {
public:
« no previous file with comments | « net/tools/quic/stateless_rejector.cc ('k') | net/tools/quic/test_tools/quic_test_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698