OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/cpp/extensions/dev/socket_dev.h" | 5 #include "ppapi/cpp/extensions/dev/socket_dev.h" |
6 | 6 |
7 #include "ppapi/cpp/completion_callback.h" | 7 #include "ppapi/cpp/completion_callback.h" |
8 #include "ppapi/cpp/extensions/optional.h" | 8 #include "ppapi/cpp/extensions/optional.h" |
9 #include "ppapi/cpp/extensions/to_var_converter.h" | 9 #include "ppapi/cpp/extensions/to_var_converter.h" |
10 #include "ppapi/cpp/logging.h" | 10 #include "ppapi/cpp/logging.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 : socket_id(kSocketId) { | 69 : socket_id(kSocketId) { |
70 } | 70 } |
71 | 71 |
72 CreateInfo_Dev::~CreateInfo_Dev() { | 72 CreateInfo_Dev::~CreateInfo_Dev() { |
73 } | 73 } |
74 | 74 |
75 bool CreateInfo_Dev::Populate(const PP_Ext_Socket_CreateInfo_Dev& value) { | 75 bool CreateInfo_Dev::Populate(const PP_Ext_Socket_CreateInfo_Dev& value) { |
76 if (value.type != PP_VARTYPE_DICTIONARY) | 76 if (value.type != PP_VARTYPE_DICTIONARY) |
77 return false; | 77 return false; |
78 | 78 |
79 VarDictionary_Dev dict(value); | 79 VarDictionary dict(value); |
80 bool result = socket_id.Populate(dict); | 80 bool result = socket_id.Populate(dict); |
81 | 81 |
82 return result; | 82 return result; |
83 } | 83 } |
84 | 84 |
85 Var CreateInfo_Dev::CreateVar() const { | 85 Var CreateInfo_Dev::CreateVar() const { |
86 VarDictionary_Dev dict; | 86 VarDictionary dict; |
87 | 87 |
88 bool result = socket_id.AddTo(&dict); | 88 bool result = socket_id.AddTo(&dict); |
89 // Suppress unused variable warnings. | 89 // Suppress unused variable warnings. |
90 static_cast<void>(result); | 90 static_cast<void>(result); |
91 PP_DCHECK(result); | 91 PP_DCHECK(result); |
92 | 92 |
93 return dict; | 93 return dict; |
94 } | 94 } |
95 | 95 |
96 const char* const AcceptInfo_Dev::kResultCode = "resultCode"; | 96 const char* const AcceptInfo_Dev::kResultCode = "resultCode"; |
97 const char* const AcceptInfo_Dev::kSocketId = "socketId"; | 97 const char* const AcceptInfo_Dev::kSocketId = "socketId"; |
98 | 98 |
99 AcceptInfo_Dev::AcceptInfo_Dev() | 99 AcceptInfo_Dev::AcceptInfo_Dev() |
100 : result_code(kResultCode), | 100 : result_code(kResultCode), |
101 socket_id(kSocketId) { | 101 socket_id(kSocketId) { |
102 } | 102 } |
103 | 103 |
104 AcceptInfo_Dev::~AcceptInfo_Dev() { | 104 AcceptInfo_Dev::~AcceptInfo_Dev() { |
105 } | 105 } |
106 | 106 |
107 bool AcceptInfo_Dev::Populate(const PP_Ext_Socket_AcceptInfo_Dev& value) { | 107 bool AcceptInfo_Dev::Populate(const PP_Ext_Socket_AcceptInfo_Dev& value) { |
108 if (value.type != PP_VARTYPE_DICTIONARY) | 108 if (value.type != PP_VARTYPE_DICTIONARY) |
109 return false; | 109 return false; |
110 | 110 |
111 VarDictionary_Dev dict(value); | 111 VarDictionary dict(value); |
112 bool result = result_code.Populate(dict); | 112 bool result = result_code.Populate(dict); |
113 result = socket_id.Populate(dict) && result; | 113 result = socket_id.Populate(dict) && result; |
114 | 114 |
115 return result; | 115 return result; |
116 } | 116 } |
117 | 117 |
118 Var AcceptInfo_Dev::CreateVar() const { | 118 Var AcceptInfo_Dev::CreateVar() const { |
119 VarDictionary_Dev dict; | 119 VarDictionary dict; |
120 | 120 |
121 bool result = result_code.AddTo(&dict); | 121 bool result = result_code.AddTo(&dict); |
122 result = socket_id.MayAddTo(&dict) && result; | 122 result = socket_id.MayAddTo(&dict) && result; |
123 PP_DCHECK(result); | 123 PP_DCHECK(result); |
124 | 124 |
125 return dict; | 125 return dict; |
126 } | 126 } |
127 | 127 |
128 const char* const ReadInfo_Dev::kResultCode = "resultCode"; | 128 const char* const ReadInfo_Dev::kResultCode = "resultCode"; |
129 const char* const ReadInfo_Dev::kData = "data"; | 129 const char* const ReadInfo_Dev::kData = "data"; |
130 | 130 |
131 ReadInfo_Dev::ReadInfo_Dev() | 131 ReadInfo_Dev::ReadInfo_Dev() |
132 : result_code(kResultCode), | 132 : result_code(kResultCode), |
133 data(kData) { | 133 data(kData) { |
134 } | 134 } |
135 | 135 |
136 ReadInfo_Dev::~ReadInfo_Dev() { | 136 ReadInfo_Dev::~ReadInfo_Dev() { |
137 } | 137 } |
138 | 138 |
139 bool ReadInfo_Dev::Populate(const PP_Ext_Socket_ReadInfo_Dev& value) { | 139 bool ReadInfo_Dev::Populate(const PP_Ext_Socket_ReadInfo_Dev& value) { |
140 if (value.type != PP_VARTYPE_DICTIONARY) | 140 if (value.type != PP_VARTYPE_DICTIONARY) |
141 return false; | 141 return false; |
142 | 142 |
143 VarDictionary_Dev dict(value); | 143 VarDictionary dict(value); |
144 bool result = result_code.Populate(dict); | 144 bool result = result_code.Populate(dict); |
145 result = data.Populate(dict) && result; | 145 result = data.Populate(dict) && result; |
146 | 146 |
147 return result; | 147 return result; |
148 } | 148 } |
149 | 149 |
150 Var ReadInfo_Dev::CreateVar() const { | 150 Var ReadInfo_Dev::CreateVar() const { |
151 VarDictionary_Dev dict; | 151 VarDictionary dict; |
152 | 152 |
153 bool result = result_code.AddTo(&dict); | 153 bool result = result_code.AddTo(&dict); |
154 result = data.AddTo(&dict) && result; | 154 result = data.AddTo(&dict) && result; |
155 PP_DCHECK(result); | 155 PP_DCHECK(result); |
156 | 156 |
157 return dict; | 157 return dict; |
158 } | 158 } |
159 | 159 |
160 const char* const WriteInfo_Dev::kBytesWritten = "bytesWritten"; | 160 const char* const WriteInfo_Dev::kBytesWritten = "bytesWritten"; |
161 | 161 |
162 WriteInfo_Dev::WriteInfo_Dev() | 162 WriteInfo_Dev::WriteInfo_Dev() |
163 : bytes_written(kBytesWritten) { | 163 : bytes_written(kBytesWritten) { |
164 } | 164 } |
165 | 165 |
166 WriteInfo_Dev::~WriteInfo_Dev() { | 166 WriteInfo_Dev::~WriteInfo_Dev() { |
167 } | 167 } |
168 | 168 |
169 bool WriteInfo_Dev::Populate(const PP_Ext_Socket_WriteInfo_Dev& value) { | 169 bool WriteInfo_Dev::Populate(const PP_Ext_Socket_WriteInfo_Dev& value) { |
170 if (value.type != PP_VARTYPE_DICTIONARY) | 170 if (value.type != PP_VARTYPE_DICTIONARY) |
171 return false; | 171 return false; |
172 | 172 |
173 VarDictionary_Dev dict(value); | 173 VarDictionary dict(value); |
174 bool result = bytes_written.Populate(dict); | 174 bool result = bytes_written.Populate(dict); |
175 | 175 |
176 return result; | 176 return result; |
177 } | 177 } |
178 | 178 |
179 Var WriteInfo_Dev::CreateVar() const { | 179 Var WriteInfo_Dev::CreateVar() const { |
180 VarDictionary_Dev dict; | 180 VarDictionary dict; |
181 | 181 |
182 bool result = bytes_written.AddTo(&dict); | 182 bool result = bytes_written.AddTo(&dict); |
183 // Suppress unused variable warnings. | 183 // Suppress unused variable warnings. |
184 static_cast<void>(result); | 184 static_cast<void>(result); |
185 PP_DCHECK(result); | 185 PP_DCHECK(result); |
186 | 186 |
187 return dict; | 187 return dict; |
188 } | 188 } |
189 | 189 |
190 const char* const RecvFromInfo_Dev::kResultCode = "resultCode"; | 190 const char* const RecvFromInfo_Dev::kResultCode = "resultCode"; |
191 const char* const RecvFromInfo_Dev::kData = "data"; | 191 const char* const RecvFromInfo_Dev::kData = "data"; |
192 const char* const RecvFromInfo_Dev::kAddress = "address"; | 192 const char* const RecvFromInfo_Dev::kAddress = "address"; |
193 const char* const RecvFromInfo_Dev::kPort = "port"; | 193 const char* const RecvFromInfo_Dev::kPort = "port"; |
194 | 194 |
195 RecvFromInfo_Dev::RecvFromInfo_Dev() | 195 RecvFromInfo_Dev::RecvFromInfo_Dev() |
196 : result_code(kResultCode), | 196 : result_code(kResultCode), |
197 data(kData), | 197 data(kData), |
198 address(kAddress), | 198 address(kAddress), |
199 port(kPort) { | 199 port(kPort) { |
200 } | 200 } |
201 | 201 |
202 RecvFromInfo_Dev::~RecvFromInfo_Dev() { | 202 RecvFromInfo_Dev::~RecvFromInfo_Dev() { |
203 } | 203 } |
204 | 204 |
205 bool RecvFromInfo_Dev::Populate(const PP_Ext_Socket_RecvFromInfo_Dev& value) { | 205 bool RecvFromInfo_Dev::Populate(const PP_Ext_Socket_RecvFromInfo_Dev& value) { |
206 if (value.type != PP_VARTYPE_DICTIONARY) | 206 if (value.type != PP_VARTYPE_DICTIONARY) |
207 return false; | 207 return false; |
208 | 208 |
209 VarDictionary_Dev dict(value); | 209 VarDictionary dict(value); |
210 bool result = result_code.Populate(dict); | 210 bool result = result_code.Populate(dict); |
211 result = data.Populate(dict) && result; | 211 result = data.Populate(dict) && result; |
212 result = address.Populate(dict) && result; | 212 result = address.Populate(dict) && result; |
213 result = port.Populate(dict) && result; | 213 result = port.Populate(dict) && result; |
214 | 214 |
215 return result; | 215 return result; |
216 } | 216 } |
217 | 217 |
218 Var RecvFromInfo_Dev::CreateVar() const { | 218 Var RecvFromInfo_Dev::CreateVar() const { |
219 VarDictionary_Dev dict; | 219 VarDictionary dict; |
220 | 220 |
221 bool result = result_code.AddTo(&dict); | 221 bool result = result_code.AddTo(&dict); |
222 result = data.AddTo(&dict) && result; | 222 result = data.AddTo(&dict) && result; |
223 result = address.AddTo(&dict) && result; | 223 result = address.AddTo(&dict) && result; |
224 result = port.AddTo(&dict) && result; | 224 result = port.AddTo(&dict) && result; |
225 PP_DCHECK(result); | 225 PP_DCHECK(result); |
226 | 226 |
227 return dict; | 227 return dict; |
228 } | 228 } |
229 | 229 |
(...skipping 13 matching lines...) Expand all Loading... |
243 local_port(kLocalPort) { | 243 local_port(kLocalPort) { |
244 } | 244 } |
245 | 245 |
246 SocketInfo_Dev::~SocketInfo_Dev() { | 246 SocketInfo_Dev::~SocketInfo_Dev() { |
247 } | 247 } |
248 | 248 |
249 bool SocketInfo_Dev::Populate(const PP_Ext_Socket_SocketInfo_Dev& value) { | 249 bool SocketInfo_Dev::Populate(const PP_Ext_Socket_SocketInfo_Dev& value) { |
250 if (value.type != PP_VARTYPE_DICTIONARY) | 250 if (value.type != PP_VARTYPE_DICTIONARY) |
251 return false; | 251 return false; |
252 | 252 |
253 VarDictionary_Dev dict(value); | 253 VarDictionary dict(value); |
254 bool result = socket_type.Populate(dict); | 254 bool result = socket_type.Populate(dict); |
255 result = connected.Populate(dict) && result; | 255 result = connected.Populate(dict) && result; |
256 result = peer_address.Populate(dict) && result; | 256 result = peer_address.Populate(dict) && result; |
257 result = peer_port.Populate(dict) && result; | 257 result = peer_port.Populate(dict) && result; |
258 result = local_address.Populate(dict) && result; | 258 result = local_address.Populate(dict) && result; |
259 result = local_port.Populate(dict) && result; | 259 result = local_port.Populate(dict) && result; |
260 | 260 |
261 return result; | 261 return result; |
262 } | 262 } |
263 | 263 |
264 Var SocketInfo_Dev::CreateVar() const { | 264 Var SocketInfo_Dev::CreateVar() const { |
265 VarDictionary_Dev dict; | 265 VarDictionary dict; |
266 | 266 |
267 bool result = socket_type.AddTo(&dict); | 267 bool result = socket_type.AddTo(&dict); |
268 result = connected.AddTo(&dict) && result; | 268 result = connected.AddTo(&dict) && result; |
269 result = peer_address.MayAddTo(&dict) && result; | 269 result = peer_address.MayAddTo(&dict) && result; |
270 result = peer_port.MayAddTo(&dict) && result; | 270 result = peer_port.MayAddTo(&dict) && result; |
271 result = local_address.MayAddTo(&dict) && result; | 271 result = local_address.MayAddTo(&dict) && result; |
272 result = local_port.MayAddTo(&dict) && result; | 272 result = local_port.MayAddTo(&dict) && result; |
273 PP_DCHECK(result); | 273 PP_DCHECK(result); |
274 | 274 |
275 return dict; | 275 return dict; |
276 } | 276 } |
277 | 277 |
278 const char* const NetworkInterface_Dev::kName = "name"; | 278 const char* const NetworkInterface_Dev::kName = "name"; |
279 const char* const NetworkInterface_Dev::kAddress = "address"; | 279 const char* const NetworkInterface_Dev::kAddress = "address"; |
280 | 280 |
281 NetworkInterface_Dev::NetworkInterface_Dev() | 281 NetworkInterface_Dev::NetworkInterface_Dev() |
282 : name(kName), | 282 : name(kName), |
283 address(kAddress) { | 283 address(kAddress) { |
284 } | 284 } |
285 | 285 |
286 NetworkInterface_Dev::~NetworkInterface_Dev() { | 286 NetworkInterface_Dev::~NetworkInterface_Dev() { |
287 } | 287 } |
288 | 288 |
289 bool NetworkInterface_Dev::Populate( | 289 bool NetworkInterface_Dev::Populate( |
290 const PP_Ext_Socket_NetworkInterface_Dev& value) { | 290 const PP_Ext_Socket_NetworkInterface_Dev& value) { |
291 if (value.type != PP_VARTYPE_DICTIONARY) | 291 if (value.type != PP_VARTYPE_DICTIONARY) |
292 return false; | 292 return false; |
293 | 293 |
294 VarDictionary_Dev dict(value); | 294 VarDictionary dict(value); |
295 bool result = name.Populate(dict); | 295 bool result = name.Populate(dict); |
296 result = address.Populate(dict) && result; | 296 result = address.Populate(dict) && result; |
297 | 297 |
298 return result; | 298 return result; |
299 } | 299 } |
300 | 300 |
301 Var NetworkInterface_Dev::CreateVar() const { | 301 Var NetworkInterface_Dev::CreateVar() const { |
302 VarDictionary_Dev dict; | 302 VarDictionary dict; |
303 | 303 |
304 bool result = name.AddTo(&dict); | 304 bool result = name.AddTo(&dict); |
305 result = address.AddTo(&dict) && result; | 305 result = address.AddTo(&dict) && result; |
306 PP_DCHECK(result); | 306 PP_DCHECK(result); |
307 | 307 |
308 return dict; | 308 return dict; |
309 } | 309 } |
310 | 310 |
311 Socket_Dev::Socket_Dev(const InstanceHandle& instance) : instance_(instance) { | 311 Socket_Dev::Socket_Dev(const InstanceHandle& instance) : instance_(instance) { |
312 } | 312 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 return get_interface<PPB_Ext_Socket_Dev_0_2>()->GetJoinedGroups( | 645 return get_interface<PPB_Ext_Socket_Dev_0_2>()->GetJoinedGroups( |
646 instance_.pp_instance(), | 646 instance_.pp_instance(), |
647 socket_id_var.pp_var(), | 647 socket_id_var.pp_var(), |
648 callback.output(), | 648 callback.output(), |
649 callback.pp_completion_callback()); | 649 callback.pp_completion_callback()); |
650 } | 650 } |
651 | 651 |
652 } // namespace socket | 652 } // namespace socket |
653 } // namespace ext | 653 } // namespace ext |
654 } // namespace pp | 654 } // namespace pp |
OLD | NEW |