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"
19 class PPAPI_PROXY_EXPORT TCPServerSocketPrivateResource
20 : public PluginResource
,
21 public thunk::PPB_TCPServerSocket_Private_API
{
23 TCPServerSocketPrivateResource(Connection connection
, PP_Instance instance
);
24 ~TCPServerSocketPrivateResource() override
;
26 // PluginResource implementation.
27 thunk::PPB_TCPServerSocket_Private_API
* AsPPB_TCPServerSocket_Private_API()
30 // PPB_TCPServerSocket_Private_API implementation.
31 int32_t Listen(const PP_NetAddress_Private
* addr
,
33 scoped_refptr
<TrackedCallback
> callback
) override
;
34 int32_t Accept(PP_Resource
* tcp_socket
,
35 scoped_refptr
<TrackedCallback
> callback
) override
;
36 int32_t GetLocalAddress(PP_NetAddress_Private
* addr
) override
;
37 void StopListening() override
;
41 STATE_BEFORE_LISTENING
,
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
);
56 PP_NetAddress_Private local_addr_
;
58 scoped_refptr
<TrackedCallback
> listen_callback_
;
59 scoped_refptr
<TrackedCallback
> accept_callback_
;
61 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketPrivateResource
);
67 #endif // PPAPI_PROXY_TCP_SERVER_SOCKET_PRIVATE_RESOURCE_H_