 Chromium Code Reviews
 Chromium Code Reviews Issue 1376593007:
  SSL in EmbeddedTestServer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1376593007:
  SSL in EmbeddedTestServer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: net/test/embedded_test_server/http_response.h | 
| diff --git a/net/test/embedded_test_server/http_response.h b/net/test/embedded_test_server/http_response.h | 
| index d4df75b5b85418960e39b54056b1562dfe4c4d39..6d7b3c3bd880fb9586a40708dbf0ecb0ce9a5c45 100644 | 
| --- a/net/test/embedded_test_server/http_response.h | 
| +++ b/net/test/embedded_test_server/http_response.h | 
| @@ -5,10 +5,10 @@ | 
| #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_RESPONSE_H_ | 
| #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_RESPONSE_H_ | 
| -#include <map> | 
| #include <string> | 
| #include "base/basictypes.h" | 
| +#include "base/callback.h" | 
| #include "base/compiler_specific.h" | 
| #include "base/strings/string_split.h" | 
| #include "net/http/http_status_code.h" | 
| @@ -16,19 +16,29 @@ | 
| namespace net { | 
| namespace test_server { | 
| +// Callback called when the response is done being sent. | 
| +using SendCompleteCallback = base::Callback<void(void)>; | 
| + | 
| +// Callback called when the response is ready to be sent that takes the | 
| +// |response| we are sending along with 1the callback |done| that is called | 
| 
mmenke
2015/10/19 18:07:41
|done| -> |write_done|
 
mmenke
2015/10/19 18:07:41
nit: --we
 
mmenke
2015/10/19 18:07:41
1the -> the
 
svaldez
2015/10/19 21:56:15
Done.
 
svaldez
2015/10/19 21:56:15
Done.
 
svaldez
2015/10/19 21:56:15
Done.
 | 
| +// when we are done writing. | 
| +using SendBytesCallback = | 
| + base::Callback<void(std::string response, SendCompleteCallback write_done)>; | 
| + | 
| // Interface for HTTP response implementations. | 
| class HttpResponse{ | 
| public: | 
| virtual ~HttpResponse(); | 
| - // Returns raw contents to be written to the network socket | 
| - // in response. If you intend to make this a valid HTTP response, | 
| - // it should start with "HTTP/x.x" line, followed by response headers. | 
| - virtual std::string ToResponseString() const = 0; | 
| + // |send| will send the specified data to the network socket, and invoke | 
| + // |write_done| when complete. When the entire response has been sent, | 
| + // |done| must be called. | 
| + virtual void SendResponse(SendBytesCallback send, | 
| + SendCompleteCallback done) = 0; | 
| 
mmenke
2015/10/19 18:07:41
cosnt SendBytesCallback&, const SendCompleteCallba
 
svaldez
2015/10/19 21:56:15
Done.
 | 
| }; | 
| // This class is used to handle basic HTTP responses with commonly used | 
| -// response headers such as "Content-Type". | 
| +// response headers such as "Content-Type". Sends the response immediately. | 
| class BasicHttpResponse : public HttpResponse { | 
| public: | 
| BasicHttpResponse(); | 
| @@ -54,7 +64,9 @@ class BasicHttpResponse : public HttpResponse { | 
| } | 
| // Generates and returns a http response string. | 
| - std::string ToResponseString() const override; | 
| + std::string ToResponseString() const; | 
| + | 
| + void SendResponse(SendBytesCallback send, SendCompleteCallback done) override; | 
| private: | 
| HttpStatusCode code_; |