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

Side by Side Diff: net/tools/quic/test_tools/simple_client.h

Issue 2477703002: Remove now unused Balsa code. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
(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_TOOLS_QUIC_TEST_TOOLS_SIMPLE_CLIENT_H_
6 #define NET_TOOLS_QUIC_TEST_TOOLS_SIMPLE_CLIENT_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <string>
12 #include <vector>
13
14 #include "net/base/ip_address.h"
15 #include "net/base/ip_endpoint.h"
16 #include "net/tools/balsa/balsa_frame.h"
17
18 namespace net {
19 namespace test {
20
21 class HTTPMessage;
22
23 class SimpleClient {
24 public:
25 virtual ~SimpleClient() {}
26
27 // Clears any outstanding state and sends 'size' bytes from 'buffer' to the
28 // server, possibly with multiple send operations. Returns 'size' on success
29 // and -1 on error. Callers should assume that any return value other than
30 // 'size' indicates failure.
31 virtual ssize_t Send(const void* buffer, size_t size) = 0;
32
33 // Serialize and send an HTTP request.
34 virtual ssize_t SendMessage(const HTTPMessage& message) = 0;
35
36 // Clears any outstanding state, sends 'size' bytes from 'buffer' and waits
37 // for a response or an error.
38 virtual ssize_t SendAndWaitForResponse(const void* buffer, size_t size) = 0;
39
40 // Clears any outstanding state and sends a simple GET of 'uri' to the
41 // server.
42 virtual ssize_t SendRequest(const std::string& uri) = 0;
43
44 // The response body is returned as a string.
45 virtual std::string SendCustomSynchronousRequest(
46 const HTTPMessage& message) = 0;
47 virtual std::string SendSynchronousRequest(const std::string& url) = 0;
48
49 // Returns once a complete response or a connection close has been received
50 // from the server.
51 virtual void WaitForResponse();
52
53 // Waits for some data or response from the server.
54 virtual void WaitForInitialResponse();
55
56 // Returns once a complete response or a connection close has been received
57 // from the server, or once the timeout expires. -1 for no timeout.
58 virtual void WaitForResponseForMs(int timeout_ms);
59
60 // Waits for some data or response from the server, or once the timeout
61 // expires. -1 for no timeout.
62 virtual void WaitForInitialResponseForMs(int timeout_ms);
63
64 virtual bool WaitUntil(int timeout_ms, std::function<bool()> trigger) = 0;
65
66 // Clears any outstanding state from the last request.
67 virtual void ClearPerRequestState() = 0;
68
69 // Closes and reopens the connection to the server.
70 virtual void ResetConnection() = 0;
71
72 // Closes the connection to the server.
73 virtual void Disconnect() = 0;
74
75 // Both will return 0 on success, -1 otherwise.
76 // Sends out RST packet to peer.
77 // TODO(yongfa): Probably should be an interface too. LOG(FATAL) here
78 // to prevent accidental invocation.
79 virtual int ResetSocket();
80
81 virtual int HalfClose();
82
83 // Connects to the server. This should be done implicitly by Send*
84 // functions, but can be done explicitly as well.
85 virtual void Connect() = 0;
86
87 // Bind to the specified address. If set_bind_to_address() is called, this
88 // is called automatically on connect, but can be done explicitly to make
89 // LocalIPEndPoint() meaningful before actually connecting.
90 // Sets *local_address to the actual address bound to, which can be different
91 // if the given address has port 0.
92 virtual void Bind(IPEndPoint* local_address) = 0;
93
94 virtual void MigrateSocket(const IPAddress& new_host) = 0;
95
96 // Returns the local socket address of the client fd. Call only when
97 // connected.
98 // To get the local IPAdress, use local_address().host().
99 // To get the local port, use local_address.port().
100 virtual IPEndPoint local_address() const = 0;
101
102 // Returns the serialized message that would be sent by any of the HTTPMessage
103 // functions above.
104 virtual std::string SerializeMessage(const HTTPMessage& message) = 0;
105
106 // Sets the IP address to bind to on future Connect()s in case Bind() is not
107 // called in advance. If it's set to uninitialized IPAddress, default loopback
108 // address will be used.
109 virtual IPAddress bind_to_address() const = 0;
110 virtual void set_bind_to_address(const IPAddress& address) = 0;
111
112 // Returns true if the headers have been processed and are available.
113 virtual bool response_headers_complete() const = 0;
114
115 // Returns the response headers, if a response was completely framed.
116 // Undefined behavior otherwise.
117 virtual const BalsaHeaders* response_headers() const = 0;
118
119 // Returns true iff response has been fully received.
120 virtual bool response_complete() const = 0;
121
122 // Returns the number of bytes read from the server during this request.
123 virtual int64_t response_size() const = 0;
124
125 // Returns the number of header bytes received during this request, if
126 // meaningful for the protocol.
127 virtual int response_header_size() const;
128
129 // Returns the number of body bytes received during this request, if
130 // meaningful for the protocol.
131 virtual int64_t response_body_size() const;
132
133 // Returns the response body, if there was one. If there was no response, or
134 // if buffer_body() is false, returns an empty string.
135 virtual const std::string& response_body() = 0;
136
137 // The address the client is connected to.
138 virtual const IPEndPoint& address() const = 0;
139
140 // Returns true if the client is connected, false otherwise.
141 virtual bool connected() const = 0;
142
143 // Returns true if the server has informed the client that it is
144 // in "lame duck" mode, indicating intent to shut down and
145 // requesting that no further connections be established.
146 virtual bool ServerInLameDuckMode() const = 0;
147
148 // Return the number of bytes read off the wire by this client.
149 virtual size_t bytes_read() const = 0;
150
151 // Returns the number of bytes written to the wire by this client.
152 virtual size_t bytes_written() const = 0;
153
154 // Return the number of requests sent.
155 virtual size_t requests_sent() const = 0;
156
157 // Instructs the client to populate response_body().
158 virtual bool buffer_body() const = 0;
159 virtual void set_buffer_body(bool buffer_body) = 0;
160 };
161
162 } // namespace test
163 } // namespace net
164
165 #endif // NET_TOOLS_QUIC_TEST_TOOLS_SIMPLE_CLIENT_H_
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.cc ('k') | net/tools/quic/test_tools/simple_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698