Chromium Code Reviews| 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..0664f1465ee4e9fa009e891b624ce66199acf4da |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/gdata/test_servers/http_connection.h |
| @@ -0,0 +1,59 @@ |
| +// 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> |
| +#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; |
| + |
| +class HttpConnectionDelegate { |
| + public: |
| + HttpConnectionDelegate() {} |
| + virtual ~HttpConnectionDelegate() {} |
| + virtual bool HandleRequest(HttpConnection& connection, |
|
satorux1
2012/10/12 08:29:18
function comment missing.
mtomasz
2012/10/12 11:09:46
Done.
|
| + scoped_ptr<HttpRequest> request) = 0; |
| +}; |
| + |
| +// 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; |
| + |
| + scoped_refptr<net::StreamListenSocket> socket_; |
| + HttpConnectionDelegate* delegate_; // Does not own. |
| + HttpRequestParser request_parser_; |
| + |
| + // Accepts raw chunk of data from the client. Internally, passes it to the |
| + // 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); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HttpConnection); |
| +}; |
| + |
| +} // namespace test_servers |
| +} // namespace gdata |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_ |