OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ | 5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ |
6 #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ | 6 #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 #include "net/test/embedded_test_server/http_request.h" | 11 #include "net/test/embedded_test_server/http_request.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 class StreamListenSocket; | 15 class StreamListenSocket; |
16 | 16 |
17 namespace test_server { | 17 namespace test_server { |
18 | 18 |
19 class HttpConnection; | 19 class HttpConnection; |
20 class HttpResponse; | 20 class HttpResponse; |
21 | 21 |
22 // Calblack called when a request is parsed. Response should be sent | 22 // Calblack called when a request is parsed. Response should be sent |
23 // using HttpConnection::SendResponse() on the |connection| argument. | 23 // using HttpConnection::SendResponse() on the |connection| argument. |
24 typedef base::Callback<void(HttpConnection* connection, | 24 typedef base::Callback< |
25 scoped_ptr<HttpRequest> request)> | 25 void(HttpConnection* connection, scoped_ptr<HttpRequest> request)> |
26 HandleRequestCallback; | 26 HandleRequestCallback; |
27 | 27 |
28 // Wraps the connection socket. Accepts incoming data and sends responses. | 28 // Wraps the connection socket. Accepts incoming data and sends responses. |
29 // If a valid request is parsed, then |callback_| is invoked. | 29 // If a valid request is parsed, then |callback_| is invoked. |
30 class HttpConnection { | 30 class HttpConnection { |
31 public: | 31 public: |
32 HttpConnection(scoped_ptr<StreamListenSocket> socket, | 32 HttpConnection(scoped_ptr<StreamListenSocket> socket, |
33 const HandleRequestCallback& callback); | 33 const HandleRequestCallback& callback); |
34 ~HttpConnection(); | 34 ~HttpConnection(); |
35 | 35 |
(...skipping 12 matching lines...) Expand all Loading... |
48 const HandleRequestCallback callback_; | 48 const HandleRequestCallback callback_; |
49 HttpRequestParser request_parser_; | 49 HttpRequestParser request_parser_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(HttpConnection); | 51 DISALLOW_COPY_AND_ASSIGN(HttpConnection); |
52 }; | 52 }; |
53 | 53 |
54 } // namespace test_server | 54 } // namespace test_server |
55 } // namespace net | 55 } // namespace net |
56 | 56 |
57 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ | 57 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_ |
OLD | NEW |