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