| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 const std::string& mime_type); | 51 const std::string& mime_type); |
| 52 void Send404(int connection_id); | 52 void Send404(int connection_id); |
| 53 void Send500(int connection_id, const std::string& message); | 53 void Send500(int connection_id, const std::string& message); |
| 54 void Close(int connection_id); | 54 void Close(int connection_id); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 friend class base::RefCountedThreadSafe<HttpServer>; | 57 friend class base::RefCountedThreadSafe<HttpServer>; |
| 58 friend class HttpConnection; | 58 friend class HttpConnection; |
| 59 | 59 |
| 60 // ListenSocketDelegate | 60 // ListenSocketDelegate |
| 61 virtual void DidAccept(ListenSocket* server, ListenSocket* socket); | 61 virtual void DidAccept(ListenSocket* server, ListenSocket* socket) OVERRIDE; |
| 62 virtual void DidRead(ListenSocket* socket, const char* data, int len); | 62 virtual void DidRead(ListenSocket* socket, |
| 63 virtual void DidClose(ListenSocket* socket); | 63 const char* data, |
| 64 int len) OVERRIDE; |
| 65 virtual void DidClose(ListenSocket* socket) OVERRIDE; |
| 64 | 66 |
| 65 // Expects the raw data to be stored in recv_data_. If parsing is successful, | 67 // Expects the raw data to be stored in recv_data_. If parsing is successful, |
| 66 // will remove the data parsed from recv_data_, leaving only the unused | 68 // will remove the data parsed from recv_data_, leaving only the unused |
| 67 // recv data. | 69 // recv data. |
| 68 bool ParseHeaders(HttpConnection* connection, | 70 bool ParseHeaders(HttpConnection* connection, |
| 69 HttpServerRequestInfo* info, | 71 HttpServerRequestInfo* info, |
| 70 size_t* pos); | 72 size_t* pos); |
| 71 | 73 |
| 72 HttpConnection* FindConnection(int connection_id); | 74 HttpConnection* FindConnection(int connection_id); |
| 73 HttpConnection* FindConnection(ListenSocket* socket); | 75 HttpConnection* FindConnection(ListenSocket* socket); |
| 74 | 76 |
| 75 HttpServer::Delegate* delegate_; | 77 HttpServer::Delegate* delegate_; |
| 76 scoped_refptr<ListenSocket> server_; | 78 scoped_refptr<ListenSocket> server_; |
| 77 typedef std::map<int, HttpConnection*> IdToConnectionMap; | 79 typedef std::map<int, HttpConnection*> IdToConnectionMap; |
| 78 IdToConnectionMap id_to_connection_; | 80 IdToConnectionMap id_to_connection_; |
| 79 typedef std::map<ListenSocket*, HttpConnection*> SocketToConnectionMap; | 81 typedef std::map<ListenSocket*, HttpConnection*> SocketToConnectionMap; |
| 80 SocketToConnectionMap socket_to_connection_; | 82 SocketToConnectionMap socket_to_connection_; |
| 81 | 83 |
| 82 DISALLOW_COPY_AND_ASSIGN(HttpServer); | 84 DISALLOW_COPY_AND_ASSIGN(HttpServer); |
| 83 }; | 85 }; |
| 84 | 86 |
| 85 } // namespace net | 87 } // namespace net |
| 86 | 88 |
| 87 #endif // NET_SERVER_HTTP_SERVER_H_ | 89 #endif // NET_SERVER_HTTP_SERVER_H_ |
| OLD | NEW |