OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/proxy/tcp_socket_private_resource.h" | 5 #include "ppapi/proxy/tcp_socket_private_resource.h" |
6 | 6 |
7 #include "ppapi/proxy/ppapi_messages.h" | 7 #include "ppapi/proxy/ppapi_messages.h" |
8 #include "ppapi/shared_impl/ppb_tcp_socket_shared.h" | |
8 | 9 |
9 namespace ppapi { | 10 namespace ppapi { |
10 namespace proxy { | 11 namespace proxy { |
11 | 12 |
12 TCPSocketPrivateResource::TCPSocketPrivateResource(Connection connection, | 13 TCPSocketPrivateResource::TCPSocketPrivateResource(Connection connection, |
13 PP_Instance instance) | 14 PP_Instance instance) |
14 : TCPSocketResourceBase(connection, instance, true) { | 15 : TCPSocketResourceBase(connection, instance, TCP_SOCKET_VERSION_PRIVATE) { |
15 SendCreate(BROWSER, PpapiHostMsg_TCPSocket_CreatePrivate()); | 16 SendCreate(BROWSER, PpapiHostMsg_TCPSocket_CreatePrivate()); |
16 } | 17 } |
17 | 18 |
18 TCPSocketPrivateResource::TCPSocketPrivateResource( | 19 TCPSocketPrivateResource::TCPSocketPrivateResource( |
19 Connection connection, | 20 Connection connection, |
20 PP_Instance instance, | 21 PP_Instance instance, |
21 int pending_resource_id, | 22 int pending_resource_id, |
22 const PP_NetAddress_Private& local_addr, | 23 const PP_NetAddress_Private& local_addr, |
23 const PP_NetAddress_Private& remote_addr) | 24 const PP_NetAddress_Private& remote_addr) |
24 : TCPSocketResourceBase(connection, instance, true, | 25 : TCPSocketResourceBase(connection, instance, TCP_SOCKET_VERSION_PRIVATE, |
25 local_addr, | 26 local_addr, remote_addr) { |
26 remote_addr) { | |
27 AttachToPendingHost(BROWSER, pending_resource_id); | 27 AttachToPendingHost(BROWSER, pending_resource_id); |
28 } | 28 } |
29 | 29 |
30 TCPSocketPrivateResource::~TCPSocketPrivateResource() { | 30 TCPSocketPrivateResource::~TCPSocketPrivateResource() { |
31 DisconnectImpl(); | 31 CloseImpl(); |
bbudge
2013/09/19 22:30:58
Why not call this in the base class dtor?
also cal
yzshen1
2013/09/19 23:14:42
Done.
| |
32 } | 32 } |
33 | 33 |
34 thunk::PPB_TCPSocket_Private_API* | 34 thunk::PPB_TCPSocket_Private_API* |
35 TCPSocketPrivateResource::AsPPB_TCPSocket_Private_API() { | 35 TCPSocketPrivateResource::AsPPB_TCPSocket_Private_API() { |
36 return this; | 36 return this; |
37 } | 37 } |
38 | 38 |
39 int32_t TCPSocketPrivateResource::Connect( | 39 int32_t TCPSocketPrivateResource::Connect( |
40 const char* host, | 40 const char* host, |
41 uint16_t port, | 41 uint16_t port, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 } | 84 } |
85 | 85 |
86 int32_t TCPSocketPrivateResource::Write( | 86 int32_t TCPSocketPrivateResource::Write( |
87 const char* buffer, | 87 const char* buffer, |
88 int32_t bytes_to_write, | 88 int32_t bytes_to_write, |
89 scoped_refptr<TrackedCallback> callback) { | 89 scoped_refptr<TrackedCallback> callback) { |
90 return WriteImpl(buffer, bytes_to_write, callback); | 90 return WriteImpl(buffer, bytes_to_write, callback); |
91 } | 91 } |
92 | 92 |
93 void TCPSocketPrivateResource::Disconnect() { | 93 void TCPSocketPrivateResource::Disconnect() { |
94 DisconnectImpl(); | 94 CloseImpl(); |
95 } | 95 } |
96 | 96 |
97 int32_t TCPSocketPrivateResource::SetOption( | 97 int32_t TCPSocketPrivateResource::SetOption( |
98 PP_TCPSocketOption_Private name, | 98 PP_TCPSocketOption_Private name, |
99 const PP_Var& value, | 99 const PP_Var& value, |
100 scoped_refptr<TrackedCallback> callback) { | 100 scoped_refptr<TrackedCallback> callback) { |
101 switch (name) { | 101 switch (name) { |
102 case PP_TCPSOCKETOPTION_PRIVATE_INVALID: | 102 case PP_TCPSOCKETOPTION_PRIVATE_INVALID: |
103 return PP_ERROR_BADARGUMENT; | 103 return PP_ERROR_BADARGUMENT; |
104 case PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY: | 104 case PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY: |
105 return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value, callback); | 105 return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value, callback); |
106 default: | 106 default: |
107 NOTREACHED(); | 107 NOTREACHED(); |
108 return PP_ERROR_BADARGUMENT; | 108 return PP_ERROR_BADARGUMENT; |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 PP_Resource TCPSocketPrivateResource::CreateAcceptedSocket( | |
113 int /* pending_host_id */, | |
114 const PP_NetAddress_Private& /* local_addr */, | |
115 const PP_NetAddress_Private& /* remote_addr */) { | |
116 NOTREACHED(); | |
117 return 0; | |
118 } | |
119 | |
112 } // namespace proxy | 120 } // namespace proxy |
113 } // namespace ppapi | 121 } // namespace ppapi |
OLD | NEW |