chrome/browser/ui: Remove use of MessageLoopProxy and deprecated MessageLoop APIs
[chromium-blink-merge.git] / ppapi / proxy / tcp_socket_private_resource.cc
blob454c3faf1a374a89420c2b541d6139ba2802d1dc
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 #include "ppapi/proxy/tcp_socket_private_resource.h"
7 #include "ppapi/proxy/ppapi_messages.h"
8 #include "ppapi/shared_impl/ppb_tcp_socket_shared.h"
10 namespace ppapi {
11 namespace proxy {
13 TCPSocketPrivateResource::TCPSocketPrivateResource(Connection connection,
14 PP_Instance instance)
15 : TCPSocketResourceBase(connection, instance, TCP_SOCKET_VERSION_PRIVATE) {
16 SendCreate(BROWSER, PpapiHostMsg_TCPSocket_CreatePrivate());
19 TCPSocketPrivateResource::TCPSocketPrivateResource(
20 Connection connection,
21 PP_Instance instance,
22 int pending_resource_id,
23 const PP_NetAddress_Private& local_addr,
24 const PP_NetAddress_Private& remote_addr)
25 : TCPSocketResourceBase(connection, instance, TCP_SOCKET_VERSION_PRIVATE,
26 local_addr, remote_addr) {
27 AttachToPendingHost(BROWSER, pending_resource_id);
30 TCPSocketPrivateResource::~TCPSocketPrivateResource() {
33 thunk::PPB_TCPSocket_Private_API*
34 TCPSocketPrivateResource::AsPPB_TCPSocket_Private_API() {
35 return this;
38 int32_t TCPSocketPrivateResource::Connect(
39 const char* host,
40 uint16_t port,
41 scoped_refptr<TrackedCallback> callback) {
42 return ConnectImpl(host, port, callback);
45 int32_t TCPSocketPrivateResource::ConnectWithNetAddress(
46 const PP_NetAddress_Private* addr,
47 scoped_refptr<TrackedCallback> callback) {
48 return ConnectWithNetAddressImpl(addr, callback);
51 PP_Bool TCPSocketPrivateResource::GetLocalAddress(
52 PP_NetAddress_Private* local_addr) {
53 return GetLocalAddressImpl(local_addr);
56 PP_Bool TCPSocketPrivateResource::GetRemoteAddress(
57 PP_NetAddress_Private* remote_addr) {
58 return GetRemoteAddressImpl(remote_addr);
61 int32_t TCPSocketPrivateResource::SSLHandshake(
62 const char* server_name,
63 uint16_t server_port,
64 scoped_refptr<TrackedCallback> callback) {
65 return SSLHandshakeImpl(server_name, server_port, callback);
68 PP_Resource TCPSocketPrivateResource::GetServerCertificate() {
69 return GetServerCertificateImpl();
72 PP_Bool TCPSocketPrivateResource::AddChainBuildingCertificate(
73 PP_Resource certificate,
74 PP_Bool trusted) {
75 return AddChainBuildingCertificateImpl(certificate, trusted);
78 int32_t TCPSocketPrivateResource::Read(
79 char* buffer,
80 int32_t bytes_to_read,
81 scoped_refptr<TrackedCallback> callback) {
82 return ReadImpl(buffer, bytes_to_read, callback);
85 int32_t TCPSocketPrivateResource::Write(
86 const char* buffer,
87 int32_t bytes_to_write,
88 scoped_refptr<TrackedCallback> callback) {
89 return WriteImpl(buffer, bytes_to_write, callback);
92 void TCPSocketPrivateResource::Disconnect() {
93 CloseImpl();
96 int32_t TCPSocketPrivateResource::SetOption(
97 PP_TCPSocketOption_Private name,
98 const PP_Var& value,
99 scoped_refptr<TrackedCallback> callback) {
100 switch (name) {
101 case PP_TCPSOCKETOPTION_PRIVATE_INVALID:
102 return PP_ERROR_BADARGUMENT;
103 case PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY:
104 return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value,
105 true, // Check connect() state.
106 callback);
107 default:
108 NOTREACHED();
109 return PP_ERROR_BADARGUMENT;
113 PP_Resource TCPSocketPrivateResource::CreateAcceptedSocket(
114 int /* pending_host_id */,
115 const PP_NetAddress_Private& /* local_addr */,
116 const PP_NetAddress_Private& /* remote_addr */) {
117 NOTREACHED();
118 return 0;
121 } // namespace proxy
122 } // namespace ppapi