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

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: CreateNetworkListFromAddrInfo marked as shared. 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 16
17 namespace IPC { 17 namespace IPC {
18 18
19 namespace { 19 namespace {
20 20
21 // Deserializes a vector from IPC. This special version must be used instead 21 // 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 22 // 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 23 // directly or indirectly (i.e. a vector of objects that have a SerializedVar
24 // inside them). 24 // inside them).
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 130 system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
131 return false; 131 return false;
132 r->system_type = static_cast<PP_FileSystemType>(system_type); 132 r->system_type = static_cast<PP_FileSystemType>(system_type);
133 return true; 133 return true;
134 } 134 }
135 135
136 // static 136 // static
137 void ParamTraits<PP_FileInfo>::Log(const param_type& p, std::string* l) { 137 void ParamTraits<PP_FileInfo>::Log(const param_type& p, std::string* l) {
138 } 138 }
139 139
140 // PP_HostResolver_Private_Hint ------------------------------------------------
141 // static
142 void ParamTraits<PP_HostResolver_Private_Hint>::Write(Message* m,
143 const param_type& p) {
144 ParamTraits<int>::Write(m, static_cast<int>(p.family));
145 ParamTraits<int>::Write(m, static_cast<int>(p.flags));
146 }
147
148 // static
149 bool ParamTraits<PP_HostResolver_Private_Hint>::Read(const Message* m,
150 void** iter,
151 param_type* r) {
152 int family, flags;
153 if (!ParamTraits<int>::Read(m, iter, &family) ||
154 !ParamTraits<int>::Read(m, iter, &flags)) {
155 return false;
156 }
157
158 if (family != PP_NETADDRESSFAMILY_UNSPECIFIED &&
159 family != PP_NETADDRESSFAMILY_IPV4 &&
160 family != PP_NETADDRESSFAMILY_IPV6) {
161 return false;
162 }
163 r->family = static_cast<PP_NetAddressFamily_Private>(family);
164 r->flags = static_cast<PP_HostResolver_Private_Flags>(flags);
165 return true;
166 }
167
168 // static
169 void ParamTraits<PP_HostResolver_Private_Hint>::Log(const param_type& p,
170 std::string* l) {
171 }
172
140 // PP_NetAddress_Private ------------------------------------------------------- 173 // PP_NetAddress_Private -------------------------------------------------------
141 174
142 // static 175 // static
143 void ParamTraits<PP_NetAddress_Private>::Write(Message* m, 176 void ParamTraits<PP_NetAddress_Private>::Write(Message* m,
144 const param_type& p) { 177 const param_type& p) {
145 WriteParam(m, p.size); 178 WriteParam(m, p.size);
146 m->WriteBytes(p.data, static_cast<int>(p.size)); 179 m->WriteBytes(p.data, static_cast<int>(p.size));
147 } 180 }
148 181
149 // static 182 // static
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return false; 425 return false;
393 r->SetHostResource(instance, resource); 426 r->SetHostResource(instance, resource);
394 return true; 427 return true;
395 } 428 }
396 429
397 // static 430 // static
398 void ParamTraits<ppapi::HostResource>::Log(const param_type& p, 431 void ParamTraits<ppapi::HostResource>::Log(const param_type& p,
399 std::string* l) { 432 std::string* l) {
400 } 433 }
401 434
435 // NameAndAddressPair ----------------------------------------------------------
436
437 // static
438 void ParamTraits<ppapi::NameAndAddressPair>::Write(Message* m,
439 const param_type& p) {
440 ParamTraits<std::string>::Write(m, p.canonical_name);
441 ParamTraits<PP_NetAddress_Private>::Write(m, p.address);
442 }
443
444 // static
445 bool ParamTraits<ppapi::NameAndAddressPair>::Read(const Message* m,
446 void** iter,
447 param_type* r) {
448 if (!ParamTraits<std::string>::Read(m, iter, &r->canonical_name) ||
449 !ParamTraits<PP_NetAddress_Private>::Read(m, iter, &r->address)) {
450 return false;
451 }
452 return true;
453 }
454
455 // static
456 void ParamTraits<ppapi::NameAndAddressPair>::Log(const param_type& p,
457 std::string* l) {
458 }
459
460 // NetworkList -----------------------------------------------------------------
461
462 // static
463 void ParamTraits<ppapi::NetworkList>::Write(Message* m, const param_type& p) {
464 ParamTraits<int>::Write(m, static_cast<int>(p.size()));
465 for (ppapi::NetworkList::const_iterator it = p.begin(); it != p.end(); ++it)
466 ParamTraits<ppapi::NameAndAddressPair>::Write(m, *it);
467 }
468
469 // static
470 bool ParamTraits<ppapi::NetworkList>::Read(const Message* m,
471 void** iter,
472 param_type* r) {
473 int size;
474 if (!ParamTraits<int>::Read(m, iter, &size))
475 return false;
476
477 r->resize(size);
478 for (int i = 0; i < size; ++i) {
479 if (!ParamTraits<ppapi::NameAndAddressPair>::Read(m, iter, &(*r)[i]))
480 return false;
481 }
482
483 return true;
484 }
485
486 // static
487 void ParamTraits<ppapi::NetworkList>::Log(const param_type& p, std::string* l) {
488 }
489
402 // SerializedVar --------------------------------------------------------------- 490 // SerializedVar ---------------------------------------------------------------
403 491
404 // static 492 // static
405 void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m, 493 void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m,
406 const param_type& p) { 494 const param_type& p) {
407 p.WriteToMessage(m); 495 p.WriteToMessage(m);
408 } 496 }
409 497
410 // static 498 // static
411 bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const Message* m, 499 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) { 566 param_type* r) {
479 return r->ReadFromMessage(m, iter); 567 return r->ReadFromMessage(m, iter);
480 } 568 }
481 569
482 // static 570 // static
483 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, 571 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p,
484 std::string* l) { 572 std::string* l) {
485 } 573 }
486 574
487 } // namespace IPC 575 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698