Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: net/server/http_listen_socket.h

Issue 2868036: Brushed up listen socket: (Closed)
Patch Set: Lint. Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/net.gyp ('k') | net/server/http_listen_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_SERVER_HTTP_LISTEN_SOCKET_H_
6 #define NET_SERVER_HTTP_LISTEN_SOCKET_H_
7
8 #include "net/base/listen_socket.h"
9
10 class HttpServerRequestInfo;
11
12 // Implements a simple HTTP listen socket on top of the raw socket interface.
13 class HttpListenSocket : public ListenSocket,
14 public ListenSocket::ListenSocketDelegate {
15 public:
16 class Delegate {
17 public:
18 virtual void OnHttpRequest(HttpListenSocket* socket,
19 HttpServerRequestInfo* info) = 0;
20
21 virtual void OnWebSocketRequest(HttpListenSocket* socket,
22 HttpServerRequestInfo* info) = 0;
23
24 virtual void OnWebSocketMessage(HttpListenSocket* socket,
25 const std::string& data) = 0;
26
27 virtual void OnClose(HttpListenSocket* socket) = 0;
28 protected:
29 virtual ~Delegate() {}
30 };
31
32 static HttpListenSocket* Listen(const std::string& ip,
33 int port,
34 HttpListenSocket::Delegate* delegate);
35
36 void AcceptWebSocket(HttpServerRequestInfo* request);
37
38 void SendOverWebSocket(const std::string& data);
39
40 void Listen() { ListenSocket::Listen(); }
41 virtual void Accept();
42
43 // ListenSocketDelegate
44 virtual void DidAccept(ListenSocket* server, ListenSocket* connection);
45 virtual void DidRead(ListenSocket* connection, const char* data, int len);
46 virtual void DidClose(ListenSocket* sock);
47
48 private:
49 static const int kReadBufSize = 16 * 1024;
50 HttpListenSocket(SOCKET s, HttpListenSocket::Delegate* del);
51 virtual ~HttpListenSocket();
52
53 // Expects the raw data to be stored in recv_data_. If parsing is successful,
54 // will remove the data parsed from recv_data_, leaving only the unused
55 // recv data.
56 HttpServerRequestInfo* ParseHeaders();
57
58 HttpListenSocket::Delegate* delegate_;
59 bool is_web_socket_;
60 std::string recv_data_;
61
62 DISALLOW_COPY_AND_ASSIGN(HttpListenSocket);
63 };
64
65 #endif // NET_SERVER_HTTP_LISTEN_SOCKET_H_
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | net/server/http_listen_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698