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

Side by Side Diff: chrome/browser/google_apis/test_server/http_connection.h

Issue 11088073: HTTP server for testing Google Drive. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved to chrome/browser/google_apis. 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_GOOGLE_APIS_TEST_SERVER_HTTP_CONNECTION_H_
6 #define CHROME_BROWSER_GOOGLE_APIS_TEST_SERVER_HTTP_CONNECTION_H_
7
8 #include <string>
9 #include "base/basictypes.h"
10 #include "base/string_piece.h"
11 #include "chrome/browser/google_apis/test_server/http_request.h"
12 #include "net/base/stream_listen_socket.h"
13
14 namespace drive {
15 namespace test_server {
16
17 class HttpConnection;
18 class HttpResponse;
19
20 // Calblack called when a request is parsed. Response should be sent
21 // using HttpConnection::SendResponse() on the |connection| argument.
22 typedef base::Callback<void(HttpConnection* connection,
23 scoped_ptr<HttpRequest> request)>
24 HandleRequestCallback;
25
26 // Wraps the connection socket. Accepts incoming data and sends responses.
27 // If a valid request is parsed, then |callback_| is invoked.
28 class HttpConnection {
29 public:
30 HttpConnection(net::StreamListenSocket* socket,
31 const HandleRequestCallback& callback);
32 ~HttpConnection();
33
34 // Sends the HTTP response to the client.
35 void SendResponse(scoped_ptr<HttpResponse> response) const;
36
37 private:
38 friend class HttpServer;
39
40 // Accepts raw chunk of data from the client. Internally, passes it to the
41 // HttpRequestParser class. If a request is parsed, then |callback_| is
42 // called.
43 void ReceiveData(const base::StringPiece& data);
44
45 scoped_refptr<net::StreamListenSocket> socket_;
46 const HandleRequestCallback callback_;
47 HttpRequestParser request_parser_;
48
49 DISALLOW_COPY_AND_ASSIGN(HttpConnection);
50 };
51
52 } // namespace test_server
53 } // namespace drive
54
55 #endif // CHROME_BROWSER_GOOGLE_APIS_TEST_SERVER_HTTP_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698