| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 void DetachSocket(); | 64 void DetachSocket(); |
| 65 | 65 |
| 66 void Shift(int num_bytes); | 66 void Shift(int num_bytes); |
| 67 | 67 |
| 68 HttpServer* server_; | 68 HttpServer* server_; |
| 69 scoped_refptr<ListenSocket> socket_; | 69 scoped_refptr<ListenSocket> socket_; |
| 70 bool is_web_socket_; | 70 bool is_web_socket_; |
| 71 std::string recv_data_; | 71 std::string recv_data_; |
| 72 int id_; | 72 int id_; |
| 73 bool use_hixie76_web_socket_; |
| 73 | 74 |
| 74 DISALLOW_COPY_AND_ASSIGN(Connection); | 75 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 75 }; | 76 }; |
| 76 friend class Connection; | 77 friend class Connection; |
| 77 | 78 |
| 79 void AcceptWebSocketHyBi10(Connection* connection, |
| 80 const HttpServerRequestInfo& request); |
| 81 void SendOverWebSocketHyBi10(Connection* connection, const std::string& data); |
| 82 |
| 83 bool DidReadWebSocketHyBi10(Connection* connection, |
| 84 char* data, |
| 85 size_t length, |
| 86 std::string* message); |
| 87 |
| 88 void AcceptWebSocketHixie76(Connection* connection, |
| 89 const HttpServerRequestInfo& request); |
| 90 void SendOverWebSocketHixie76(Connection* connection, |
| 91 const std::string& data); |
| 78 | 92 |
| 79 // ListenSocketDelegate | 93 // ListenSocketDelegate |
| 80 virtual void DidAccept(ListenSocket* server, ListenSocket* socket); | 94 virtual void DidAccept(ListenSocket* server, ListenSocket* socket); |
| 81 virtual void DidRead(ListenSocket* socket, const char* data, int len); | 95 virtual void DidRead(ListenSocket* socket, const char* data, int len); |
| 82 virtual void DidClose(ListenSocket* socket); | 96 virtual void DidClose(ListenSocket* socket); |
| 83 | 97 |
| 84 // Expects the raw data to be stored in recv_data_. If parsing is successful, | 98 // Expects the raw data to be stored in recv_data_. If parsing is successful, |
| 85 // will remove the data parsed from recv_data_, leaving only the unused | 99 // will remove the data parsed from recv_data_, leaving only the unused |
| 86 // recv data. | 100 // recv data. |
| 87 bool ParseHeaders(Connection* connection, | 101 bool ParseHeaders(Connection* connection, |
| 88 HttpServerRequestInfo* info, | 102 HttpServerRequestInfo* info, |
| 89 int* ppos); | 103 int* ppos); |
| 90 | 104 |
| 91 Connection* FindConnection(int connection_id); | 105 Connection* FindConnection(int connection_id); |
| 92 Connection* FindConnection(ListenSocket* socket); | 106 Connection* FindConnection(ListenSocket* socket); |
| 93 | 107 |
| 94 HttpServer::Delegate* delegate_; | 108 HttpServer::Delegate* delegate_; |
| 95 scoped_refptr<ListenSocket> server_; | 109 scoped_refptr<ListenSocket> server_; |
| 96 typedef std::map<int, Connection*> IdToConnectionMap; | 110 typedef std::map<int, Connection*> IdToConnectionMap; |
| 97 IdToConnectionMap id_to_connection_; | 111 IdToConnectionMap id_to_connection_; |
| 98 typedef std::map<ListenSocket*, Connection*> SocketToConnectionMap; | 112 typedef std::map<ListenSocket*, Connection*> SocketToConnectionMap; |
| 99 SocketToConnectionMap socket_to_connection_; | 113 SocketToConnectionMap socket_to_connection_; |
| 100 | 114 |
| 101 DISALLOW_COPY_AND_ASSIGN(HttpServer); | 115 DISALLOW_COPY_AND_ASSIGN(HttpServer); |
| 102 }; | 116 }; |
| 103 | 117 |
| 104 } // namespace net | 118 } // namespace net |
| 105 | 119 |
| 106 #endif // NET_SERVER_HTTP_SERVER_H_ | 120 #endif // NET_SERVER_HTTP_SERVER_H_ |
| OLD | NEW |