 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..1b8ba49a39b7906c2bfeb7f17475f422425696c5 100644 | 
| --- a/net/test/embedded_test_server/http_response.h | 
| +++ b/net/test/embedded_test_server/http_response.h | 
| @@ -9,6 +9,7 @@ | 
| #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,15 +17,24 @@ | 
| namespace net { | 
| namespace test_server { | 
| +// Callback called when the response is done being sent. | 
| +using SendDoneCallback = base::Callback<void(void)>; | 
| 
mmenke
2015/10/14 21:59:16
Suggest Done->Complete (Complete's a bit more comm
 
svaldez
2015/10/14 22:33:40
Done.
 | 
| + | 
| +// Callback called when the response is ready to be sent. | 
| 
mmenke
2015/10/14 21:59:16
Document done.
 
svaldez
2015/10/14 22:33:40
Done.
 | 
| +using SendCallback = | 
| + base::Callback<void(std::string response, SendDoneCallback done)>; | 
| 
mmenke
2015/10/14 21:59:16
Suggest calling this SendBytesCallback to more cle
 
svaldez
2015/10/14 22:33:40
Done.
 | 
| + | 
| // Interface for HTTP response implementations. | 
| class HttpResponse{ | 
| public: | 
| virtual ~HttpResponse(); | 
| - // Returns raw contents to be written to the network socket | 
| + // Calls |send| with the 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; | 
| + // May call |send| reentrantly. If the HttpResponse is destroyed before | 
| + // the operation completes, the callback will not be called. | 
| 
mmenke
2015/10/14 21:59:16
Think this documentation should be targeted at imp
 
svaldez
2015/10/14 22:33:40
Done.
 | 
| + virtual void SendResponse(SendCallback send, SendDoneCallback done) = 0; | 
| 
mmenke
2015/10/14 21:59:16
I assume you can use SendCallback and your own sen
 
svaldez
2015/10/14 22:33:40
Done.
 | 
| }; | 
| // This class is used to handle basic HTTP responses with commonly used | 
| @@ -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(SendCallback send, SendDoneCallback done) override; | 
| private: | 
| HttpStatusCode code_; |