OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_transport.h" | |
6 | |
7 #include "base/singleton.h" | |
8 #include "base/thread_local.h" | |
9 #include "ppapi/c/dev/ppb_transport_dev.h" | |
10 #include "webkit/glue/plugins/pepper_common.h" | |
11 #include "webkit/glue/plugins/pepper_plugin_instance.h" | |
12 #include "webkit/glue/plugins/pepper_plugin_module.h" | |
13 | |
14 namespace pepper { | |
15 | |
16 namespace { | |
17 | |
18 // Creates a new transport object with the specified name | |
19 // using the specified protocol. | |
20 PP_Resource CreateTransport(PP_Module module, | |
21 const char* name, | |
22 const char* proto) { | |
23 // TODO(juberti): implement me | |
24 PP_Resource p(0); | |
25 return p; | |
26 } | |
27 | |
28 // Returns whether or not resource is Transport | |
29 PP_Bool IsTransport(PP_Resource resource) { | |
30 return BoolToPPBool(!!Resource::GetAs<Transport>(resource)); | |
31 } | |
32 | |
33 // Returns whether the transport is currently writable | |
34 // (i.e. can send data to the remote peer) | |
35 PP_Bool IsWritable(PP_Resource transport) { | |
36 // TODO(juberti): impelement me | |
37 return PP_FALSE; | |
38 } | |
39 | |
40 | |
41 // TODO(juberti): other getters/setters | |
42 // connect state | |
43 // connect type, protocol | |
44 // RTT | |
45 | |
46 | |
47 // Establishes a connection to the remote peer. | |
48 // Returns PP_ERROR_WOULDBLOCK and notifies on |cb| | |
49 // when connectivity is established (or timeout occurs). | |
50 int32_t Connect(PP_Resource transport, | |
51 PP_CompletionCallback cb) { | |
52 // TODO(juberti): impelement me | |
53 return 0; | |
54 } | |
55 | |
56 | |
57 // Obtains another ICE candidate address to be provided | |
58 // to the remote peer. Returns PP_ERROR_WOULDBLOCK | |
59 // if there are no more addresses to be sent. | |
60 int32_t GetNextAddress(PP_Resource transport, | |
61 PP_Var* address, | |
62 PP_CompletionCallback cb) { | |
63 // TODO(juberti): implement me | |
64 return 0; | |
65 } | |
66 | |
67 | |
68 // Provides an ICE candidate address that was received | |
69 // from the remote peer. | |
70 int32_t ReceiveRemoteAddress(PP_Resource transport, | |
71 PP_Var address) { | |
72 // TODO(juberti): implement me | |
73 return 0; | |
74 } | |
75 | |
76 | |
77 // Like recv(), receives data. Returns PP_ERROR_WOULDBLOCK | |
78 // if there is currently no data to receive. | |
79 int32_t Recv(PP_Resource transport, | |
80 void* data, | |
81 uint32_t len, | |
82 PP_CompletionCallback cb) { | |
83 // TODO(juberti): implement me | |
84 return 0; | |
85 } | |
86 | |
87 | |
88 // Like send(), sends data. Returns PP_ERROR_WOULDBLOCK | |
89 // if the socket is currently flow-controlled. | |
90 int32_t Send(PP_Resource transport, | |
91 const void* data, | |
92 uint32_t len, | |
93 PP_CompletionCallback cb) { | |
94 // TODO(juberti): implement me | |
95 return 0; | |
96 } | |
97 | |
98 | |
99 // Disconnects from the remote peer. | |
100 int32_t Close(PP_Resource transport) { | |
101 // TODO(juberti): implement me | |
102 return 0; | |
103 } | |
104 | |
105 | |
106 const PPB_Transport_Dev ppb_transport = { | |
107 &CreateTransport, | |
108 &IsTransport, | |
109 &IsWritable, | |
110 &Connect, | |
111 &GetNextAddress, | |
112 &ReceiveRemoteAddress, | |
113 &Recv, | |
114 &Send, | |
115 &Close, | |
116 }; | |
117 | |
118 } // namespace | |
119 | |
120 Transport::Transport(PluginModule* module) | |
121 : Resource(module) { | |
122 // TODO(juberti): impl | |
123 } | |
124 | |
125 const PPB_Transport_Dev* Transport::GetInterface() { | |
126 return &ppb_transport; | |
127 } | |
128 | |
129 Transport::~Transport() { | |
130 // TODO(juberti): teardown | |
131 } | |
132 | |
133 Transport* Transport::AsTransport() { | |
134 return this; | |
135 } | |
136 | |
137 bool Transport::Init(const char* name, | |
138 const char* proto) { | |
139 // TODO(juberti): impl | |
140 return false; | |
141 } | |
142 | |
143 } // namespace pepper | |
144 | |
OLD | NEW |