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 CONTENT_RENDERER_PEPPER_PPB_TCP_SOCKET_PRIVATE_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PPB_TCP_SOCKET_PRIVATE_IMPL_H_ 7 8 #include <vector> 9 10 #include "base/compiler_specific.h" 11 #include "ipc/ipc_listener.h" 12 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" 13 14 namespace content { 15 16 class PPB_TCPSocket_Private_Impl : public ppapi::TCPSocketPrivateImpl, 17 public IPC::Listener { 18 public: 19 static PP_Resource CreateResource(PP_Instance instance); 20 21 virtual void SendConnect(const std::string& host, uint16_t port) OVERRIDE; 22 virtual void SendConnectWithNetAddress( 23 const PP_NetAddress_Private& addr) OVERRIDE; 24 virtual void SendSSLHandshake( 25 const std::string& server_name, 26 uint16_t server_port, 27 const std::vector<std::vector<char> >& trusted_certs, 28 const std::vector<std::vector<char> >& untrusted_certs) OVERRIDE; 29 virtual void SendRead(int32_t bytes_to_read) OVERRIDE; 30 virtual void SendWrite(const std::string& buffer) OVERRIDE; 31 virtual void SendDisconnect() OVERRIDE; 32 virtual void SendSetOption(PP_TCPSocket_Option name, 33 const ppapi::SocketOptionData& value) OVERRIDE; 34 35 private: 36 PPB_TCPSocket_Private_Impl(PP_Instance instance, 37 uint32 socket_id, 38 int routing_id); 39 virtual ~PPB_TCPSocket_Private_Impl(); 40 41 // IPC::Listener implementation. 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 43 44 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id, 45 uint32 socket_id, 46 int32_t result, 47 const PP_NetAddress_Private& local_addr, 48 const PP_NetAddress_Private& remote_addr); 49 void OnTCPSocketSSLHandshakeACK( 50 uint32 plugin_dispatcher_id, 51 uint32 socket_id, 52 bool succeeded, 53 const ppapi::PPB_X509Certificate_Fields& certificate_fields); 54 void OnTCPSocketReadACK(uint32 plugin_dispatcher_id, 55 uint32 socket_id, 56 int32_t result, 57 const std::string& data); 58 void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, 59 uint32 socket_id, 60 int32_t result); 61 void OnTCPSocketSetOptionACK(uint32 plugin_dispatcher_id, 62 uint32 socket_id, 63 int32_t result); 64 65 int routing_id_; 66 67 DISALLOW_COPY_AND_ASSIGN(PPB_TCPSocket_Private_Impl); 68 }; 69 70 } // namespace content 71 72 #endif // CONTENT_RENDERER_PEPPER_PPB_TCP_SOCKET_PRIVATE_IMPL_H_ 73