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

Side by Side Diff: chrome/browser/chromeos/gdata/test_servers/http_connection.h

Issue 11088073: HTTP server for testing Google Drive. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments. Created 8 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 unified diff | Download patch
OLDNEW
(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>
satorux1 2012/10/16 03:12:18 unnecessary?
mtomasz 2012/11/08 13:29:59 Done.
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 // Delegate associated with a connection which handles requests.
21 class HttpConnectionDelegate {
22 public:
23 HttpConnectionDelegate() {}
24 virtual ~HttpConnectionDelegate() {}
25
26 // Delegate method called when a request is parsed. Response should be sent
27 // using HttpConnection::SendResponse() on the |connection| argument.
28 // If returns false, then the connection will be closed.
29 virtual bool HandleRequest(HttpConnection& connection,
30 scoped_ptr<HttpRequest> request) = 0;
31 };
satorux1 2012/10/16 03:12:18 Since this delegate class only has one function, I
mtomasz 2012/11/08 13:29:59 Done.
32
33 // Wraps the connection socket. Accepts incoming data and sends responses.
34 // If a valid request is parsed, then OnRequest() method on the delegate is
35 // called.
36 class HttpConnection {
37 public:
38 HttpConnection(net::StreamListenSocket* socket,
39 HttpConnectionDelegate* delegate);
40 virtual ~HttpConnection();
41
42 // Sends the HTTP response to the client.
43 virtual void SendResponse(scoped_ptr<HttpResponse> response);
44
45 private:
46 friend class HttpServer;
47
48 // 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
49 // HttpRequestParser class. If a request is parsed, then OnRequest() method
50 // on the delegate is called. If a syntax error occurs during parsing,
51 // then returns false.
52 virtual bool ReceiveData(const char* data, int length);
53
54 scoped_refptr<net::StreamListenSocket> socket_;
55 HttpConnectionDelegate* delegate_; // Does not own.
56 HttpRequestParser request_parser_;
57
58 DISALLOW_COPY_AND_ASSIGN(HttpConnection);
59 };
60
61 } // namespace test_servers
62 } // namespace gdata
63
64 #endif // CHROME_BROWSER_CHROMEOS_GDATA_TEST_SERVERS_HTTP_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698