Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <sstream> | |
| 10 #include "base/basictypes.h" | |
| 11 #include "net/base/stream_listen_socket.h" | |
| 12 #include "chrome/browser/chromeos/gdata/test_servers/http_request.h" | |
| 13 | |
| 14 namespace gdata { | |
| 15 namespace test_servers { | |
| 16 | |
| 17 class HttpConnection; | |
| 18 class HttpResponse; | |
| 19 | |
| 20 class HttpConnectionDelegate { | |
| 21 public: | |
| 22 HttpConnectionDelegate() {} | |
| 23 virtual ~HttpConnectionDelegate() {} | |
| 24 virtual bool HandleRequest(HttpConnection& connection, | |
|
satorux1
2012/10/12 08:29:18
function comment missing.
mtomasz
2012/10/12 11:09:46
Done.
| |
| 25 scoped_ptr<HttpRequest> request) = 0; | |
| 26 }; | |
| 27 | |
| 28 // Wraps the connection socket. Accepts incoming data and sends responses. | |
| 29 // If a valid request is parsed, then OnRequest() method on the delegate is | |
| 30 // called. | |
| 31 class HttpConnection { | |
| 32 public: | |
| 33 HttpConnection(net::StreamListenSocket* socket, | |
| 34 HttpConnectionDelegate* delegate); | |
| 35 virtual ~HttpConnection(); | |
| 36 | |
| 37 // Sends the HTTP response to the client. | |
| 38 virtual void SendResponse(scoped_ptr<HttpResponse> response); | |
| 39 | |
| 40 private: | |
| 41 friend class HttpServer; | |
| 42 | |
| 43 scoped_refptr<net::StreamListenSocket> socket_; | |
| 44 HttpConnectionDelegate* delegate_; // Does not own. | |
| 45 HttpRequestParser request_parser_; | |
| 46 | |
| 47 // Accepts raw chunk of data from the client. Internally, passes it to the | |
| 48 // HttpRequestParser class. If a request is parsed, then OnRequest() method | |
| 49 // on the delegate is called. If a syntax error occurs during parsing, | |
| 50 // then returns false. | |
| 51 virtual bool ReceiveData(const char* data, int length); | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(HttpConnection); | |
| 54 }; | |
| 55 | |
| 56 } // namespace test_servers | |
| 57 } // namespace gdata | |
| 58 | |
| 59 #endif // CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_ | |
| OLD | NEW |