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

Side by Side Diff: chrome/browser/chromeos/drive/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: Fixed for clang. Created 8 years, 1 month 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_DRIVE_TEST_SERVERS_HTTP_CONNECTION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_TEST_SERVERS_HTTP_CONNECTION_H_
7
8 #include <string>
9 #include "base/basictypes.h"
10 #include "net/base/stream_listen_socket.h"
11 #include "chrome/browser/chromeos/drive/test_servers/http_request.h"
12
13 namespace drive {
14 namespace test_servers {
15
16 class HttpConnection;
17 class HttpResponse;
18
19 // Calblack called when a request is parsed. Response should be sent
20 // using HttpConnection::SendResponse() on the |connection| argument.
21 typedef base::Callback<void(HttpConnection* connection,
22 scoped_ptr<HttpRequest> request)>
23 HandleRequestCallback;
24
25 // Wraps the connection socket. Accepts incoming data and sends responses.
26 // If a valid request is parsed, then |callback_| is invoked.
27 class HttpConnection {
28 public:
29 HttpConnection(net::StreamListenSocket* socket,
30 const HandleRequestCallback& callback);
31 virtual ~HttpConnection();
32
33 // Sends the HTTP response to the client.
34 virtual void SendResponse(scoped_ptr<HttpResponse> response) const;
satorux1 2012/11/12 06:07:00 Should this be a virtual function? There are no cl
mtomasz 2012/11/12 12:17:44 Why don't we make public methods virtual by defaul
satorux1 2012/11/13 05:13:18 See YAGNI on wikipedia. :) Besides: 1) It's helpf
mtomasz 2012/11/13 12:23:07 Got it.
35
36 private:
37 friend class HttpTestServer;
38
39 // Accepts raw chunk of data from the client. Internally, passes it to the
40 // HttpRequestParser class. If a request is parsed, then |callback_| is
41 // called.
satorux1 2012/11/12 06:07:00 ditto.
mtomasz 2012/11/12 12:17:44 Done.
42 virtual void ReceiveData(const char* data, size_t length);
satorux1 2012/11/12 06:07:00 Can we use StringPiece instead? One less parameter
mtomasz 2012/11/12 12:17:44 How about just std::string since we don't need any
satorux1 2012/11/13 05:13:18 const std::string& will make a copy if the input i
mtomasz 2012/11/13 12:23:07 Done.
43
44 scoped_refptr<net::StreamListenSocket> socket_;
45 const HandleRequestCallback callback_;
46 HttpRequestParser request_parser_;
47
48 DISALLOW_COPY_AND_ASSIGN(HttpConnection);
49 };
50
51 } // namespace test_servers
52 } // namespace drive
53
54 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_TEST_SERVERS_HTTP_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698