1// Copyright (c) 2012 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_CPP_PRIVATE_TCP_SOCKET_PRIVATE_H_
6#define PPAPI_CPP_PRIVATE_TCP_SOCKET_PRIVATE_H_
7
8#include "ppapi/c/pp_stdint.h"
9#include "ppapi/c/private/ppb_tcp_socket_private.h"
10#include "ppapi/cpp/pass_ref.h"
11#include "ppapi/cpp/private/x509_certificate_private.h"
12#include "ppapi/cpp/resource.h"
13
14namespace pp {
15
16class CompletionCallback;
17class InstanceHandle;
18
19class TCPSocketPrivate : public Resource {
20 public:
21  explicit TCPSocketPrivate(const InstanceHandle& instance);
22
23  TCPSocketPrivate(PassRef, PP_Resource resource);
24
25  // Returns true if the required interface is available.
26  static bool IsAvailable();
27
28  int32_t Connect(const char* host,
29                  uint16_t port,
30                  const CompletionCallback& callback);
31  int32_t ConnectWithNetAddress(const PP_NetAddress_Private* addr,
32                                const CompletionCallback& callback);
33  bool GetLocalAddress(PP_NetAddress_Private* local_addr);
34  bool GetRemoteAddress(PP_NetAddress_Private* remote_addr);
35  int32_t SSLHandshake(const char* server_name,
36                       uint16_t server_port,
37                       const CompletionCallback& callback);
38  X509CertificatePrivate GetServerCertificate();
39  bool AddChainBuildingCertificate(const X509CertificatePrivate& cert,
40                                   bool trusted);
41
42  int32_t Read(char* buffer,
43               int32_t bytes_to_read,
44               const CompletionCallback& callback);
45  int32_t Write(const char* buffer,
46                int32_t bytes_to_write,
47                const CompletionCallback& callback);
48  void Disconnect();
49  int32_t SetOption(PP_TCPSocketOption_Private name,
50                    const Var& value,
51                    const CompletionCallback& callback);
52};
53
54}  // namespace pp
55
56#endif  // PPAPI_CPP_PRIVATE_TCP_SOCKET_PRIVATE_H_
57