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_SOCKET_PRIVATE_RESOURCE_H_
6 #define PPAPI_PROXY_TCP_SOCKET_PRIVATE_RESOURCE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "ppapi/proxy/tcp_socket_resource_base.h"
11 #include "ppapi/thunk/ppb_tcp_socket_private_api.h"
16 class PPAPI_PROXY_EXPORT TCPSocketPrivateResource
17 : public thunk::PPB_TCPSocket_Private_API
,
18 public TCPSocketResourceBase
{
20 // C-tor used for new sockets.
21 TCPSocketPrivateResource(Connection connection
, PP_Instance instance
);
23 // C-tor used for already accepted sockets.
24 TCPSocketPrivateResource(Connection connection
,
26 int pending_resource_id
,
27 const PP_NetAddress_Private
& local_addr
,
28 const PP_NetAddress_Private
& remote_addr
);
30 ~TCPSocketPrivateResource() override
;
32 // PluginResource overrides.
33 PPB_TCPSocket_Private_API
* AsPPB_TCPSocket_Private_API() override
;
35 // PPB_TCPSocket_Private_API implementation.
36 int32_t Connect(const char* host
,
38 scoped_refptr
<TrackedCallback
> callback
) override
;
39 int32_t ConnectWithNetAddress(
40 const PP_NetAddress_Private
* addr
,
41 scoped_refptr
<TrackedCallback
> callback
) override
;
42 PP_Bool
GetLocalAddress(PP_NetAddress_Private
* local_addr
) override
;
43 PP_Bool
GetRemoteAddress(PP_NetAddress_Private
* remote_addr
) override
;
45 const char* server_name
,
47 scoped_refptr
<TrackedCallback
> callback
) override
;
48 PP_Resource
GetServerCertificate() override
;
49 PP_Bool
AddChainBuildingCertificate(PP_Resource certificate
,
50 PP_Bool trusted
) override
;
51 int32_t Read(char* buffer
,
52 int32_t bytes_to_read
,
53 scoped_refptr
<TrackedCallback
> callback
) override
;
54 int32_t Write(const char* buffer
,
55 int32_t bytes_to_write
,
56 scoped_refptr
<TrackedCallback
> callback
) override
;
57 void Disconnect() override
;
58 int32_t SetOption(PP_TCPSocketOption_Private name
,
60 scoped_refptr
<TrackedCallback
> callback
) override
;
62 // TCPSocketResourceBase implementation.
63 PP_Resource
CreateAcceptedSocket(
65 const PP_NetAddress_Private
& local_addr
,
66 const PP_NetAddress_Private
& remote_addr
) override
;
69 DISALLOW_COPY_AND_ASSIGN(TCPSocketPrivateResource
);
75 #endif // PPAPI_PROXY_TCP_SOCKET_PRIVATE_RESOURCE_H_