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

Side by Side Diff: net/web2socket_proxy/web2socket_serv.h

Issue 5484001: Web2socket proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for signed/unsigned confusion + cosmetic Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/web2socket_proxy/web2socket_main.cc ('k') | net/web2socket_proxy/web2socket_serv.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_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_
6 #define NET_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_
7
8 #include <stdint.h>
9
10 #include <list>
11 #include <map>
12
13 #include "base/basictypes.h"
14 #include "net/web2socket_proxy/web2socket.h"
15
16 struct sockaddr;
17
18 class Web2SocketServ {
19 public:
20 static const size_t kReadBufferLimit = 120 * 1024;
21
22 // Limits number of simultaneously open connections.
23 static const size_t kConnPoolLimit = 2000;
24
25 Web2SocketServ(const std::string& origin,
26 struct sockaddr* addr,
27 int addr_len);
28 ~Web2SocketServ();
29
30 void Run();
31
32 void ZapConn(struct Conn*);
33 void MarkConnImportance(struct Conn*, bool important);
34 struct Conn* GetFreshConn();
35 bool IsConnSane(struct Conn*);
36
37 static void OnConnect(int listening_sock, short event, void*);
38
39 // Return true on success.
40 static bool SetNonBlock(int fd);
41 static bool IgnoreSigPipe(void);
42
43 const std::string& origin() const { return origin_; }
44 struct event_base* evbase() { return evbase_; }
45
46 private:
47 // Checked against value of Origin field specified
48 // in a client websocket handshake.
49 std::string origin_;
50
51 // Address to listen incoming websocket connections.
52 struct sockaddr* addr_;
53 int addr_len_;
54
55 // Libevent base.
56 struct event_base* evbase_;
57
58 // Socket to listen incoming websocket connections.
59 int listening_sock_;
60
61 // List of pending connections; We are trying to keep size of this list
62 // below kConnPoolLimit in LRU fashion.
63 typedef std::list<struct Conn*> ConnPool;
64 ConnPool conn_pool_;
65
66 // Reverse map to look up a connection in a conn_pool.
67 typedef std::map<struct Conn*, ConnPool::iterator> RevMap;
68 RevMap rev_map_;
69
70 DISALLOW_COPY_AND_ASSIGN(Web2SocketServ);
71 };
72
73 #endif // NET_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_
OLDNEW
« no previous file with comments | « net/web2socket_proxy/web2socket_main.cc ('k') | net/web2socket_proxy/web2socket_serv.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698