| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> // For memcpy | 9 #include <string.h> // For memcpy |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 WriteParam(m, static_cast<int>(p.size())); | 72 WriteParam(m, static_cast<int>(p.size())); |
| 73 for (size_t i = 0; i < p.size(); i++) | 73 for (size_t i = 0; i < p.size(); i++) |
| 74 WriteParam(m, p[i]); | 74 WriteParam(m, p[i]); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| 79 // PP_Bool --------------------------------------------------------------------- | 79 // PP_Bool --------------------------------------------------------------------- |
| 80 | 80 |
| 81 // static | 81 // static |
| 82 void ParamTraits<PP_Bool>::GetSize(base::PickleSizer* s, const param_type& p) { |
| 83 GetParamSize(s, PP_ToBool(p)); |
| 84 } |
| 85 |
| 86 // static |
| 82 void ParamTraits<PP_Bool>::Write(base::Pickle* m, const param_type& p) { | 87 void ParamTraits<PP_Bool>::Write(base::Pickle* m, const param_type& p) { |
| 83 WriteParam(m, PP_ToBool(p)); | 88 WriteParam(m, PP_ToBool(p)); |
| 84 } | 89 } |
| 85 | 90 |
| 86 // static | 91 // static |
| 87 bool ParamTraits<PP_Bool>::Read(const base::Pickle* m, | 92 bool ParamTraits<PP_Bool>::Read(const base::Pickle* m, |
| 88 base::PickleIterator* iter, | 93 base::PickleIterator* iter, |
| 89 param_type* r) { | 94 param_type* r) { |
| 90 // We specifically want to be strict here about what types of input we accept, | 95 // We specifically want to be strict here about what types of input we accept, |
| 91 // which ParamTraits<bool> does for us. We don't want to deserialize "2" into | 96 // which ParamTraits<bool> does for us. We don't want to deserialize "2" into |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // static | 149 // static |
| 145 void ParamTraits<PP_KeyInformation>::Log(const param_type& p, std::string* l) { | 150 void ParamTraits<PP_KeyInformation>::Log(const param_type& p, std::string* l) { |
| 146 l->append("<PP_KeyInformation ("); | 151 l->append("<PP_KeyInformation ("); |
| 147 LogParam(p.key_id_size, l); | 152 LogParam(p.key_id_size, l); |
| 148 l->append(" bytes)>"); | 153 l->append(" bytes)>"); |
| 149 } | 154 } |
| 150 | 155 |
| 151 // PP_NetAddress_Private ------------------------------------------------------- | 156 // PP_NetAddress_Private ------------------------------------------------------- |
| 152 | 157 |
| 153 // static | 158 // static |
| 159 void ParamTraits<PP_NetAddress_Private>::GetSize(base::PickleSizer* s, |
| 160 const param_type& p) { |
| 161 GetParamSize(s, p.size); |
| 162 s->AddBytes(static_cast<int>(p.size)); |
| 163 } |
| 164 |
| 165 // static |
| 154 void ParamTraits<PP_NetAddress_Private>::Write(base::Pickle* m, | 166 void ParamTraits<PP_NetAddress_Private>::Write(base::Pickle* m, |
| 155 const param_type& p) { | 167 const param_type& p) { |
| 156 WriteParam(m, p.size); | 168 WriteParam(m, p.size); |
| 157 m->WriteBytes(p.data, static_cast<int>(p.size)); | 169 m->WriteBytes(p.data, static_cast<int>(p.size)); |
| 158 } | 170 } |
| 159 | 171 |
| 160 // static | 172 // static |
| 161 bool ParamTraits<PP_NetAddress_Private>::Read(const base::Pickle* m, | 173 bool ParamTraits<PP_NetAddress_Private>::Read(const base::Pickle* m, |
| 162 base::PickleIterator* iter, | 174 base::PickleIterator* iter, |
| 163 param_type* p) { | 175 param_type* p) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 179 void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, | 191 void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, |
| 180 std::string* l) { | 192 std::string* l) { |
| 181 l->append("<PP_NetAddress_Private ("); | 193 l->append("<PP_NetAddress_Private ("); |
| 182 LogParam(p.size, l); | 194 LogParam(p.size, l); |
| 183 l->append(" bytes)>"); | 195 l->append(" bytes)>"); |
| 184 } | 196 } |
| 185 | 197 |
| 186 // HostResource ---------------------------------------------------------------- | 198 // HostResource ---------------------------------------------------------------- |
| 187 | 199 |
| 188 // static | 200 // static |
| 201 void ParamTraits<ppapi::HostResource>::GetSize(base::PickleSizer* s, |
| 202 const param_type& p) { |
| 203 GetParamSize(s, p.instance()); |
| 204 GetParamSize(s, p.host_resource()); |
| 205 } |
| 206 |
| 207 // static |
| 189 void ParamTraits<ppapi::HostResource>::Write(base::Pickle* m, | 208 void ParamTraits<ppapi::HostResource>::Write(base::Pickle* m, |
| 190 const param_type& p) { | 209 const param_type& p) { |
| 191 WriteParam(m, p.instance()); | 210 WriteParam(m, p.instance()); |
| 192 WriteParam(m, p.host_resource()); | 211 WriteParam(m, p.host_resource()); |
| 193 } | 212 } |
| 194 | 213 |
| 195 // static | 214 // static |
| 196 bool ParamTraits<ppapi::HostResource>::Read(const base::Pickle* m, | 215 bool ParamTraits<ppapi::HostResource>::Read(const base::Pickle* m, |
| 197 base::PickleIterator* iter, | 216 base::PickleIterator* iter, |
| 198 param_type* r) { | 217 param_type* r) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 265 } |
| 247 | 266 |
| 248 // static | 267 // static |
| 249 void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( | 268 void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( |
| 250 const param_type& p, | 269 const param_type& p, |
| 251 std::string* l) { | 270 std::string* l) { |
| 252 } | 271 } |
| 253 | 272 |
| 254 // ppapi::PpapiPermissions ----------------------------------------------------- | 273 // ppapi::PpapiPermissions ----------------------------------------------------- |
| 255 | 274 |
| 275 // static |
| 276 void ParamTraits<ppapi::PpapiPermissions>::GetSize(base::PickleSizer* s, |
| 277 const param_type& p) { |
| 278 GetParamSize(s, p.GetBits()); |
| 279 } |
| 280 |
| 281 // static |
| 256 void ParamTraits<ppapi::PpapiPermissions>::Write(base::Pickle* m, | 282 void ParamTraits<ppapi::PpapiPermissions>::Write(base::Pickle* m, |
| 257 const param_type& p) { | 283 const param_type& p) { |
| 258 WriteParam(m, p.GetBits()); | 284 WriteParam(m, p.GetBits()); |
| 259 } | 285 } |
| 260 | 286 |
| 261 // static | 287 // static |
| 262 bool ParamTraits<ppapi::PpapiPermissions>::Read(const base::Pickle* m, | 288 bool ParamTraits<ppapi::PpapiPermissions>::Read(const base::Pickle* m, |
| 263 base::PickleIterator* iter, | 289 base::PickleIterator* iter, |
| 264 param_type* r) { | 290 param_type* r) { |
| 265 uint32_t bits; | 291 uint32_t bits; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 } | 694 } |
| 669 | 695 |
| 670 // static | 696 // static |
| 671 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, | 697 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, |
| 672 std::string* l) { | 698 std::string* l) { |
| 673 } | 699 } |
| 674 | 700 |
| 675 // ppapi::CompositorLayerData -------------------------------------------------- | 701 // ppapi::CompositorLayerData -------------------------------------------------- |
| 676 | 702 |
| 677 // static | 703 // static |
| 704 void ParamTraits<ppapi::CompositorLayerData::Transform>::GetSize( |
| 705 base::PickleSizer* s, const param_type& p) { |
| 706 for (size_t i = 0; i < arraysize(p.matrix); i++) |
| 707 GetParamSize(s, p.matrix[i]); |
| 708 } |
| 709 |
| 710 // static |
| 678 void ParamTraits<ppapi::CompositorLayerData::Transform>::Write( | 711 void ParamTraits<ppapi::CompositorLayerData::Transform>::Write( |
| 679 base::Pickle* m, | 712 base::Pickle* m, |
| 680 const param_type& p) { | 713 const param_type& p) { |
| 681 for (size_t i = 0; i < arraysize(p.matrix); i++) | 714 for (size_t i = 0; i < arraysize(p.matrix); i++) |
| 682 WriteParam(m, p.matrix[i]); | 715 WriteParam(m, p.matrix[i]); |
| 683 } | 716 } |
| 684 | 717 |
| 685 // static | 718 // static |
| 686 bool ParamTraits<ppapi::CompositorLayerData::Transform>::Read( | 719 bool ParamTraits<ppapi::CompositorLayerData::Transform>::Read( |
| 687 const base::Pickle* m, | 720 const base::Pickle* m, |
| 688 base::PickleIterator* iter, | 721 base::PickleIterator* iter, |
| 689 param_type* r) { | 722 param_type* r) { |
| 690 for (size_t i = 0; i < arraysize(r->matrix);i++) { | 723 for (size_t i = 0; i < arraysize(r->matrix);i++) { |
| 691 if (!ReadParam(m, iter, &r->matrix[i])) | 724 if (!ReadParam(m, iter, &r->matrix[i])) |
| 692 return false; | 725 return false; |
| 693 } | 726 } |
| 694 return true; | 727 return true; |
| 695 } | 728 } |
| 696 | 729 |
| 697 void ParamTraits<ppapi::CompositorLayerData::Transform>::Log( | 730 void ParamTraits<ppapi::CompositorLayerData::Transform>::Log( |
| 698 const param_type& p, | 731 const param_type& p, |
| 699 std::string* l) { | 732 std::string* l) { |
| 700 } | 733 } |
| 701 | 734 |
| 702 } // namespace IPC | 735 } // namespace IPC |
| OLD | NEW |