OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 #include "ppapi/cpp/private/flash_net_connector.h" | |
6 | |
7 #include "ppapi/c/pp_errors.h" | |
8 #include "ppapi/cpp/completion_callback.h" | |
9 #include "ppapi/cpp/instance_handle.h" | |
10 #include "ppapi/cpp/module.h" | |
11 #include "ppapi/cpp/module_impl.h" | |
12 | |
13 namespace pp { | |
14 | |
15 namespace { | |
16 | |
17 template <> const char* interface_name<PPB_Flash_NetConnector>() { | |
18 return PPB_FLASH_NETCONNECTOR_INTERFACE; | |
19 } | |
20 | |
21 } // namespace | |
22 | |
23 namespace flash { | |
24 | |
25 NetConnector::NetConnector(const InstanceHandle& instance) { | |
26 if (has_interface<PPB_Flash_NetConnector>()) { | |
27 PassRefFromConstructor(get_interface<PPB_Flash_NetConnector>()->Create( | |
28 instance.pp_instance())); | |
29 } | |
30 } | |
31 | |
32 int32_t NetConnector::ConnectTcp(const char* host, | |
33 uint16_t port, | |
34 PP_FileHandle* socket_out, | |
35 PP_NetAddress_Private* local_addr_out, | |
36 PP_NetAddress_Private* remote_addr_out, | |
37 const CompletionCallback& cc) { | |
38 if (!has_interface<PPB_Flash_NetConnector>()) | |
39 return cc.MayForce(PP_ERROR_NOINTERFACE); | |
40 return get_interface<PPB_Flash_NetConnector>()->ConnectTcp( | |
41 pp_resource(), | |
42 host, port, | |
43 socket_out, local_addr_out, remote_addr_out, | |
44 cc.pp_completion_callback()); | |
45 } | |
46 | |
47 int32_t NetConnector::ConnectTcpAddress(const PP_NetAddress_Private* addr, | |
48 PP_FileHandle* socket_out, | |
49 PP_NetAddress_Private* local_addr_out, | |
50 PP_NetAddress_Private* remote_addr_out, | |
51 const CompletionCallback& cc) { | |
52 if (!has_interface<PPB_Flash_NetConnector>()) | |
53 return cc.MayForce(PP_ERROR_NOINTERFACE); | |
54 return get_interface<PPB_Flash_NetConnector>()->ConnectTcpAddress( | |
55 pp_resource(), | |
56 addr, | |
57 socket_out, local_addr_out, remote_addr_out, | |
58 cc.pp_completion_callback()); | |
59 } | |
60 | |
61 } // namespace flash | |
62 } // namespace pp | |
OLD | NEW |