OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/cpp/dev/transport_dev.h" | 5 #include "ppapi/cpp/dev/transport_dev.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | |
7 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
8 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
9 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
10 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
11 | 12 |
12 namespace pp { | 13 namespace pp { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 template <> const char* interface_name<PPB_Transport_Dev>() { | 17 template <> const char* interface_name<PPB_Transport_Dev>() { |
17 return PPB_TRANSPORT_DEV_INTERFACE; | 18 return PPB_TRANSPORT_DEV_INTERFACE; |
18 } | 19 } |
19 | 20 |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 Transport_Dev::Transport_Dev(Instance* instance, | 23 Transport_Dev::Transport_Dev(Instance* instance, |
23 const char* name, | 24 const char* name, |
24 const char* proto) { | 25 const char* proto) { |
25 if (has_interface<PPB_Transport_Dev>()) | 26 if (has_interface<PPB_Transport_Dev>()) |
26 PassRefFromConstructor(get_interface<PPB_Transport_Dev>()->CreateTransport( | 27 PassRefFromConstructor(get_interface<PPB_Transport_Dev>()->CreateTransport( |
27 instance->pp_instance(), name, proto)); | 28 instance->pp_instance(), name, proto)); |
28 } | 29 } |
29 | 30 |
31 bool Transport_Dev::IsWritable() { | |
32 if (!has_interface<PPB_Transport_Dev>()) | |
33 return false; | |
34 return PPBoolToBool( | |
35 get_interface<PPB_Transport_Dev>()->IsWritable(pp_resource())); | |
36 } | |
37 | |
38 int32_t Transport_Dev::Connect(const CompletionCallback& cc) { | |
39 if (!has_interface<PPB_Transport_Dev>()) | |
40 return PP_ERROR_NOINTERFACE; | |
41 return get_interface<PPB_Transport_Dev>()->Connect( | |
42 pp_resource(), cc.pp_completion_callback()); | |
43 } | |
44 | |
45 int32_t Transport_Dev::GetNextAddress(PP_Var* address, | |
brettw
2011/02/14 23:16:39
This should be a pp::Var*
To implement this, I'd
Sergey Ulanov
2011/02/15 00:26:25
Done.
| |
46 const CompletionCallback& cc) { | |
47 if (!has_interface<PPB_Transport_Dev>()) | |
48 return PP_ERROR_NOINTERFACE; | |
49 return get_interface<PPB_Transport_Dev>()->GetNextAddress( | |
50 pp_resource(), address, cc.pp_completion_callback()); | |
51 } | |
52 | |
53 int32_t Transport_Dev::ReceiveRemoteAddress(const PP_Var& address) { | |
54 if (!has_interface<PPB_Transport_Dev>()) | |
55 return PP_ERROR_NOINTERFACE; | |
56 return get_interface<PPB_Transport_Dev>()->ReceiveRemoteAddress( | |
57 pp_resource(), address); | |
58 } | |
59 | |
60 int32_t Transport_Dev::Recv(void* data, uint32_t len, | |
61 const CompletionCallback& cc) { | |
62 if (!has_interface<PPB_Transport_Dev>()) | |
63 return PP_ERROR_NOINTERFACE; | |
64 return get_interface<PPB_Transport_Dev>()->Recv( | |
65 pp_resource(), data, len, cc.pp_completion_callback()); | |
66 } | |
67 | |
68 int32_t Transport_Dev::Send(const void* data, uint32_t len, | |
69 const CompletionCallback& cc) { | |
70 if (!has_interface<PPB_Transport_Dev>()) | |
71 return PP_ERROR_NOINTERFACE; | |
72 return get_interface<PPB_Transport_Dev>()->Send( | |
73 pp_resource(), data, len, cc.pp_completion_callback()); | |
74 } | |
75 | |
76 int32_t Transport_Dev::Close() { | |
77 if (!has_interface<PPB_Transport_Dev>()) | |
78 return PP_ERROR_NOINTERFACE; | |
79 return get_interface<PPB_Transport_Dev>()->Close(pp_resource()); | |
80 } | |
81 | |
30 } // namespace pp | 82 } // namespace pp |
31 | |
OLD | NEW |