Chromium Code Reviews| 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_SERVER_H_ | 5 #ifndef NET_SERVER_HTTP_SERVER_H_ |
| 6 #define NET_SERVER_HTTP_SERVER_H_ | 6 #define NET_SERVER_HTTP_SERVER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 virtual void OnConnect(int connection_id) = 0; | 33 virtual void OnConnect(int connection_id) = 0; |
| 34 virtual void OnHttpRequest(int connection_id, | 34 virtual void OnHttpRequest(int connection_id, |
| 35 const HttpServerRequestInfo& info) = 0; | 35 const HttpServerRequestInfo& info) = 0; |
| 36 virtual void OnWebSocketRequest(int connection_id, | 36 virtual void OnWebSocketRequest(int connection_id, |
| 37 const HttpServerRequestInfo& info) = 0; | 37 const HttpServerRequestInfo& info) = 0; |
| 38 virtual void OnWebSocketMessage(int connection_id, | 38 virtual void OnWebSocketMessage(int connection_id, |
| 39 const std::string& data) = 0; | 39 const std::string& data) = 0; |
| 40 virtual void OnClose(int connection_id) = 0; | 40 virtual void OnClose(int connection_id) = 0; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // Instantiates a http server with |server_socket| which already started | |
| 44 // listening, but not accepting. This constructor schedules accepting | |
| 45 // connections in next run loop in case when |delegate| is not ready to get | |
|
mmenke
2014/10/31 18:23:02
nit: Maybe just "next run loop" -> "asynchronousl
byungchul
2014/10/31 18:42:56
Done.
| |
| 46 // callbacks yet. | |
| 43 HttpServer(scoped_ptr<ServerSocket> server_socket, | 47 HttpServer(scoped_ptr<ServerSocket> server_socket, |
| 44 HttpServer::Delegate* delegate); | 48 HttpServer::Delegate* delegate); |
| 45 ~HttpServer(); | 49 ~HttpServer(); |
| 46 | 50 |
| 47 void AcceptWebSocket(int connection_id, | 51 void AcceptWebSocket(int connection_id, |
| 48 const HttpServerRequestInfo& request); | 52 const HttpServerRequestInfo& request); |
| 49 void SendOverWebSocket(int connection_id, const std::string& data); | 53 void SendOverWebSocket(int connection_id, const std::string& data); |
| 50 // Sends the provided data directly to the given connection. No validation is | 54 // Sends the provided data directly to the given connection. No validation is |
| 51 // performed that data constitutes a valid HTTP response. A valid HTTP | 55 // performed that data constitutes a valid HTTP response. A valid HTTP |
| 52 // response may be split across multiple calls to SendRaw. | 56 // response may be split across multiple calls to SendRaw. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 IdToConnectionMap id_to_connection_; | 113 IdToConnectionMap id_to_connection_; |
| 110 | 114 |
| 111 base::WeakPtrFactory<HttpServer> weak_ptr_factory_; | 115 base::WeakPtrFactory<HttpServer> weak_ptr_factory_; |
| 112 | 116 |
| 113 DISALLOW_COPY_AND_ASSIGN(HttpServer); | 117 DISALLOW_COPY_AND_ASSIGN(HttpServer); |
| 114 }; | 118 }; |
| 115 | 119 |
| 116 } // namespace net | 120 } // namespace net |
| 117 | 121 |
| 118 #endif // NET_SERVER_HTTP_SERVER_H_ | 122 #endif // NET_SERVER_HTTP_SERVER_H_ |
| OLD | NEW |