Index: chrome/browser/chromeos/gdata/test_servers/http_connection.h |
diff --git a/chrome/browser/chromeos/gdata/test_servers/http_connection.h b/chrome/browser/chromeos/gdata/test_servers/http_connection.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1cb4ce39ac2efaf1baf7a4ef3c0f7aa641840561 |
--- /dev/null |
+++ b/chrome/browser/chromeos/gdata/test_servers/http_connection.h |
@@ -0,0 +1,64 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_ |
+#define CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_ |
+ |
+#include <string> |
+#include <sstream> |
satorux1
2012/10/16 03:12:18
unnecessary?
mtomasz
2012/11/08 13:29:59
Done.
|
+#include "base/basictypes.h" |
+#include "net/base/stream_listen_socket.h" |
+#include "chrome/browser/chromeos/gdata/test_servers/http_request.h" |
+ |
+namespace gdata { |
+namespace test_servers { |
+ |
+class HttpConnection; |
+class HttpResponse; |
+ |
+// Delegate associated with a connection which handles requests. |
+class HttpConnectionDelegate { |
+ public: |
+ HttpConnectionDelegate() {} |
+ virtual ~HttpConnectionDelegate() {} |
+ |
+ // Delegate method called when a request is parsed. Response should be sent |
+ // using HttpConnection::SendResponse() on the |connection| argument. |
+ // If returns false, then the connection will be closed. |
+ virtual bool HandleRequest(HttpConnection& connection, |
+ scoped_ptr<HttpRequest> request) = 0; |
+}; |
satorux1
2012/10/16 03:12:18
Since this delegate class only has one function, I
mtomasz
2012/11/08 13:29:59
Done.
|
+ |
+// Wraps the connection socket. Accepts incoming data and sends responses. |
+// If a valid request is parsed, then OnRequest() method on the delegate is |
+// called. |
+class HttpConnection { |
+ public: |
+ HttpConnection(net::StreamListenSocket* socket, |
+ HttpConnectionDelegate* delegate); |
+ virtual ~HttpConnection(); |
+ |
+ // Sends the HTTP response to the client. |
+ virtual void SendResponse(scoped_ptr<HttpResponse> response); |
+ |
+ private: |
+ friend class HttpServer; |
+ |
+ // Accepts raw chunk of data from the client. Internally, passes it to the |
satorux1
2012/10/16 03:12:18
Can we assume that |data| and |length| given here
mtomasz
2012/11/08 13:29:59
We can't assume that. It can be any piece of the r
|
+ // HttpRequestParser class. If a request is parsed, then OnRequest() method |
+ // on the delegate is called. If a syntax error occurs during parsing, |
+ // then returns false. |
+ virtual bool ReceiveData(const char* data, int length); |
+ |
+ scoped_refptr<net::StreamListenSocket> socket_; |
+ HttpConnectionDelegate* delegate_; // Does not own. |
+ HttpRequestParser request_parser_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(HttpConnection); |
+}; |
+ |
+} // namespace test_servers |
+} // namespace gdata |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_ |