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

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

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

Powered by Google App Engine
This is Rietveld 408576698