| Index: net/tools/quic/quic_simple_server_stream.h
|
| diff --git a/net/tools/quic/quic_simple_server_stream.h b/net/tools/quic/quic_simple_server_stream.h
|
| index 90cb0dcf31f975317284d0d00c3c4421257e50b7..a0edbd9f093abb2558c65b61e1c696f8d295c3b8 100644
|
| --- a/net/tools/quic/quic_simple_server_stream.h
|
| +++ b/net/tools/quic/quic_simple_server_stream.h
|
| @@ -13,6 +13,7 @@
|
| #include "net/quic/quic_protocol.h"
|
| #include "net/quic/quic_spdy_stream.h"
|
| #include "net/spdy/spdy_framer.h"
|
| +#include "net/tools/quic/quic_in_memory_cache.h"
|
|
|
| namespace net {
|
|
|
| @@ -46,9 +47,13 @@ class QuicSimpleServerStream : public QuicSpdyStream {
|
| static const char* const kNotFoundResponseBody;
|
|
|
| protected:
|
| - // Sends a basic 200 response using SendHeaders for the headers and WriteData
|
| - // for the body.
|
| - virtual void SendResponse();
|
| + enum State {
|
| + INIT,
|
| + SEND_HEADERS,
|
| + SEND_BODY,
|
| + SEND_TRAILERS,
|
| + NONE,
|
| + };
|
|
|
| // Sends a basic 500 response using SendHeaders for the headers and WriteData
|
| // for the body.
|
| @@ -58,17 +63,22 @@ class QuicSimpleServerStream : public QuicSpdyStream {
|
| // for the body.
|
| void SendNotFoundResponse();
|
|
|
| - void SendHeadersAndBody(const SpdyHeaderBlock& response_headers,
|
| - base::StringPiece body);
|
| - void SendHeadersAndBodyAndTrailers(const SpdyHeaderBlock& response_headers,
|
| - base::StringPiece body,
|
| - const SpdyHeaderBlock& response_trailers);
|
| + // Starts or resumes the response as indicated |next_state_|.
|
| + void DoLoop();
|
|
|
| SpdyHeaderBlock* request_headers() { return &request_headers_; }
|
|
|
| const std::string& body() { return body_; }
|
|
|
| + State next_state_;
|
| + QuicInMemoryCache::Response response_;
|
| +
|
| private:
|
| + void Init();
|
| + void SendHeaders();
|
| + void SendBody();
|
| + void SendTrailers();
|
| +
|
| friend class test::QuicSimpleServerStreamPeer;
|
|
|
| // The parsed headers received from the client.
|
| @@ -76,6 +86,10 @@ class QuicSimpleServerStream : public QuicSpdyStream {
|
| int content_length_;
|
| std::string body_;
|
|
|
| + // How many body chunks have been sent. Only relevant to
|
| + // QuicInMemoryCache::BIDIRECTIONAL.
|
| + size_t body_chunks_consumed_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(QuicSimpleServerStream);
|
| };
|
|
|
|
|