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..2a7a6044318aee37920a2bb702cbd51c9c1ce0d4 |
--- /dev/null |
+++ b/net/web2socket_proxy/web2socket_serv.h |
@@ -0,0 +1,61 @@ |
+// 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 CHROME_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_ |
+#define CHROME_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_ |
+ |
+#include <list> |
+#include <map> |
+#include <stdint.h> |
tyoshino (SeeGerritForStatus)
2010/12/03 07:53:33
C system file go first
Denis Lagno
2010/12/03 16:28:50
Done.
|
+ |
+#include "base/basictypes.h" |
+#include "net/web2socket_proxy/web2socket.h" |
+ |
+class Web2SocketServ { |
+ public: |
+ Web2SocketServ(const std::string& origin = std::string(), |
+ int port = 10101); |
+ void Run(); |
+ ~Web2SocketServ(); |
+ |
+ static const size_t kConnPoolLimit = 144; |
+ static const size_t kReadBufferLimit = 128 * 1024; |
+ |
+ 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); |
+ |
+ // Checked against value of Origin field specified |
+ // in a client websocket handshake. |
+ std::string origin_; |
+ |
+ // Network port for server to listen incoming websocket connections. |
+ int port_; |
+ |
+ // 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 // CHROME_WEB2SOCKET_PROXY_WEB2SOCKET_SERV_H_ |