| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 virtual void OnWebSocketMessage(int connection_id, | 33 virtual void OnWebSocketMessage(int connection_id, |
| 34 const std::string& data) = 0; | 34 const std::string& data) = 0; |
| 35 | 35 |
| 36 virtual void OnClose(int connection_id) = 0; | 36 virtual void OnClose(int connection_id) = 0; |
| 37 protected: | 37 protected: |
| 38 virtual ~Delegate() {} | 38 virtual ~Delegate() {} |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 HttpServer(const std::string& host, int port, HttpServer::Delegate* del); | 41 HttpServer(const std::string& host, int port, HttpServer::Delegate* del); |
| 42 virtual ~HttpServer(); | |
| 43 | 42 |
| 44 void AcceptWebSocket(int connection_id, | 43 void AcceptWebSocket(int connection_id, |
| 45 const HttpServerRequestInfo& request); | 44 const HttpServerRequestInfo& request); |
| 46 void SendOverWebSocket(int connection_id, const std::string& data); | 45 void SendOverWebSocket(int connection_id, const std::string& data); |
| 47 void Send(int connection_id, const std::string& data); | 46 void Send(int connection_id, const std::string& data); |
| 48 void Send(int connection_id, const char* bytes, int len); | 47 void Send(int connection_id, const char* bytes, int len); |
| 49 void Send200(int connection_id, | 48 void Send200(int connection_id, |
| 50 const std::string& data, | 49 const std::string& data, |
| 51 const std::string& mime_type); | 50 const std::string& mime_type); |
| 52 void Send404(int connection_id); | 51 void Send404(int connection_id); |
| 53 void Send500(int connection_id, const std::string& message); | 52 void Send500(int connection_id, const std::string& message); |
| 54 void Close(int connection_id); | 53 void Close(int connection_id); |
| 55 | 54 |
| 56 private: | 55 private: |
| 57 friend class base::RefCountedThreadSafe<HttpServer>; | 56 friend class base::RefCountedThreadSafe<HttpServer>; |
| 58 friend class HttpConnection; | 57 friend class HttpConnection; |
| 59 | 58 |
| 59 virtual ~HttpServer(); |
| 60 |
| 60 // ListenSocketDelegate | 61 // ListenSocketDelegate |
| 61 virtual void DidAccept(ListenSocket* server, ListenSocket* socket) OVERRIDE; | 62 virtual void DidAccept(ListenSocket* server, ListenSocket* socket) OVERRIDE; |
| 62 virtual void DidRead(ListenSocket* socket, | 63 virtual void DidRead(ListenSocket* socket, |
| 63 const char* data, | 64 const char* data, |
| 64 int len) OVERRIDE; | 65 int len) OVERRIDE; |
| 65 virtual void DidClose(ListenSocket* socket) OVERRIDE; | 66 virtual void DidClose(ListenSocket* socket) OVERRIDE; |
| 66 | 67 |
| 67 // Expects the raw data to be stored in recv_data_. If parsing is successful, | 68 // Expects the raw data to be stored in recv_data_. If parsing is successful, |
| 68 // will remove the data parsed from recv_data_, leaving only the unused | 69 // will remove the data parsed from recv_data_, leaving only the unused |
| 69 // recv data. | 70 // recv data. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 80 IdToConnectionMap id_to_connection_; | 81 IdToConnectionMap id_to_connection_; |
| 81 typedef std::map<ListenSocket*, HttpConnection*> SocketToConnectionMap; | 82 typedef std::map<ListenSocket*, HttpConnection*> SocketToConnectionMap; |
| 82 SocketToConnectionMap socket_to_connection_; | 83 SocketToConnectionMap socket_to_connection_; |
| 83 | 84 |
| 84 DISALLOW_COPY_AND_ASSIGN(HttpServer); | 85 DISALLOW_COPY_AND_ASSIGN(HttpServer); |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 } // namespace net | 88 } // namespace net |
| 88 | 89 |
| 89 #endif // NET_SERVER_HTTP_SERVER_H_ | 90 #endif // NET_SERVER_HTTP_SERVER_H_ |
| OLD | NEW |