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_SERVER_HTTP_CONNECTION_H_ | 5 #ifndef NET_SERVER_HTTP_CONNECTION_H_ |
6 #define NET_SERVER_HTTP_CONNECTION_H_ | 6 #define NET_SERVER_HTTP_CONNECTION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "net/http/http_status_code.h" | 13 #include "net/http/http_status_code.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class HttpServer; | 17 class HttpServer; |
| 18 class HttpServerResponseInfo; |
18 class StreamListenSocket; | 19 class StreamListenSocket; |
19 class WebSocket; | 20 class WebSocket; |
20 | 21 |
21 class HttpConnection { | 22 class HttpConnection { |
22 public: | 23 public: |
23 ~HttpConnection(); | 24 ~HttpConnection(); |
24 | 25 |
25 void Send(const std::string& data); | 26 void Send(const std::string& data); |
26 void Send(const char* bytes, int len); | 27 void Send(const char* bytes, int len); |
27 void Send(HttpStatusCode status_code, | 28 void Send(const HttpServerResponseInfo& response); |
28 const std::string& data, | |
29 const std::string& content_type); | |
30 | 29 |
31 void Shift(int num_bytes); | 30 void Shift(int num_bytes); |
32 | 31 |
33 const std::string& recv_data() const { return recv_data_; } | 32 const std::string& recv_data() const { return recv_data_; } |
34 int id() const { return id_; } | 33 int id() const { return id_; } |
35 | 34 |
36 private: | 35 private: |
37 friend class HttpServer; | 36 friend class HttpServer; |
38 static int last_id_; | 37 static int last_id_; |
39 | 38 |
40 HttpConnection(HttpServer* server, StreamListenSocket* sock); | 39 HttpConnection(HttpServer* server, StreamListenSocket* sock); |
41 | 40 |
42 void DetachSocket(); | 41 void DetachSocket(); |
43 | 42 |
44 HttpServer* server_; | 43 HttpServer* server_; |
45 scoped_refptr<StreamListenSocket> socket_; | 44 scoped_refptr<StreamListenSocket> socket_; |
46 scoped_ptr<WebSocket> web_socket_; | 45 scoped_ptr<WebSocket> web_socket_; |
47 std::string recv_data_; | 46 std::string recv_data_; |
48 int id_; | 47 int id_; |
49 DISALLOW_COPY_AND_ASSIGN(HttpConnection); | 48 DISALLOW_COPY_AND_ASSIGN(HttpConnection); |
50 }; | 49 }; |
51 | 50 |
52 } // namespace net | 51 } // namespace net |
53 | 52 |
54 #endif // NET_SERVER_HTTP_CONNECTION_H_ | 53 #endif // NET_SERVER_HTTP_CONNECTION_H_ |
OLD | NEW |