OLD | NEW |
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 // static | 339 // static |
340 void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m, | 340 void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m, |
341 const param_type& p) { | 341 const param_type& p) { |
342 ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); | 342 ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); |
343 switch (p.type()) { | 343 switch (p.type()) { |
344 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: | 344 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: |
345 ParamTraits<base::SharedMemoryHandle>::Write(m, p.shmem()); | 345 ParamTraits<base::SharedMemoryHandle>::Write(m, p.shmem()); |
346 break; | 346 break; |
347 case ppapi::proxy::SerializedHandle::SOCKET: | 347 case ppapi::proxy::SerializedHandle::SOCKET: |
348 case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: | 348 case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: |
349 case ppapi::proxy::SerializedHandle::FILE: | |
350 ParamTraits<IPC::PlatformFileForTransit>::Write(m, p.descriptor()); | 349 ParamTraits<IPC::PlatformFileForTransit>::Write(m, p.descriptor()); |
351 break; | 350 break; |
352 case ppapi::proxy::SerializedHandle::INVALID: | 351 case ppapi::proxy::SerializedHandle::INVALID: |
353 break; | 352 break; |
354 // No default so the compiler will warn on new types. | 353 // No default so the compiler will warn on new types. |
355 } | 354 } |
356 } | 355 } |
357 | 356 |
358 // static | 357 // static |
359 bool ParamTraits<ppapi::proxy::SerializedHandle>::Read(const Message* m, | 358 bool ParamTraits<ppapi::proxy::SerializedHandle>::Read(const Message* m, |
(...skipping 20 matching lines...) Expand all Loading... |
380 break; | 379 break; |
381 } | 380 } |
382 case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: { | 381 case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: { |
383 IPC::PlatformFileForTransit desc; | 382 IPC::PlatformFileForTransit desc; |
384 if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &desc)) { | 383 if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &desc)) { |
385 r->set_channel_handle(desc); | 384 r->set_channel_handle(desc); |
386 return true; | 385 return true; |
387 } | 386 } |
388 break; | 387 break; |
389 } | 388 } |
390 case ppapi::proxy::SerializedHandle::FILE: { | |
391 IPC::PlatformFileForTransit desc; | |
392 if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &desc)) { | |
393 r->set_file_handle(desc); | |
394 return true; | |
395 } | |
396 break; | |
397 } | |
398 case ppapi::proxy::SerializedHandle::INVALID: | 389 case ppapi::proxy::SerializedHandle::INVALID: |
399 return true; | 390 return true; |
400 // No default so the compiler will warn us if a new type is added. | 391 // No default so the compiler will warn us if a new type is added. |
401 } | 392 } |
402 return false; | 393 return false; |
403 } | 394 } |
404 | 395 |
405 // static | 396 // static |
406 void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, | 397 void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, |
407 std::string* l) { | 398 std::string* l) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 ParamTraits<int32_t>::Read(m, iter, &r->letter_spacing) && | 545 ParamTraits<int32_t>::Read(m, iter, &r->letter_spacing) && |
555 ParamTraits<int32_t>::Read(m, iter, &r->word_spacing); | 546 ParamTraits<int32_t>::Read(m, iter, &r->word_spacing); |
556 } | 547 } |
557 | 548 |
558 // static | 549 // static |
559 void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log( | 550 void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log( |
560 const param_type& p, | 551 const param_type& p, |
561 std::string* l) { | 552 std::string* l) { |
562 } | 553 } |
563 | 554 |
564 // ppapi::PepperFilePath ------------------------------------------------------- | |
565 | |
566 // static | |
567 void ParamTraits<ppapi::PepperFilePath>::Write(Message* m, | |
568 const param_type& p) { | |
569 WriteParam(m, static_cast<unsigned>(p.domain())); | |
570 WriteParam(m, p.path()); | |
571 } | |
572 | |
573 // static | |
574 bool ParamTraits<ppapi::PepperFilePath>::Read(const Message* m, | |
575 PickleIterator* iter, | |
576 param_type* p) { | |
577 unsigned domain; | |
578 FilePath path; | |
579 if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path)) | |
580 return false; | |
581 if (domain > ppapi::PepperFilePath::DOMAIN_MAX_VALID) | |
582 return false; | |
583 | |
584 *p = ppapi::PepperFilePath( | |
585 static_cast<ppapi::PepperFilePath::Domain>(domain), path); | |
586 return true; | |
587 } | |
588 | |
589 // static | |
590 void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p, | |
591 std::string* l) { | |
592 l->append("("); | |
593 LogParam(static_cast<unsigned>(p.domain()), l); | |
594 l->append(", "); | |
595 LogParam(p.path(), l); | |
596 l->append(")"); | |
597 } | |
598 | |
599 // SerializedFlashMenu --------------------------------------------------------- | 555 // SerializedFlashMenu --------------------------------------------------------- |
600 | 556 |
601 // static | 557 // static |
602 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( | 558 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( |
603 Message* m, | 559 Message* m, |
604 const param_type& p) { | 560 const param_type& p) { |
605 p.WriteToMessage(m); | 561 p.WriteToMessage(m); |
606 } | 562 } |
607 | 563 |
608 // static | 564 // static |
(...skipping 24 matching lines...) Expand all Loading... |
633 param_type* r) { | 589 param_type* r) { |
634 return ParamTraits<ListValue>::Read(m, iter, &(r->values_)); | 590 return ParamTraits<ListValue>::Read(m, iter, &(r->values_)); |
635 } | 591 } |
636 | 592 |
637 // static | 593 // static |
638 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, | 594 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, |
639 std::string* l) { | 595 std::string* l) { |
640 } | 596 } |
641 | 597 |
642 } // namespace IPC | 598 } // namespace IPC |
OLD | NEW |