Chromium Code Reviews| Index: chrome/browser/chromeos/net/webproxy/serv.h |
| diff --git a/chrome/browser/chromeos/net/webproxy/serv.h b/chrome/browser/chromeos/net/webproxy/serv.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b8501c8c7246cf2467a2602014ff4dcbf984f84b |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/net/webproxy/serv.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright (c) 2011 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_BROWSER_CHROMEOS_NET_WEBPROXY_SERV_H_ |
| +#define CHROME_BROWSER_CHROMEOS_NET_WEBPROXY_SERV_H_ |
| + |
| +#include <list> |
| +#include <map> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| + |
| +struct sockaddr; |
| +struct event_base; |
| + |
| +namespace chromeos { |
| +namespace webproxy { |
| + |
| +class Serv { |
|
zel
2011/04/07 16:54:12
comments please - what does this class do?
Denis Lagno
2011/04/11 23:21:27
Done.
|
| + public: |
| + static const size_t kReadBufferLimit = 120 * 1024; |
| + |
| + // Limits number of simultaneously open connections. |
| + static const size_t kConnPoolLimit = 2000; |
| + |
| + Serv(const std::vector<std::string>& allowed_origins, |
| + struct sockaddr* addr, int addr_len); |
| + ~Serv(); |
| + |
| + void Run(); |
| + |
| + void ZapConn(struct Conn*); |
| + void MarkConnImportance(struct Conn*, bool important); |
| + struct Conn* GetFreshConn(); |
| + bool IsConnSane(struct Conn*); |
| + bool IsOriginAllowed(const std::string& origin); |
| + |
| + static void OnConnect(int listening_sock, short event, void*); |
| + |
| + // Return true on success. |
| + static bool SetNonBlock(int fd); |
| + static bool IgnoreSigPipe(void); |
| + |
| + struct event_base* evbase() { return evbase_; } |
| + |
| + private: |
| + // Checked against value of Origin field specified |
| + // in a client websocket handshake. |
| + std::vector<std::string> allowed_origins_; |
| + |
| + // 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(Serv); |
| +}; |
| + |
| +} // namespace chromeos |
| +} // namespace webproxy |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_NET_WEBPROXY_SERV_H_ |