Chromium Code Reviews| Index: net/server/http_server.h |
| diff --git a/net/server/http_server.h b/net/server/http_server.h |
| index 4309d122f1ead040eb28f2c2557a489b9fbff1b6..acb5249a5d5c87c0f95308cd3e1d32abe3ce371d 100644 |
| --- a/net/server/http_server.h |
| +++ b/net/server/http_server.h |
| @@ -10,19 +10,21 @@ |
| #include "base/basictypes.h" |
|
mmenke
2014/05/23 19:20:58
Should use macros.h instead (To make sure we get b
byungchul
2014/05/30 00:19:02
Done.
|
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "net/http/http_status_code.h" |
| -#include "net/socket/stream_listen_socket.h" |
| +#include "net/server/http_connection.h" |
| namespace net { |
| -class HttpConnection; |
| class HttpServerRequestInfo; |
| class HttpServerResponseInfo; |
| class IPEndPoint; |
| +class ServerSocket; |
| +class StreamSocket; |
| class WebSocket; |
| -class HttpServer : public StreamListenSocket::Delegate, |
| - public base::RefCountedThreadSafe<HttpServer> { |
| +class HttpServer : public HttpConnection::Delegate, |
| + public base::SupportsWeakPtr<HttpServer> { |
|
mmenke
2014/05/23 19:20:58
WeakPtrs shouldn't be exposed to external classes
mmenke
2014/05/23 19:20:58
This class should be declared with NEXT_EXPORT, sh
byungchul
2014/05/28 01:19:35
NEXT_EXPORT is only for shared lib. Not sure which
Ryan Sleevi
2014/05/28 01:36:26
All of our platforms do component builds on the wa
byungchul
2014/05/30 00:19:02
Done.
byungchul
2014/06/08 17:24:27
Turned out that http_server is built as a static l
|
| public: |
| class Delegate { |
| public: |
| @@ -36,13 +38,11 @@ class HttpServer : public StreamListenSocket::Delegate, |
| const std::string& data) = 0; |
| virtual void OnClose(int connection_id) = 0; |
| - |
| - protected: |
| - virtual ~Delegate() {} |
| }; |
| - HttpServer(const StreamListenSocketFactory& socket_factory, |
| + HttpServer(scoped_ptr<ServerSocket> server_socket, |
| HttpServer::Delegate* delegate); |
| + virtual ~HttpServer(); |
| void AcceptWebSocket(int connection_id, |
| const HttpServerRequestInfo& request); |
| @@ -67,37 +67,35 @@ class HttpServer : public StreamListenSocket::Delegate, |
| // Copies the local address to |address|. Returns a network error code. |
| int GetLocalAddress(IPEndPoint* address); |
| - // ListenSocketDelegate |
| - virtual void DidAccept(StreamListenSocket* server, |
| - scoped_ptr<StreamListenSocket> socket) OVERRIDE; |
| - virtual void DidRead(StreamListenSocket* socket, |
| - const char* data, |
| - int len) OVERRIDE; |
| - virtual void DidClose(StreamListenSocket* socket) OVERRIDE; |
| + private: |
| + friend class HttpServerTest; |
| - protected: |
| - virtual ~HttpServer(); |
| + typedef std::map<int, HttpConnection*> IdToConnectionMap; |
| - private: |
| - friend class base::RefCountedThreadSafe<HttpServer>; |
| - friend class HttpConnection; |
| + void DoAcceptLoop(int rv); |
| + void OnAcceptCompleted(int rv); |
| + int DidAccept(int rv); |
| + |
| + // HttpConnection::Delegate |
| + virtual void DidRead(HttpConnection* conn) OVERRIDE; |
| + virtual void DidClose(HttpConnection* conn) OVERRIDE; |
| // Expects the raw data to be stored in recv_data_. If parsing is successful, |
| // will remove the data parsed from recv_data_, leaving only the unused |
| // recv data. |
| - bool ParseHeaders(HttpConnection* connection, |
| + bool ParseHeaders(const char* data, |
| + size_t data_len, |
| HttpServerRequestInfo* info, |
| size_t* pos); |
| HttpConnection* FindConnection(int connection_id); |
| - HttpConnection* FindConnection(StreamListenSocket* socket); |
| - HttpServer::Delegate* delegate_; |
| - scoped_ptr<StreamListenSocket> server_; |
| - typedef std::map<int, HttpConnection*> IdToConnectionMap; |
| + const scoped_ptr<ServerSocket> server_socket_; |
| + scoped_ptr<StreamSocket> accepted_socket_; |
| + HttpServer::Delegate* const delegate_; |
| + |
| + int last_id_; |
| IdToConnectionMap id_to_connection_; |
| - typedef std::map<StreamListenSocket*, HttpConnection*> SocketToConnectionMap; |
| - SocketToConnectionMap socket_to_connection_; |
| DISALLOW_COPY_AND_ASSIGN(HttpServer); |
| }; |