blob: 6a8e9fff0f4ef15bddcffb588471b0a85e530ee6 [file] [log] [blame]
[email protected]8522332e2013-08-28 19:42:591// 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.
4
5#ifndef PPAPI_PROXY_TCP_SOCKET_RESOURCE_H_
6#define PPAPI_PROXY_TCP_SOCKET_RESOURCE_H_
7
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_api.h"
12
13namespace ppapi {
[email protected]92576792013-09-20 15:29:1314
15enum TCPSocketVersion;
16
[email protected]8522332e2013-08-28 19:42:5917namespace proxy {
18
19class PPAPI_PROXY_EXPORT TCPSocketResource : public thunk::PPB_TCPSocket_API,
20 public TCPSocketResourceBase {
21 public:
[email protected]92576792013-09-20 15:29:1322 // C-tor used for new sockets created.
23 TCPSocketResource(Connection connection,
24 PP_Instance instance,
25 TCPSocketVersion version);
26
[email protected]8522332e2013-08-28 19:42:5927 virtual ~TCPSocketResource();
28
29 // PluginResource overrides.
mostynb699af3c2014-10-06 18:03:3430 virtual thunk::PPB_TCPSocket_API* AsPPB_TCPSocket_API() override;
[email protected]8522332e2013-08-28 19:42:5931
32 // thunk::PPB_TCPSocket_API implementation.
[email protected]92576792013-09-20 15:29:1333 virtual int32_t Bind(PP_Resource addr,
mostynb699af3c2014-10-06 18:03:3434 scoped_refptr<TrackedCallback> callback) override;
[email protected]8522332e2013-08-28 19:42:5935 virtual int32_t Connect(PP_Resource addr,
mostynb699af3c2014-10-06 18:03:3436 scoped_refptr<TrackedCallback> callback) override;
37 virtual PP_Resource GetLocalAddress() override;
38 virtual PP_Resource GetRemoteAddress() override;
[email protected]8522332e2013-08-28 19:42:5939 virtual int32_t Read(char* buffer,
40 int32_t bytes_to_read,
mostynb699af3c2014-10-06 18:03:3441 scoped_refptr<TrackedCallback> callback) override;
[email protected]8522332e2013-08-28 19:42:5942 virtual int32_t Write(const char* buffer,
43 int32_t bytes_to_write,
mostynb699af3c2014-10-06 18:03:3444 scoped_refptr<TrackedCallback> callback) override;
[email protected]92576792013-09-20 15:29:1345 virtual int32_t Listen(int32_t backlog,
mostynb699af3c2014-10-06 18:03:3446 scoped_refptr<TrackedCallback> callback) override;
[email protected]92576792013-09-20 15:29:1347 virtual int32_t Accept(PP_Resource* accepted_tcp_socket,
mostynb699af3c2014-10-06 18:03:3448 scoped_refptr<TrackedCallback> callback) override;
49 virtual void Close() override;
[email protected]8522332e2013-08-28 19:42:5950 virtual int32_t SetOption(PP_TCPSocket_Option name,
51 const PP_Var& value,
mostynb699af3c2014-10-06 18:03:3452 scoped_refptr<TrackedCallback> callback) override;
[email protected]8522332e2013-08-28 19:42:5953
[email protected]92576792013-09-20 15:29:1354 // TCPSocketResourceBase implementation.
55 virtual PP_Resource CreateAcceptedSocket(
56 int pending_host_id,
57 const PP_NetAddress_Private& local_addr,
mostynb699af3c2014-10-06 18:03:3458 const PP_NetAddress_Private& remote_addr) override;
[email protected]92576792013-09-20 15:29:1359
[email protected]8522332e2013-08-28 19:42:5960 private:
[email protected]92576792013-09-20 15:29:1361 // C-tor used for accepted sockets.
62 TCPSocketResource(Connection connection,
63 PP_Instance instance,
64 int pending_host_id,
65 const PP_NetAddress_Private& local_addr,
66 const PP_NetAddress_Private& remote_addr);
67
[email protected]8522332e2013-08-28 19:42:5968 DISALLOW_COPY_AND_ASSIGN(TCPSocketResource);
69};
70
71} // namespace proxy
72} // namespace ppapi
73
74#endif // PPAPI_PROXY_TCP_SOCKET_RESOURCE_H_