Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / net / test / embedded_test_server / http_connection.h
blobda9353404c6c840498ba9713707c07b8f2f2bdae
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.
5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_
6 #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_
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 "net/test/embedded_test_server/http_request.h"
14 namespace net {
16 class StreamListenSocket;
18 namespace test_server {
20 class HttpConnection;
21 class HttpResponse;
23 // Calblack called when a request is parsed. Response should be sent
24 // using HttpConnection::SendResponse() on the |connection| argument.
25 typedef base::Callback<void(HttpConnection* connection,
26 scoped_ptr<HttpRequest> request)>
27 HandleRequestCallback;
29 // Wraps the connection socket. Accepts incoming data and sends responses.
30 // If a valid request is parsed, then |callback_| is invoked.
31 class HttpConnection {
32 public:
33 HttpConnection(StreamListenSocket* socket,
34 const HandleRequestCallback& callback);
35 ~HttpConnection();
37 // Sends the HTTP response to the client.
38 void SendResponse(scoped_ptr<HttpResponse> response) const;
40 private:
41 friend class EmbeddedTestServer;
43 // Accepts raw chunk of data from the client. Internally, passes it to the
44 // HttpRequestParser class. If a request is parsed, then |callback_| is
45 // called.
46 void ReceiveData(const base::StringPiece& data);
48 scoped_refptr<StreamListenSocket> socket_;
49 const HandleRequestCallback callback_;
50 HttpRequestParser request_parser_;
52 DISALLOW_COPY_AND_ASSIGN(HttpConnection);
55 } // namespace test_server
56 } // namespace net
58 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_CONNECTION_H_