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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/web2socket_proxy/web2socket_main.cc ('k') | net/web2socket_proxy/web2socket_serv.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/web2socket_proxy/web2socket_serv.h
diff --git a/net/web2socket_proxy/web2socket_serv.h b/net/web2socket_proxy/web2socket_serv.h
new file mode 100644
index 0000000000000000000000000000000000000000..2a58dc5724f985351138167b9830e7241d9a46bb
--- /dev/null
+++ b/net/web2socket_proxy/web2socket_serv.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_
+#define NET_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_
+
+#include <stdint.h>
+
+#include <list>
+#include <map>
+
+#include "base/basictypes.h"
+#include "net/web2socket_proxy/web2socket.h"
+
+struct sockaddr;
+
+class Web2SocketServ {
+ public:
+ static const size_t kReadBufferLimit = 120 * 1024;
+
+ // Limits number of simultaneously open connections.
+ static const size_t kConnPoolLimit = 2000;
+
+ Web2SocketServ(const std::string& origin,
+ struct sockaddr* addr,
+ int addr_len);
+ ~Web2SocketServ();
+
+ void Run();
+
+ void ZapConn(struct Conn*);
+ void MarkConnImportance(struct Conn*, bool important);
+ struct Conn* GetFreshConn();
+ bool IsConnSane(struct Conn*);
+
+ static void OnConnect(int listening_sock, short event, void*);
+
+ // Return true on success.
+ static bool SetNonBlock(int fd);
+ static bool IgnoreSigPipe(void);
+
+ const std::string& origin() const { return origin_; }
+ struct event_base* evbase() { return evbase_; }
+
+ private:
+ // Checked against value of Origin field specified
+ // in a client websocket handshake.
+ std::string origin_;
+
+ // Address to listen incoming websocket connections.
+ struct sockaddr* addr_;
+ int addr_len_;
+
+ // Libevent base.
+ struct event_base* evbase_;
+
+ // Socket to listen incoming websocket connections.
+ int listening_sock_;
+
+ // List of pending connections; We are trying to keep size of this list
+ // below kConnPoolLimit in LRU fashion.
+ typedef std::list<struct Conn*> ConnPool;
+ ConnPool conn_pool_;
+
+ // Reverse map to look up a connection in a conn_pool.
+ typedef std::map<struct Conn*, ConnPool::iterator> RevMap;
+ RevMap rev_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(Web2SocketServ);
+};
+
+#endif // NET_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_
« 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