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

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

Issue 10828023: PPAPI/NaCl: Make NaClIPCAdapter transfer handles more generally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review? Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 param_type* r) { 305 param_type* r) {
306 return ReadVectorWithoutCopy(m, iter, r); 306 return ReadVectorWithoutCopy(m, iter, r);
307 } 307 }
308 308
309 // static 309 // static
310 void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Log( 310 void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Log(
311 const param_type& p, 311 const param_type& p,
312 std::string* l) { 312 std::string* l) {
313 } 313 }
314 314
315 #if !defined(OS_NACL) 315 // SerializedHandle ------------------------------------------------------------
316
317 // static
318 void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m,
319 const param_type& p) {
320 m->WriteInt(p.type());
321 switch (p.type()) {
322 case ppapi::proxy::SerializedHandle::SHARED_MEMORY:
323 ParamTraits<base::SharedMemoryHandle>::Write(m, p.shmem());
324 ParamTraits<uint32_t>::Write(m, p.size());
325 break;
326 case ppapi::proxy::SerializedHandle::SOCKET:
327 ParamTraits<IPC::PlatformFileForTransit>::Write(m, p.descriptor());
328 break;
329 case ppapi::proxy::SerializedHandle::INVALID:
330 break;
331 // no default so the compiler will warn on new types.
332 }
333 }
334
335 // static
336 bool ParamTraits<ppapi::proxy::SerializedHandle>::Read(const Message* m,
337 PickleIterator* iter,
338 param_type* r) {
339 int type;
340 if (!m->ReadInt(iter, &type))
341 return false;
342 bool success = false;
343 switch (type) {
344 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: {
345 base::SharedMemoryHandle handle;
346 uint32_t size;
347 success = ParamTraits<base::SharedMemoryHandle>::Read(m, iter, &handle) &&
348 ParamTraits<uint32_t>::Read(m, iter, &size);
349 if (success)
350 r->set_shmem(handle, size);
351 break;
352 }
353 case ppapi::proxy::SerializedHandle::SOCKET: {
354 IPC::PlatformFileForTransit socket;
355 success = ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter,
356 &socket);
357 if (success)
358 r->set_socket(socket);
359 break;
360 }
361 case ppapi::proxy::SerializedHandle::INVALID:
362 break;
363 // No default so the compiler will warn us if a new type is added.
364 }
365 return success;
366 }
367
368 // static
369 void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p,
370 std::string* l) {
371 }
372
373 #if !defined(OS_NACL) && !defined(NACL_WIN64)
316 // PPBFlash_DrawGlyphs_Params -------------------------------------------------- 374 // PPBFlash_DrawGlyphs_Params --------------------------------------------------
317 // static 375 // static
318 void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( 376 void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write(
319 Message* m, 377 Message* m,
320 const param_type& p) { 378 const param_type& p) {
321 ParamTraits<PP_Instance>::Write(m, p.instance); 379 ParamTraits<PP_Instance>::Write(m, p.instance);
322 ParamTraits<ppapi::HostResource>::Write(m, p.image_data); 380 ParamTraits<ppapi::HostResource>::Write(m, p.image_data);
323 ParamTraits<ppapi::proxy::SerializedFontDescription>::Write(m, p.font_desc); 381 ParamTraits<ppapi::proxy::SerializedFontDescription>::Write(m, p.font_desc);
324 ParamTraits<uint32_t>::Write(m, p.color); 382 ParamTraits<uint32_t>::Write(m, p.color);
325 ParamTraits<PP_Point>::Write(m, p.position); 383 ParamTraits<PP_Point>::Write(m, p.position);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read(const Message* m, 558 bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read(const Message* m,
501 PickleIterator* iter, 559 PickleIterator* iter,
502 param_type* r) { 560 param_type* r) {
503 return ParamTraits<ListValue>::Read(m, iter, &(r->values_)); 561 return ParamTraits<ListValue>::Read(m, iter, &(r->values_));
504 } 562 }
505 563
506 // static 564 // static
507 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, 565 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p,
508 std::string* l) { 566 std::string* l) {
509 } 567 }
510 #endif // !defined(OS_NACL) 568 #endif // !defined(OS_NACL) && !defined(NACL_WIN64)
511 569
512 } // namespace IPC 570 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698