[email protected] | 339fbcff | 2012-02-29 16:10:32 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ppapi/proxy/ppapi_param_traits.h" |
| 6 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | #include <stdint.h> |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 9 | #include <string.h> // For memcpy |
| 10 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 11 | #include "base/macros.h" |
| 12 | #include "build/build_config.h" |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 13 | #include "ppapi/c/pp_resource.h" |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 14 | #include "ppapi/proxy/ppapi_messages.h" |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 15 | #include "ppapi/proxy/serialized_flash_menu.h" |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 16 | #include "ppapi/proxy/serialized_var.h" |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 17 | #include "ppapi/shared_impl/host_resource.h" |
[email protected] | de289526 | 2012-04-04 17:15:48 | [diff] [blame] | 18 | #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 19 | |
| 20 | namespace IPC { |
| 21 | |
[email protected] | 1162a6a | 2011-04-21 17:28:16 | [diff] [blame] | 22 | namespace { |
| 23 | |
| 24 | // Deserializes a vector from IPC. This special version must be used instead |
| 25 | // of the default IPC version when the vector contains a SerializedVar, either |
| 26 | // directly or indirectly (i.e. a vector of objects that have a SerializedVar |
| 27 | // inside them). |
| 28 | // |
| 29 | // The default vector deserializer does resize and then we deserialize into |
| 30 | // those allocated slots. However, the implementation of vector (at least in |
| 31 | // GCC's implementation), creates a new empty object using the default |
| 32 | // constructor, and then sets the rest of the items to that empty one using the |
| 33 | // copy constructor. |
| 34 | // |
| 35 | // Since we allocate the inner class when you call the default constructor and |
| 36 | // transfer the inner class when you do operator=, the entire vector will end |
| 37 | // up referring to the same inner class. Deserializing into this will just end |
| 38 | // up overwriting the same item over and over, since all the SerializedVars |
| 39 | // will refer to the same thing. |
| 40 | // |
| 41 | // The solution is to make a new object for each deserialized item, and then |
| 42 | // add it to the vector one at a time. |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 43 | template <typename T> |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 44 | bool ReadVectorWithoutCopy(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 45 | base::PickleIterator* iter, |
[email protected] | 1162a6a | 2011-04-21 17:28:16 | [diff] [blame] | 46 | std::vector<T>* output) { |
| 47 | // This part is just a copy of the the default ParamTraits vector Read(). |
| 48 | int size; |
| 49 | // ReadLength() checks for < 0 itself. |
avi | 48fc13b | 2014-12-28 23:31:48 | [diff] [blame] | 50 | if (!iter->ReadLength(&size)) |
[email protected] | 1162a6a | 2011-04-21 17:28:16 | [diff] [blame] | 51 | return false; |
| 52 | // Resizing beforehand is not safe, see BUG 1006367 for details. |
| 53 | if (INT_MAX / sizeof(T) <= static_cast<size_t>(size)) |
| 54 | return false; |
| 55 | |
| 56 | output->reserve(size); |
| 57 | for (int i = 0; i < size; i++) { |
| 58 | T cur; |
| 59 | if (!ReadParam(m, iter, &cur)) |
| 60 | return false; |
| 61 | output->push_back(cur); |
| 62 | } |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | // This serializes the vector of items to the IPC message in exactly the same |
| 67 | // way as the "regular" IPC vector serializer does. But having the code here |
| 68 | // saves us from having to copy this code into all ParamTraits that use the |
| 69 | // ReadVectorWithoutCopy function for deserializing. |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 70 | template <typename T> |
| 71 | void WriteVectorWithoutCopy(base::Pickle* m, const std::vector<T>& p) { |
[email protected] | 1162a6a | 2011-04-21 17:28:16 | [diff] [blame] | 72 | WriteParam(m, static_cast<int>(p.size())); |
| 73 | for (size_t i = 0; i < p.size(); i++) |
| 74 | WriteParam(m, p[i]); |
| 75 | } |
| 76 | |
| 77 | } // namespace |
| 78 | |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 79 | // PP_Bool --------------------------------------------------------------------- |
| 80 | |
| 81 | // static |
jam | 3db6b6d | 2016-05-13 15:09:58 | [diff] [blame] | 82 | void ParamTraits<PP_Bool>::GetSize(base::PickleSizer* s, const param_type& p) { |
| 83 | GetParamSize(s, PP_ToBool(p)); |
| 84 | } |
| 85 | |
| 86 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 87 | void ParamTraits<PP_Bool>::Write(base::Pickle* m, const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 88 | WriteParam(m, PP_ToBool(p)); |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 92 | bool ParamTraits<PP_Bool>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 93 | base::PickleIterator* iter, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 94 | param_type* r) { |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 95 | // We specifically want to be strict here about what types of input we accept, |
| 96 | // which ParamTraits<bool> does for us. We don't want to deserialize "2" into |
| 97 | // a PP_Bool, for example. |
| 98 | bool result = false; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 99 | if (!ReadParam(m, iter, &result)) |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 100 | return false; |
[email protected] | 8a855a0 | 2011-07-08 05:22:45 | [diff] [blame] | 101 | *r = PP_FromBool(result); |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 102 | return true; |
| 103 | } |
| 104 | |
| 105 | // static |
| 106 | void ParamTraits<PP_Bool>::Log(const param_type& p, std::string* l) { |
| 107 | } |
| 108 | |
jrummell | a68c98f | 2015-01-08 22:35:43 | [diff] [blame] | 109 | // PP_KeyInformation ------------------------------------------------------- |
| 110 | |
| 111 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 112 | void ParamTraits<PP_KeyInformation>::Write(base::Pickle* m, |
| 113 | const param_type& p) { |
jrummell | a68c98f | 2015-01-08 22:35:43 | [diff] [blame] | 114 | WriteParam(m, p.key_id_size); |
| 115 | m->WriteBytes(p.key_id, static_cast<int>(p.key_id_size)); |
| 116 | WriteParam(m, p.key_status); |
| 117 | WriteParam(m, p.system_code); |
| 118 | } |
| 119 | |
| 120 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 121 | bool ParamTraits<PP_KeyInformation>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 122 | base::PickleIterator* iter, |
jrummell | a68c98f | 2015-01-08 22:35:43 | [diff] [blame] | 123 | param_type* p) { |
| 124 | uint32_t size; |
| 125 | if (!ReadParam(m, iter, &size)) |
| 126 | return false; |
| 127 | if (size > sizeof(p->key_id)) |
| 128 | return false; |
| 129 | p->key_id_size = size; |
| 130 | |
| 131 | const char* data; |
| 132 | if (!iter->ReadBytes(&data, size)) |
| 133 | return false; |
| 134 | memcpy(p->key_id, data, size); |
| 135 | |
| 136 | PP_CdmKeyStatus key_status; |
| 137 | if (!ReadParam(m, iter, &key_status)) |
| 138 | return false; |
| 139 | p->key_status = key_status; |
| 140 | |
| 141 | uint32_t system_code; |
| 142 | if (!ReadParam(m, iter, &system_code)) |
| 143 | return false; |
| 144 | p->system_code = system_code; |
| 145 | |
| 146 | return true; |
| 147 | } |
| 148 | |
| 149 | // static |
| 150 | void ParamTraits<PP_KeyInformation>::Log(const param_type& p, std::string* l) { |
| 151 | l->append("<PP_KeyInformation ("); |
| 152 | LogParam(p.key_id_size, l); |
| 153 | l->append(" bytes)>"); |
| 154 | } |
| 155 | |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 156 | // PP_NetAddress_Private ------------------------------------------------------- |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 157 | |
| 158 | // static |
jam | 3db6b6d | 2016-05-13 15:09:58 | [diff] [blame] | 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 |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 166 | void ParamTraits<PP_NetAddress_Private>::Write(base::Pickle* m, |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 167 | const param_type& p) { |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 168 | WriteParam(m, p.size); |
| 169 | m->WriteBytes(p.data, static_cast<int>(p.size)); |
| 170 | } |
| 171 | |
| 172 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 173 | bool ParamTraits<PP_NetAddress_Private>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 174 | base::PickleIterator* iter, |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 175 | param_type* p) { |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 176 | uint16_t size; |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 177 | if (!ReadParam(m, iter, &size)) |
| 178 | return false; |
| 179 | if (size > sizeof(p->data)) |
| 180 | return false; |
| 181 | p->size = size; |
| 182 | |
| 183 | const char* data; |
avi | 48fc13b | 2014-12-28 23:31:48 | [diff] [blame] | 184 | if (!iter->ReadBytes(&data, size)) |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 185 | return false; |
| 186 | memcpy(p->data, data, size); |
| 187 | return true; |
| 188 | } |
| 189 | |
| 190 | // static |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 191 | void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, |
| 192 | std::string* l) { |
| 193 | l->append("<PP_NetAddress_Private ("); |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 194 | LogParam(p.size, l); |
| 195 | l->append(" bytes)>"); |
| 196 | } |
| 197 | |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 198 | // HostResource ---------------------------------------------------------------- |
| 199 | |
| 200 | // static |
jam | 3db6b6d | 2016-05-13 15:09:58 | [diff] [blame] | 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 |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 208 | void ParamTraits<ppapi::HostResource>::Write(base::Pickle* m, |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 209 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 210 | WriteParam(m, p.instance()); |
| 211 | WriteParam(m, p.host_resource()); |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 215 | bool ParamTraits<ppapi::HostResource>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 216 | base::PickleIterator* iter, |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 217 | param_type* r) { |
| 218 | PP_Instance instance; |
| 219 | PP_Resource resource; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 220 | if (!ReadParam(m, iter, &instance) || !ReadParam(m, iter, &resource)) |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 221 | return false; |
| 222 | r->SetHostResource(instance, resource); |
| 223 | return true; |
| 224 | } |
| 225 | |
| 226 | // static |
| 227 | void ParamTraits<ppapi::HostResource>::Log(const param_type& p, |
| 228 | std::string* l) { |
| 229 | } |
| 230 | |
| 231 | // SerializedVar --------------------------------------------------------------- |
| 232 | |
| 233 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 234 | void ParamTraits<ppapi::proxy::SerializedVar>::Write(base::Pickle* m, |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 235 | const param_type& p) { |
| 236 | p.WriteToMessage(m); |
| 237 | } |
| 238 | |
| 239 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 240 | bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 241 | base::PickleIterator* iter, |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 242 | param_type* r) { |
| 243 | return r->ReadFromMessage(m, iter); |
| 244 | } |
| 245 | |
| 246 | // static |
| 247 | void ParamTraits<ppapi::proxy::SerializedVar>::Log(const param_type& p, |
| 248 | std::string* l) { |
| 249 | } |
| 250 | |
| 251 | // std::vector<SerializedVar> -------------------------------------------------- |
| 252 | |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 253 | void ParamTraits<std::vector<ppapi::proxy::SerializedVar>>::Write( |
| 254 | base::Pickle* m, |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 255 | const param_type& p) { |
| 256 | WriteVectorWithoutCopy(m, p); |
| 257 | } |
| 258 | |
| 259 | // static |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 260 | bool ParamTraits<std::vector<ppapi::proxy::SerializedVar>>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 261 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 262 | base::PickleIterator* iter, |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 263 | param_type* r) { |
| 264 | return ReadVectorWithoutCopy(m, iter, r); |
| 265 | } |
| 266 | |
| 267 | // static |
| 268 | void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( |
| 269 | const param_type& p, |
| 270 | std::string* l) { |
| 271 | } |
| 272 | |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 273 | // ppapi::PpapiPermissions ----------------------------------------------------- |
| 274 | |
jam | 3db6b6d | 2016-05-13 15:09:58 | [diff] [blame] | 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 |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 282 | void ParamTraits<ppapi::PpapiPermissions>::Write(base::Pickle* m, |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 283 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 284 | WriteParam(m, p.GetBits()); |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 288 | bool ParamTraits<ppapi::PpapiPermissions>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 289 | base::PickleIterator* iter, |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 290 | param_type* r) { |
| 291 | uint32_t bits; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 292 | if (!ReadParam(m, iter, &bits)) |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 293 | return false; |
| 294 | *r = ppapi::PpapiPermissions(bits); |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | // static |
| 299 | void ParamTraits<ppapi::PpapiPermissions>::Log(const param_type& p, |
| 300 | std::string* l) { |
| 301 | } |
| 302 | |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 303 | // SerializedHandle ------------------------------------------------------------ |
| 304 | |
| 305 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 306 | void ParamTraits<ppapi::proxy::SerializedHandle>::Write(base::Pickle* m, |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 307 | const param_type& p) { |
| 308 | ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); |
| 309 | switch (p.type()) { |
| 310 | case ppapi::proxy::SerializedHandle::SHARED_MEMORY: |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 311 | WriteParam(m, p.shmem()); |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 312 | break; |
| 313 | case ppapi::proxy::SerializedHandle::SOCKET: |
[email protected] | 0c92b0d | 2012-12-08 00:46:23 | [diff] [blame] | 314 | case ppapi::proxy::SerializedHandle::FILE: |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 315 | WriteParam(m, p.descriptor()); |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 316 | break; |
| 317 | case ppapi::proxy::SerializedHandle::INVALID: |
| 318 | break; |
| 319 | // No default so the compiler will warn on new types. |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | // static |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 324 | bool ParamTraits<ppapi::proxy::SerializedHandle>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 325 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 326 | base::PickleIterator* iter, |
| 327 | param_type* r) { |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 328 | ppapi::proxy::SerializedHandle::Header header; |
| 329 | if (!ppapi::proxy::SerializedHandle::ReadHeader(iter, &header)) |
| 330 | return false; |
| 331 | switch (header.type) { |
| 332 | case ppapi::proxy::SerializedHandle::SHARED_MEMORY: { |
| 333 | base::SharedMemoryHandle handle; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 334 | if (ReadParam(m, iter, &handle)) { |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 335 | r->set_shmem(handle, header.size); |
| 336 | return true; |
| 337 | } |
| 338 | break; |
| 339 | } |
| 340 | case ppapi::proxy::SerializedHandle::SOCKET: { |
| 341 | IPC::PlatformFileForTransit socket; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 342 | if (ReadParam(m, iter, &socket)) { |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 343 | r->set_socket(socket); |
| 344 | return true; |
| 345 | } |
| 346 | break; |
| 347 | } |
[email protected] | 0c92b0d | 2012-12-08 00:46:23 | [diff] [blame] | 348 | case ppapi::proxy::SerializedHandle::FILE: { |
| 349 | IPC::PlatformFileForTransit desc; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 350 | if (ReadParam(m, iter, &desc)) { |
[email protected] | 80f8f84 | 2013-12-18 22:47:57 | [diff] [blame] | 351 | r->set_file_handle(desc, header.open_flags, header.file_io); |
[email protected] | 0c92b0d | 2012-12-08 00:46:23 | [diff] [blame] | 352 | return true; |
| 353 | } |
| 354 | break; |
| 355 | } |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 356 | case ppapi::proxy::SerializedHandle::INVALID: |
| 357 | return true; |
| 358 | // No default so the compiler will warn us if a new type is added. |
| 359 | } |
| 360 | return false; |
| 361 | } |
| 362 | |
| 363 | // static |
| 364 | void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, |
| 365 | std::string* l) { |
| 366 | } |
| 367 | |
[email protected] | 5a5d9b532 | 2012-10-02 22:20:23 | [diff] [blame] | 368 | // PPBURLLoader_UpdateProgress_Params ------------------------------------------ |
| 369 | |
| 370 | // static |
| 371 | void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Write( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 372 | base::Pickle* m, |
[email protected] | 5a5d9b532 | 2012-10-02 22:20:23 | [diff] [blame] | 373 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 374 | WriteParam(m, p.instance); |
| 375 | WriteParam(m, p.resource); |
| 376 | WriteParam(m, p.bytes_sent); |
| 377 | WriteParam(m, p.total_bytes_to_be_sent); |
| 378 | WriteParam(m, p.bytes_received); |
| 379 | WriteParam(m, p.total_bytes_to_be_received); |
[email protected] | 5a5d9b532 | 2012-10-02 22:20:23 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | // static |
| 383 | bool ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 384 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 385 | base::PickleIterator* iter, |
[email protected] | 5a5d9b532 | 2012-10-02 22:20:23 | [diff] [blame] | 386 | param_type* r) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 387 | return ReadParam(m, iter, &r->instance) && ReadParam(m, iter, &r->resource) && |
| 388 | ReadParam(m, iter, &r->bytes_sent) && |
| 389 | ReadParam(m, iter, &r->total_bytes_to_be_sent) && |
| 390 | ReadParam(m, iter, &r->bytes_received) && |
| 391 | ReadParam(m, iter, &r->total_bytes_to_be_received); |
[email protected] | 5a5d9b532 | 2012-10-02 22:20:23 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | // static |
| 395 | void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Log( |
| 396 | const param_type& p, |
| 397 | std::string* l) { |
| 398 | } |
| 399 | |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 400 | #if !defined(OS_NACL) && !defined(NACL_WIN64) |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 401 | // PPBFlash_DrawGlyphs_Params -------------------------------------------------- |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 402 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 403 | void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 404 | base::Pickle* m, |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 405 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 406 | WriteParam(m, p.instance); |
| 407 | WriteParam(m, p.image_data); |
| 408 | WriteParam(m, p.font_desc); |
| 409 | WriteParam(m, p.color); |
| 410 | WriteParam(m, p.position); |
| 411 | WriteParam(m, p.clip); |
| 412 | WriteParam(m, p.transformation[0][0]); |
| 413 | WriteParam(m, p.transformation[0][1]); |
| 414 | WriteParam(m, p.transformation[0][2]); |
| 415 | WriteParam(m, p.transformation[1][0]); |
| 416 | WriteParam(m, p.transformation[1][1]); |
| 417 | WriteParam(m, p.transformation[1][2]); |
| 418 | WriteParam(m, p.transformation[2][0]); |
| 419 | WriteParam(m, p.transformation[2][1]); |
| 420 | WriteParam(m, p.transformation[2][2]); |
| 421 | WriteParam(m, p.allow_subpixel_aa); |
| 422 | WriteParam(m, p.glyph_indices); |
| 423 | WriteParam(m, p.glyph_advances); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 427 | bool ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 428 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 429 | base::PickleIterator* iter, |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 430 | param_type* r) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 431 | return ReadParam(m, iter, &r->instance) && |
| 432 | ReadParam(m, iter, &r->image_data) && |
| 433 | ReadParam(m, iter, &r->font_desc) && ReadParam(m, iter, &r->color) && |
| 434 | ReadParam(m, iter, &r->position) && ReadParam(m, iter, &r->clip) && |
| 435 | ReadParam(m, iter, &r->transformation[0][0]) && |
| 436 | ReadParam(m, iter, &r->transformation[0][1]) && |
| 437 | ReadParam(m, iter, &r->transformation[0][2]) && |
| 438 | ReadParam(m, iter, &r->transformation[1][0]) && |
| 439 | ReadParam(m, iter, &r->transformation[1][1]) && |
| 440 | ReadParam(m, iter, &r->transformation[1][2]) && |
| 441 | ReadParam(m, iter, &r->transformation[2][0]) && |
| 442 | ReadParam(m, iter, &r->transformation[2][1]) && |
| 443 | ReadParam(m, iter, &r->transformation[2][2]) && |
| 444 | ReadParam(m, iter, &r->allow_subpixel_aa) && |
| 445 | ReadParam(m, iter, &r->glyph_indices) && |
| 446 | ReadParam(m, iter, &r->glyph_advances) && |
| 447 | r->glyph_indices.size() == r->glyph_advances.size(); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 451 | void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Log( |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 452 | const param_type& p, |
| 453 | std::string* l) { |
| 454 | } |
| 455 | |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 456 | // SerializedDirEntry ---------------------------------------------------------- |
| 457 | |
| 458 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 459 | void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(base::Pickle* m, |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 460 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 461 | WriteParam(m, p.name); |
| 462 | WriteParam(m, p.is_dir); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | // static |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 466 | bool ParamTraits<ppapi::proxy::SerializedDirEntry>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 467 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 468 | base::PickleIterator* iter, |
| 469 | param_type* r) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 470 | return ReadParam(m, iter, &r->name) && ReadParam(m, iter, &r->is_dir); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 474 | void ParamTraits<ppapi::proxy::SerializedDirEntry>::Log(const param_type& p, |
| 475 | std::string* l) { |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 476 | } |
| 477 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 478 | // ppapi::proxy::SerializedFontDescription ------------------------------------- |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 479 | |
| 480 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 481 | void ParamTraits<ppapi::proxy::SerializedFontDescription>::Write( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 482 | base::Pickle* m, |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 483 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 484 | WriteParam(m, p.face); |
| 485 | WriteParam(m, p.family); |
| 486 | WriteParam(m, p.size); |
| 487 | WriteParam(m, p.weight); |
| 488 | WriteParam(m, p.italic); |
| 489 | WriteParam(m, p.small_caps); |
| 490 | WriteParam(m, p.letter_spacing); |
| 491 | WriteParam(m, p.word_spacing); |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 495 | bool ParamTraits<ppapi::proxy::SerializedFontDescription>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 496 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 497 | base::PickleIterator* iter, |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 498 | param_type* r) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 499 | return ReadParam(m, iter, &r->face) && ReadParam(m, iter, &r->family) && |
| 500 | ReadParam(m, iter, &r->size) && ReadParam(m, iter, &r->weight) && |
| 501 | ReadParam(m, iter, &r->italic) && ReadParam(m, iter, &r->small_caps) && |
| 502 | ReadParam(m, iter, &r->letter_spacing) && |
| 503 | ReadParam(m, iter, &r->word_spacing); |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 507 | void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log( |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 508 | const param_type& p, |
| 509 | std::string* l) { |
| 510 | } |
[email protected] | 725056b7 | 2013-03-16 09:57:51 | [diff] [blame] | 511 | #endif // !defined(OS_NACL) && !defined(NACL_WIN64) |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 512 | |
[email protected] | 725056b7 | 2013-03-16 09:57:51 | [diff] [blame] | 513 | // ppapi::proxy::SerializedTrueTypeFontDesc ------------------------------------ |
| 514 | |
| 515 | // static |
| 516 | void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Write( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 517 | base::Pickle* m, |
[email protected] | 725056b7 | 2013-03-16 09:57:51 | [diff] [blame] | 518 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 519 | WriteParam(m, p.family); |
| 520 | WriteParam(m, p.generic_family); |
| 521 | WriteParam(m, p.style); |
| 522 | WriteParam(m, p.weight); |
| 523 | WriteParam(m, p.width); |
| 524 | WriteParam(m, p.charset); |
[email protected] | 725056b7 | 2013-03-16 09:57:51 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | // static |
| 528 | bool ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 529 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 530 | base::PickleIterator* iter, |
[email protected] | 725056b7 | 2013-03-16 09:57:51 | [diff] [blame] | 531 | param_type* r) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 532 | return ReadParam(m, iter, &r->family) && |
| 533 | ReadParam(m, iter, &r->generic_family) && |
| 534 | ReadParam(m, iter, &r->style) && ReadParam(m, iter, &r->weight) && |
| 535 | ReadParam(m, iter, &r->width) && ReadParam(m, iter, &r->charset); |
[email protected] | 725056b7 | 2013-03-16 09:57:51 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | // static |
| 539 | void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Log( |
| 540 | const param_type& p, |
| 541 | std::string* l) { |
| 542 | } |
| 543 | |
| 544 | #if !defined(OS_NACL) && !defined(NACL_WIN64) |
[email protected] | 0c92b0d | 2012-12-08 00:46:23 | [diff] [blame] | 545 | // ppapi::PepperFilePath ------------------------------------------------------- |
| 546 | |
| 547 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 548 | void ParamTraits<ppapi::PepperFilePath>::Write(base::Pickle* m, |
[email protected] | 0c92b0d | 2012-12-08 00:46:23 | [diff] [blame] | 549 | const param_type& p) { |
| 550 | WriteParam(m, static_cast<unsigned>(p.domain())); |
| 551 | WriteParam(m, p.path()); |
| 552 | } |
| 553 | |
| 554 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 555 | bool ParamTraits<ppapi::PepperFilePath>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 556 | base::PickleIterator* iter, |
[email protected] | 0c92b0d | 2012-12-08 00:46:23 | [diff] [blame] | 557 | param_type* p) { |
| 558 | unsigned domain; |
[email protected] | d30a36f | 2013-02-07 04:16:26 | [diff] [blame] | 559 | base::FilePath path; |
[email protected] | 0c92b0d | 2012-12-08 00:46:23 | [diff] [blame] | 560 | if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path)) |
| 561 | return false; |
| 562 | if (domain > ppapi::PepperFilePath::DOMAIN_MAX_VALID) |
| 563 | return false; |
| 564 | |
| 565 | *p = ppapi::PepperFilePath( |
| 566 | static_cast<ppapi::PepperFilePath::Domain>(domain), path); |
| 567 | return true; |
| 568 | } |
| 569 | |
| 570 | // static |
| 571 | void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p, |
| 572 | std::string* l) { |
| 573 | l->append("("); |
| 574 | LogParam(static_cast<unsigned>(p.domain()), l); |
| 575 | l->append(", "); |
| 576 | LogParam(p.path(), l); |
| 577 | l->append(")"); |
| 578 | } |
| 579 | |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 580 | // SerializedFlashMenu --------------------------------------------------------- |
| 581 | |
| 582 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 583 | void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 584 | base::Pickle* m, |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 585 | const param_type& p) { |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 586 | p.WriteToMessage(m); |
| 587 | } |
| 588 | |
| 589 | // static |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 590 | bool ParamTraits<ppapi::proxy::SerializedFlashMenu>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 591 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 592 | base::PickleIterator* iter, |
| 593 | param_type* r) { |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 594 | return r->ReadFromMessage(m, iter); |
| 595 | } |
| 596 | |
| 597 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 598 | void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, |
| 599 | std::string* l) { |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 600 | } |
[email protected] | 667591d | 2012-09-04 21:30:12 | [diff] [blame] | 601 | #endif // !defined(OS_NACL) && !defined(NACL_WIN64) |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 602 | |
[email protected] | de289526 | 2012-04-04 17:15:48 | [diff] [blame] | 603 | // PPB_X509Certificate_Fields -------------------------------------------------- |
| 604 | |
| 605 | // static |
| 606 | void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Write( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 607 | base::Pickle* m, |
[email protected] | de289526 | 2012-04-04 17:15:48 | [diff] [blame] | 608 | const param_type& p) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 609 | WriteParam(m, p.values_); |
[email protected] | de289526 | 2012-04-04 17:15:48 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | // static |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 613 | bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 614 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 615 | base::PickleIterator* iter, |
| 616 | param_type* r) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 617 | return ReadParam(m, iter, &(r->values_)); |
[email protected] | de289526 | 2012-04-04 17:15:48 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | // static |
| 621 | void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, |
| 622 | std::string* l) { |
| 623 | } |
| 624 | |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 625 | // ppapi::SocketOptionData ----------------------------------------------------- |
| 626 | |
| 627 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 628 | void ParamTraits<ppapi::SocketOptionData>::Write(base::Pickle* m, |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 629 | const param_type& p) { |
| 630 | ppapi::SocketOptionData::Type type = p.GetType(); |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 631 | WriteParam(m, static_cast<int32_t>(type)); |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 632 | switch (type) { |
| 633 | case ppapi::SocketOptionData::TYPE_INVALID: { |
| 634 | break; |
| 635 | } |
| 636 | case ppapi::SocketOptionData::TYPE_BOOL: { |
| 637 | bool out_value = false; |
| 638 | bool result = p.GetBool(&out_value); |
| 639 | // Suppress unused variable warnings. |
| 640 | static_cast<void>(result); |
| 641 | DCHECK(result); |
| 642 | |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 643 | WriteParam(m, out_value); |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 644 | break; |
| 645 | } |
| 646 | case ppapi::SocketOptionData::TYPE_INT32: { |
| 647 | int32_t out_value = 0; |
| 648 | bool result = p.GetInt32(&out_value); |
| 649 | // Suppress unused variable warnings. |
| 650 | static_cast<void>(result); |
| 651 | DCHECK(result); |
| 652 | |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 653 | WriteParam(m, out_value); |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 654 | break; |
| 655 | } |
| 656 | // No default so the compiler will warn on new types. |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | // static |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 661 | bool ParamTraits<ppapi::SocketOptionData>::Read(const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 662 | base::PickleIterator* iter, |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 663 | param_type* r) { |
| 664 | *r = ppapi::SocketOptionData(); |
| 665 | int32_t type = 0; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 666 | if (!ReadParam(m, iter, &type)) |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 667 | return false; |
| 668 | if (type != ppapi::SocketOptionData::TYPE_INVALID && |
| 669 | type != ppapi::SocketOptionData::TYPE_BOOL && |
| 670 | type != ppapi::SocketOptionData::TYPE_INT32) { |
| 671 | return false; |
| 672 | } |
| 673 | switch (static_cast<ppapi::SocketOptionData::Type>(type)) { |
| 674 | case ppapi::SocketOptionData::TYPE_INVALID: { |
| 675 | return true; |
| 676 | } |
| 677 | case ppapi::SocketOptionData::TYPE_BOOL: { |
| 678 | bool value = false; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 679 | if (!ReadParam(m, iter, &value)) |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 680 | return false; |
| 681 | r->SetBool(value); |
| 682 | return true; |
| 683 | } |
| 684 | case ppapi::SocketOptionData::TYPE_INT32: { |
| 685 | int32_t value = 0; |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 686 | if (!ReadParam(m, iter, &value)) |
[email protected] | 64a61fc | 2013-06-19 13:30:59 | [diff] [blame] | 687 | return false; |
| 688 | r->SetInt32(value); |
| 689 | return true; |
| 690 | } |
| 691 | // No default so the compiler will warn on new types. |
| 692 | } |
| 693 | return false; |
| 694 | } |
| 695 | |
| 696 | // static |
| 697 | void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, |
| 698 | std::string* l) { |
| 699 | } |
| 700 | |
[email protected] | c44620b | 2014-06-16 14:20:26 | [diff] [blame] | 701 | // ppapi::CompositorLayerData -------------------------------------------------- |
| 702 | |
| 703 | // static |
jam | 3db6b6d | 2016-05-13 15:09:58 | [diff] [blame] | 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 |
[email protected] | c44620b | 2014-06-16 14:20:26 | [diff] [blame] | 711 | void ParamTraits<ppapi::CompositorLayerData::Transform>::Write( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 712 | base::Pickle* m, |
[email protected] | c44620b | 2014-06-16 14:20:26 | [diff] [blame] | 713 | const param_type& p) { |
| 714 | for (size_t i = 0; i < arraysize(p.matrix); i++) |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 715 | WriteParam(m, p.matrix[i]); |
[email protected] | c44620b | 2014-06-16 14:20:26 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | // static |
| 719 | bool ParamTraits<ppapi::CompositorLayerData::Transform>::Read( |
rockot | 502c94f | 2016-02-03 20:20:16 | [diff] [blame] | 720 | const base::Pickle* m, |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 721 | base::PickleIterator* iter, |
[email protected] | c44620b | 2014-06-16 14:20:26 | [diff] [blame] | 722 | param_type* r) { |
| 723 | for (size_t i = 0; i < arraysize(r->matrix);i++) { |
bbudge | 03071f1 | 2015-11-02 23:51:20 | [diff] [blame] | 724 | if (!ReadParam(m, iter, &r->matrix[i])) |
[email protected] | c44620b | 2014-06-16 14:20:26 | [diff] [blame] | 725 | return false; |
| 726 | } |
| 727 | return true; |
| 728 | } |
| 729 | |
| 730 | void ParamTraits<ppapi::CompositorLayerData::Transform>::Log( |
| 731 | const param_type& p, |
| 732 | std::string* l) { |
| 733 | } |
| 734 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 735 | } // namespace IPC |