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

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

Issue 16959005: Implement PPB_UDPSocket_Dev: part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « ppapi/proxy/ppapi_param_traits.h ('k') | ppapi/proxy/udp_socket_private_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 PickleIterator* iter, 654 PickleIterator* iter,
655 param_type* r) { 655 param_type* r) {
656 return ParamTraits<ListValue>::Read(m, iter, &(r->values_)); 656 return ParamTraits<ListValue>::Read(m, iter, &(r->values_));
657 } 657 }
658 658
659 // static 659 // static
660 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, 660 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p,
661 std::string* l) { 661 std::string* l) {
662 } 662 }
663 663
664 // ppapi::SocketOptionData -----------------------------------------------------
665
666 // static
667 void ParamTraits<ppapi::SocketOptionData>::Write(Message* m,
668 const param_type& p) {
669 ppapi::SocketOptionData::Type type = p.GetType();
670 ParamTraits<int32_t>::Write(m, static_cast<int32_t>(type));
671 switch (type) {
672 case ppapi::SocketOptionData::TYPE_INVALID: {
673 break;
674 }
675 case ppapi::SocketOptionData::TYPE_BOOL: {
676 bool out_value = false;
677 bool result = p.GetBool(&out_value);
678 // Suppress unused variable warnings.
679 static_cast<void>(result);
680 DCHECK(result);
681
682 ParamTraits<bool>::Write(m, out_value);
683 break;
684 }
685 case ppapi::SocketOptionData::TYPE_INT32: {
686 int32_t out_value = 0;
687 bool result = p.GetInt32(&out_value);
688 // Suppress unused variable warnings.
689 static_cast<void>(result);
690 DCHECK(result);
691
692 ParamTraits<int32_t>::Write(m, out_value);
693 break;
694 }
695 // No default so the compiler will warn on new types.
696 }
697 }
698
699 // static
700 bool ParamTraits<ppapi::SocketOptionData>::Read(const Message* m,
701 PickleIterator* iter,
702 param_type* r) {
703 *r = ppapi::SocketOptionData();
704 int32_t type = 0;
705 if (!ParamTraits<int32_t>::Read(m, iter, &type))
706 return false;
707 if (type != ppapi::SocketOptionData::TYPE_INVALID &&
708 type != ppapi::SocketOptionData::TYPE_BOOL &&
709 type != ppapi::SocketOptionData::TYPE_INT32) {
710 return false;
711 }
712 switch (static_cast<ppapi::SocketOptionData::Type>(type)) {
713 case ppapi::SocketOptionData::TYPE_INVALID: {
714 return true;
715 }
716 case ppapi::SocketOptionData::TYPE_BOOL: {
717 bool value = false;
718 if (!ParamTraits<bool>::Read(m, iter, &value))
719 return false;
720 r->SetBool(value);
721 return true;
722 }
723 case ppapi::SocketOptionData::TYPE_INT32: {
724 int32_t value = 0;
725 if (!ParamTraits<int32_t>::Read(m, iter, &value))
726 return false;
727 r->SetInt32(value);
728 return true;
729 }
730 // No default so the compiler will warn on new types.
731 }
732 return false;
733 }
734
735 // static
736 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p,
737 std::string* l) {
738 }
739
664 } // namespace IPC 740 } // namespace IPC
OLDNEW
« no previous file with comments | « ppapi/proxy/ppapi_param_traits.h ('k') | ppapi/proxy/udp_socket_private_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698