Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / proxy / tcp_server_socket_private_resource.h
blob055b3b05db24a5de89caecae89d4f5d8ce1ef817
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 ~TCPServerSocketPrivateResource() override;
26 // PluginResource implementation.
27 thunk::PPB_TCPServerSocket_Private_API* AsPPB_TCPServerSocket_Private_API()
28 override;
30 // PPB_TCPServerSocket_Private_API implementation.
31 int32_t Listen(const PP_NetAddress_Private* addr,
32 int32_t backlog,
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;
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_