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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 PickleIterator* iter, | 653 PickleIterator* iter, |
654 param_type* r) { | 654 param_type* r) { |
655 return ParamTraits<ListValue>::Read(m, iter, &(r->values_)); | 655 return ParamTraits<ListValue>::Read(m, iter, &(r->values_)); |
656 } | 656 } |
657 | 657 |
658 // static | 658 // static |
659 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, | 659 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, |
660 std::string* l) { | 660 std::string* l) { |
661 } | 661 } |
662 | 662 |
| 663 // ppapi::SocketOptionData ----------------------------------------------------- |
| 664 |
| 665 // static |
| 666 void ParamTraits<ppapi::SocketOptionData>::Write(Message* m, |
| 667 const param_type& p) { |
| 668 ppapi::SocketOptionData::Type type = p.GetType(); |
| 669 ParamTraits<int32_t>::Write(m, static_cast<int32_t>(type)); |
| 670 switch (type) { |
| 671 case ppapi::SocketOptionData::TYPE_INVALID: { |
| 672 break; |
| 673 } |
| 674 case ppapi::SocketOptionData::TYPE_BOOL: { |
| 675 bool out_value = false; |
| 676 bool result = p.GetBool(&out_value); |
| 677 // Suppress unused variable warnings. |
| 678 static_cast<void>(result); |
| 679 DCHECK(result); |
| 680 |
| 681 ParamTraits<bool>::Write(m, out_value); |
| 682 break; |
| 683 } |
| 684 case ppapi::SocketOptionData::TYPE_INT32: { |
| 685 int32_t out_value = false; |
| 686 bool result = p.GetInt32(&out_value); |
| 687 // Suppress unused variable warnings. |
| 688 static_cast<void>(result); |
| 689 DCHECK(result); |
| 690 |
| 691 ParamTraits<int32_t>::Write(m, out_value); |
| 692 break; |
| 693 } |
| 694 // No default so the compiler will warn on new types. |
| 695 } |
| 696 } |
| 697 |
| 698 // static |
| 699 bool ParamTraits<ppapi::SocketOptionData>::Read(const Message* m, |
| 700 PickleIterator* iter, |
| 701 param_type* r) { |
| 702 *r = ppapi::SocketOptionData(); |
| 703 int32_t type = 0; |
| 704 if (!ParamTraits<int32_t>::Read(m, iter, &type)) |
| 705 return false; |
| 706 if (type != ppapi::SocketOptionData::TYPE_INVALID && |
| 707 type != ppapi::SocketOptionData::TYPE_BOOL && |
| 708 type != ppapi::SocketOptionData::TYPE_INT32) { |
| 709 return false; |
| 710 } |
| 711 switch (static_cast<ppapi::SocketOptionData::Type>(type)) { |
| 712 case ppapi::SocketOptionData::TYPE_INVALID: { |
| 713 return true; |
| 714 } |
| 715 case ppapi::SocketOptionData::TYPE_BOOL: { |
| 716 bool value = false; |
| 717 if (!ParamTraits<bool>::Read(m, iter, &value)) |
| 718 return false; |
| 719 r->SetBool(value); |
| 720 return true; |
| 721 } |
| 722 case ppapi::SocketOptionData::TYPE_INT32: { |
| 723 int32_t value = false; |
| 724 if (!ParamTraits<int32_t>::Read(m, iter, &value)) |
| 725 return false; |
| 726 r->SetInt32(value); |
| 727 return true; |
| 728 } |
| 729 // No default so the compiler will warn on new types. |
| 730 } |
| 731 return false; |
| 732 } |
| 733 |
| 734 // static |
| 735 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, |
| 736 std::string* l) { |
| 737 } |
| 738 |
663 } // namespace IPC | 739 } // namespace IPC |
OLD | NEW |