Revert 233414 "x11: Move XInput2 availability information out of..."
[chromium-blink-merge.git] / ppapi / proxy / tcp_server_socket_private_resource.h
blob21e190a6278a2a7b1b308e3cc5487e676d8c6825
1 // Copyright 2013 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 PPAPI_PROXY_TCP_SERVER_SOCKET_PRIVATE_RESOURCE_H_
6 #define PPAPI_PROXY_TCP_SERVER_SOCKET_PRIVATE_RESOURCE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "ppapi/proxy/plugin_resource.h"
12 #include "ppapi/proxy/ppapi_proxy_export.h"
13 #include "ppapi/shared_impl/tracked_callback.h"
14 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
16 namespace ppapi {
17 namespace proxy {
19 class PPAPI_PROXY_EXPORT TCPServerSocketPrivateResource
20 : public PluginResource,
21 public thunk::PPB_TCPServerSocket_Private_API {
22 public:
23 TCPServerSocketPrivateResource(Connection connection, PP_Instance instance);
24 virtual ~TCPServerSocketPrivateResource();
26 // PluginResource implementation.
27 virtual thunk::PPB_TCPServerSocket_Private_API*
28 AsPPB_TCPServerSocket_Private_API() OVERRIDE;
30 // PPB_TCPServerSocket_Private_API implementation.
31 virtual int32_t Listen(const PP_NetAddress_Private* addr,
32 int32_t backlog,
33 scoped_refptr<TrackedCallback> callback) OVERRIDE;
34 virtual int32_t Accept(PP_Resource* tcp_socket,
35 scoped_refptr<TrackedCallback> callback) OVERRIDE;
36 virtual int32_t GetLocalAddress(PP_NetAddress_Private* addr) OVERRIDE;
37 virtual void StopListening() OVERRIDE;
39 private:
40 enum State {
41 STATE_BEFORE_LISTENING,
42 STATE_LISTENING,
43 STATE_CLOSED
46 // IPC message handlers.
47 void OnPluginMsgListenReply(const ResourceMessageReplyParams& params,
48 const PP_NetAddress_Private& local_addr);
49 void OnPluginMsgAcceptReply(PP_Resource* tcp_socket,
50 const ResourceMessageReplyParams& params,
51 int pending_resource_id,
52 const PP_NetAddress_Private& local_addr,
53 const PP_NetAddress_Private& remote_addr);
55 State state_;
56 PP_NetAddress_Private local_addr_;
58 scoped_refptr<TrackedCallback> listen_callback_;
59 scoped_refptr<TrackedCallback> accept_callback_;
61 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketPrivateResource);
64 } // namespace proxy
65 } // namespace ppapi
67 #endif // PPAPI_PROXY_TCP_SERVER_SOCKET_PRIVATE_RESOURCE_H_