Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: ppapi/proxy/ppapi_param_traits.cc

Issue 9455092: HostResolver is exposed to plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added shared declaration of GetPPB_HostResolver_Private_0_1_Thunk. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 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/proxy/ppapi_param_traits.h" 5 #include "ppapi/proxy/ppapi_param_traits.h"
6 6
7 #include <string.h> // For memcpy 7 #include <string.h> // For memcpy
8 8
9 #include "ppapi/c/pp_file_info.h" 9 #include "ppapi/c/pp_file_info.h"
10 #include "ppapi/c/pp_resource.h" 10 #include "ppapi/c/pp_resource.h"
11 #include "ppapi/c/private/ppb_flash_tcp_socket.h" 11 #include "ppapi/c/private/ppb_flash_tcp_socket.h"
12 #include "ppapi/proxy/ppapi_messages.h" 12 #include "ppapi/proxy/ppapi_messages.h"
13 #include "ppapi/proxy/serialized_flash_menu.h"
13 #include "ppapi/proxy/serialized_var.h" 14 #include "ppapi/proxy/serialized_var.h"
14 #include "ppapi/proxy/serialized_flash_menu.h"
15 #include "ppapi/shared_impl/host_resource.h" 15 #include "ppapi/shared_impl/host_resource.h"
16 #include "ppapi/shared_impl/private/network_list.h"
16 17
17 namespace IPC { 18 namespace IPC {
18 19
19 namespace { 20 namespace {
20 21
21 // Deserializes a vector from IPC. This special version must be used instead 22 // Deserializes a vector from IPC. This special version must be used instead
22 // of the default IPC version when the vector contains a SerializedVar, either 23 // of the default IPC version when the vector contains a SerializedVar, either
23 // directly or indirectly (i.e. a vector of objects that have a SerializedVar 24 // directly or indirectly (i.e. a vector of objects that have a SerializedVar
24 // inside them). 25 // inside them).
25 // 26 //
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 131 system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
131 return false; 132 return false;
132 r->system_type = static_cast<PP_FileSystemType>(system_type); 133 r->system_type = static_cast<PP_FileSystemType>(system_type);
133 return true; 134 return true;
134 } 135 }
135 136
136 // static 137 // static
137 void ParamTraits<PP_FileInfo>::Log(const param_type& p, std::string* l) { 138 void ParamTraits<PP_FileInfo>::Log(const param_type& p, std::string* l) {
138 } 139 }
139 140
141 // PP_HostResolver_Private_Hint ------------------------------------------------
142 // static
143 void ParamTraits<PP_HostResolver_Private_Hint>::Write(Message* m,
144 const param_type& p) {
145 ParamTraits<int>::Write(m, static_cast<int>(p.family));
146 ParamTraits<int>::Write(m, static_cast<int>(p.flags));
147 }
148
149 // static
150 bool ParamTraits<PP_HostResolver_Private_Hint>::Read(const Message* m,
151 void** iter,
152 param_type* r) {
153 int family, flags;
154 if (!ParamTraits<int>::Read(m, iter, &family) ||
155 !ParamTraits<int>::Read(m, iter, &flags)) {
156 return false;
157 }
158
159 if (family != PP_NETADDRESSFAMILY_UNSPECIFIED &&
160 family != PP_NETADDRESSFAMILY_IPV4 &&
161 family != PP_NETADDRESSFAMILY_IPV6) {
162 return false;
163 }
164 r->family = static_cast<PP_NetAddressFamily_Private>(family);
165 r->flags = static_cast<PP_HostResolver_Private_Flags>(flags);
166 return true;
167 }
168
169 // static
170 void ParamTraits<PP_HostResolver_Private_Hint>::Log(const param_type& p,
171 std::string* l) {
172 }
173
140 // PP_NetAddress_Private ------------------------------------------------------- 174 // PP_NetAddress_Private -------------------------------------------------------
141 175
142 // static 176 // static
143 void ParamTraits<PP_NetAddress_Private>::Write(Message* m, 177 void ParamTraits<PP_NetAddress_Private>::Write(Message* m,
144 const param_type& p) { 178 const param_type& p) {
145 WriteParam(m, p.size); 179 WriteParam(m, p.size);
146 m->WriteBytes(p.data, static_cast<int>(p.size)); 180 m->WriteBytes(p.data, static_cast<int>(p.size));
147 } 181 }
148 182
149 // static 183 // static
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return false; 426 return false;
393 r->SetHostResource(instance, resource); 427 r->SetHostResource(instance, resource);
394 return true; 428 return true;
395 } 429 }
396 430
397 // static 431 // static
398 void ParamTraits<ppapi::HostResource>::Log(const param_type& p, 432 void ParamTraits<ppapi::HostResource>::Log(const param_type& p,
399 std::string* l) { 433 std::string* l) {
400 } 434 }
401 435
436 // NetworkList -----------------------------------------------------------------
437
438 // static
439 void ParamTraits<ppapi::NetworkList>::Write(Message* m, const param_type& p) {
440 ParamTraits<int>::Write(m, static_cast<int>(p.GetSize()));
441
442 std::string canonical_name;
443 PP_NetAddress_Private address;
444
445 for (size_t i = 0; i < p.GetSize(); ++i) {
446 p.GetItem(i, &canonical_name, &address);
447 ParamTraits<std::string>::Write(m, canonical_name);
448 ParamTraits<PP_NetAddress_Private>::Write(m, address);
449 }
450 }
451
452 // static
453 bool ParamTraits<ppapi::NetworkList>::Read(const Message* m,
454 void** iter,
455 param_type* r) {
456 int size;
457 if (!ParamTraits<int>::Read(m, iter, &size))
458 return false;
459
460 std::string canonical_name;
461 PP_NetAddress_Private address;
462
463 r->Clear();
464 while (size-- > 0) {
465 if (!ParamTraits<std::string>::Read(m, iter, &canonical_name) ||
466 !ParamTraits<PP_NetAddress_Private>::Read(m, iter, &address)) {
467 return false;
468 }
469 r->Append(canonical_name, address);
470 }
471
472 return true;
473 }
474
475 // static
476 void ParamTraits<ppapi::NetworkList>::Log(const param_type& p, std::string* l) {
477 }
478
402 // SerializedVar --------------------------------------------------------------- 479 // SerializedVar ---------------------------------------------------------------
403 480
404 // static 481 // static
405 void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m, 482 void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m,
406 const param_type& p) { 483 const param_type& p) {
407 p.WriteToMessage(m); 484 p.WriteToMessage(m);
408 } 485 }
409 486
410 // static 487 // static
411 bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const Message* m, 488 bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const Message* m,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 param_type* r) { 555 param_type* r) {
479 return r->ReadFromMessage(m, iter); 556 return r->ReadFromMessage(m, iter);
480 } 557 }
481 558
482 // static 559 // static
483 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, 560 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p,
484 std::string* l) { 561 std::string* l) {
485 } 562 }
486 563
487 } // namespace IPC 564 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698