Ignore non-active fullscreen windows for shelf state.
[chromium-blink-merge.git] / content / browser / renderer_host / p2p / socket_host_tcp_server.h
blob2581e83ee7e71f476bd7003d8517cad92ec61e93
1 // Copyright (c) 2011 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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_
8 #include <map>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "content/browser/renderer_host/p2p/socket_host.h"
15 #include "content/common/content_export.h"
16 #include "content/public/common/p2p_socket_type.h"
17 #include "ipc/ipc_sender.h"
18 #include "net/base/completion_callback.h"
19 #include "net/socket/tcp_server_socket.h"
21 namespace net {
22 class StreamSocket;
23 } // namespace net
25 namespace content {
27 class CONTENT_EXPORT P2PSocketHostTcpServer : public P2PSocketHost {
28 public:
29 typedef std::map<net::IPEndPoint, net::StreamSocket*> AcceptedSocketsMap;
31 P2PSocketHostTcpServer(IPC::Sender* message_sender, int id,
32 P2PSocketType client_type);
33 virtual ~P2PSocketHostTcpServer();
35 // P2PSocketHost overrides.
36 virtual bool Init(const net::IPEndPoint& local_address,
37 const net::IPEndPoint& remote_address) OVERRIDE;
38 virtual void Send(const net::IPEndPoint& to,
39 const std::vector<char>& data,
40 net::DiffServCodePoint dscp,
41 uint64 packet_id) OVERRIDE;
42 virtual P2PSocketHost* AcceptIncomingTcpConnection(
43 const net::IPEndPoint& remote_address, int id) OVERRIDE;
45 private:
46 friend class P2PSocketHostTcpServerTest;
48 void OnError();
50 void DoAccept();
51 void HandleAcceptResult(int result);
53 // Callback for Accept().
54 void OnAccepted(int result);
56 const P2PSocketType client_type_;
57 scoped_ptr<net::ServerSocket> socket_;
58 net::IPEndPoint local_address_;
60 scoped_ptr<net::StreamSocket> accept_socket_;
61 AcceptedSocketsMap accepted_sockets_;
63 net::CompletionCallback accept_callback_;
65 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcpServer);
68 } // namespace content
70 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_