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

Unified Diff: net/test/embedded_test_server/http_response.h

Issue 1376593007: SSL in EmbeddedTestServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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
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..1b58d8abcda3a445781fd3eac0c0ddeb6d07ccf2 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,22 @@
namespace net {
namespace test_server {
+// Callback called when the response is done being sent.
+typedef base::Callback<void(void)> SendDoneCallback;
davidben 2015/10/13 19:43:48 Nit: using SendDoneCallback = base::Callback<void(
svaldez 2015/10/13 20:54:44 Done.
+
+// Callback called when the response is ready to be sent.
+typedef base::Callback<void(std::string response, SendDoneCallback done)>
+ SendCallback;
+
// 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.
davidben 2015/10/13 19:43:48 Should add "May call |send| reentrantly." or somet
svaldez 2015/10/13 20:54:44 Done.
- virtual std::string ToResponseString() const = 0;
+ virtual void SendResponse(SendCallback send, SendDoneCallback done) = 0;
davidben 2015/10/13 19:43:48 Why do you need both callbacks? It looks like Send
davidben 2015/10/13 19:43:48 Nit: I'd probably call this GetResponse or somethi
svaldez 2015/10/13 20:54:44 I guess that's kind of true in the base case, howe
svaldez 2015/10/13 20:54:44 Some subclasses (not implemented yet) will need to
};
// This class is used to handle basic HTTP responses with commonly used
@@ -54,7 +62,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_;

Powered by Google App Engine
This is Rietveld 408576698