[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 | |
| 7 | #include <string.h> // For memcpy |
| 8 | |
[email protected] | ea505a9d | 2011-07-07 18:34:40 | [diff] [blame] | 9 | #include "ppapi/c/pp_file_info.h" |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 10 | #include "ppapi/c/pp_resource.h" |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 11 | #include "ppapi/c/private/ppb_flash_tcp_socket.h" |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 12 | #include "ppapi/proxy/ppapi_messages.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 13 | #include "ppapi/proxy/serialized_var.h" |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 14 | #include "ppapi/proxy/serialized_flash_menu.h" |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 15 | #include "ppapi/shared_impl/host_resource.h" |
[email protected] | de289526 | 2012-04-04 17:15:48 | [diff] [blame] | 16 | #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 17 | |
| 18 | namespace IPC { |
| 19 | |
[email protected] | 1162a6a | 2011-04-21 17:28:16 | [diff] [blame] | 20 | namespace { |
| 21 | |
| 22 | // Deserializes a vector from IPC. This special version must be used instead |
| 23 | // of the default IPC version when the vector contains a SerializedVar, either |
| 24 | // directly or indirectly (i.e. a vector of objects that have a SerializedVar |
| 25 | // inside them). |
| 26 | // |
| 27 | // The default vector deserializer does resize and then we deserialize into |
| 28 | // those allocated slots. However, the implementation of vector (at least in |
| 29 | // GCC's implementation), creates a new empty object using the default |
| 30 | // constructor, and then sets the rest of the items to that empty one using the |
| 31 | // copy constructor. |
| 32 | // |
| 33 | // Since we allocate the inner class when you call the default constructor and |
| 34 | // transfer the inner class when you do operator=, the entire vector will end |
| 35 | // up referring to the same inner class. Deserializing into this will just end |
| 36 | // up overwriting the same item over and over, since all the SerializedVars |
| 37 | // will refer to the same thing. |
| 38 | // |
| 39 | // The solution is to make a new object for each deserialized item, and then |
| 40 | // add it to the vector one at a time. |
| 41 | template<typename T> |
| 42 | bool ReadVectorWithoutCopy(const Message* m, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 43 | PickleIterator* iter, |
[email protected] | 1162a6a | 2011-04-21 17:28:16 | [diff] [blame] | 44 | std::vector<T>* output) { |
| 45 | // This part is just a copy of the the default ParamTraits vector Read(). |
| 46 | int size; |
| 47 | // ReadLength() checks for < 0 itself. |
| 48 | if (!m->ReadLength(iter, &size)) |
| 49 | return false; |
| 50 | // Resizing beforehand is not safe, see BUG 1006367 for details. |
| 51 | if (INT_MAX / sizeof(T) <= static_cast<size_t>(size)) |
| 52 | return false; |
| 53 | |
| 54 | output->reserve(size); |
| 55 | for (int i = 0; i < size; i++) { |
| 56 | T cur; |
| 57 | if (!ReadParam(m, iter, &cur)) |
| 58 | return false; |
| 59 | output->push_back(cur); |
| 60 | } |
| 61 | return true; |
| 62 | } |
| 63 | |
| 64 | // This serializes the vector of items to the IPC message in exactly the same |
| 65 | // way as the "regular" IPC vector serializer does. But having the code here |
| 66 | // saves us from having to copy this code into all ParamTraits that use the |
| 67 | // ReadVectorWithoutCopy function for deserializing. |
| 68 | template<typename T> |
| 69 | void WriteVectorWithoutCopy(Message* m, const std::vector<T>& p) { |
| 70 | WriteParam(m, static_cast<int>(p.size())); |
| 71 | for (size_t i = 0; i < p.size(); i++) |
| 72 | WriteParam(m, p[i]); |
| 73 | } |
| 74 | |
| 75 | } // namespace |
| 76 | |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 77 | // PP_Bool --------------------------------------------------------------------- |
| 78 | |
| 79 | // static |
| 80 | void ParamTraits<PP_Bool>::Write(Message* m, const param_type& p) { |
[email protected] | 8a855a0 | 2011-07-08 05:22:45 | [diff] [blame] | 81 | ParamTraits<bool>::Write(m, PP_ToBool(p)); |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | // static |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 85 | bool ParamTraits<PP_Bool>::Read(const Message* m, |
| 86 | PickleIterator* iter, |
| 87 | param_type* r) { |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 88 | // We specifically want to be strict here about what types of input we accept, |
| 89 | // which ParamTraits<bool> does for us. We don't want to deserialize "2" into |
| 90 | // a PP_Bool, for example. |
| 91 | bool result = false; |
| 92 | if (!ParamTraits<bool>::Read(m, iter, &result)) |
| 93 | return false; |
[email protected] | 8a855a0 | 2011-07-08 05:22:45 | [diff] [blame] | 94 | *r = PP_FromBool(result); |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 95 | return true; |
| 96 | } |
| 97 | |
| 98 | // static |
| 99 | void ParamTraits<PP_Bool>::Log(const param_type& p, std::string* l) { |
| 100 | } |
| 101 | |
[email protected] | ea505a9d | 2011-07-07 18:34:40 | [diff] [blame] | 102 | // PP_FileInfo ------------------------------------------------------------- |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 103 | |
| 104 | // static |
[email protected] | ea505a9d | 2011-07-07 18:34:40 | [diff] [blame] | 105 | void ParamTraits<PP_FileInfo>::Write(Message* m, const param_type& p) { |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 106 | ParamTraits<int64_t>::Write(m, p.size); |
| 107 | ParamTraits<int>::Write(m, static_cast<int>(p.type)); |
| 108 | ParamTraits<int>::Write(m, static_cast<int>(p.system_type)); |
| 109 | ParamTraits<double>::Write(m, p.creation_time); |
| 110 | ParamTraits<double>::Write(m, p.last_access_time); |
| 111 | ParamTraits<double>::Write(m, p.last_modified_time); |
| 112 | } |
| 113 | |
| 114 | // static |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 115 | bool ParamTraits<PP_FileInfo>::Read(const Message* m, PickleIterator* iter, |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 116 | param_type* r) { |
| 117 | int type, system_type; |
| 118 | if (!ParamTraits<int64_t>::Read(m, iter, &r->size) || |
| 119 | !ParamTraits<int>::Read(m, iter, &type) || |
| 120 | !ParamTraits<int>::Read(m, iter, &system_type) || |
| 121 | !ParamTraits<double>::Read(m, iter, &r->creation_time) || |
| 122 | !ParamTraits<double>::Read(m, iter, &r->last_access_time) || |
| 123 | !ParamTraits<double>::Read(m, iter, &r->last_modified_time)) |
| 124 | return false; |
| 125 | if (type != PP_FILETYPE_REGULAR && |
| 126 | type != PP_FILETYPE_DIRECTORY && |
| 127 | type != PP_FILETYPE_OTHER) |
| 128 | return false; |
[email protected] | ea505a9d | 2011-07-07 18:34:40 | [diff] [blame] | 129 | r->type = static_cast<PP_FileType>(type); |
[email protected] | cc6db92 | 2011-12-10 16:54:22 | [diff] [blame] | 130 | if (system_type != PP_FILESYSTEMTYPE_INVALID && |
| 131 | system_type != PP_FILESYSTEMTYPE_EXTERNAL && |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 132 | system_type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && |
| 133 | system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) |
| 134 | return false; |
[email protected] | ea505a9d | 2011-07-07 18:34:40 | [diff] [blame] | 135 | r->system_type = static_cast<PP_FileSystemType>(system_type); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 136 | return true; |
| 137 | } |
| 138 | |
| 139 | // static |
[email protected] | ea505a9d | 2011-07-07 18:34:40 | [diff] [blame] | 140 | void ParamTraits<PP_FileInfo>::Log(const param_type& p, std::string* l) { |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 141 | } |
| 142 | |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 143 | // PP_NetAddress_Private ------------------------------------------------------- |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 144 | |
| 145 | // static |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 146 | void ParamTraits<PP_NetAddress_Private>::Write(Message* m, |
| 147 | const param_type& p) { |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 148 | WriteParam(m, p.size); |
| 149 | m->WriteBytes(p.data, static_cast<int>(p.size)); |
| 150 | } |
| 151 | |
| 152 | // static |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 153 | bool ParamTraits<PP_NetAddress_Private>::Read(const Message* m, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 154 | PickleIterator* iter, |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 155 | param_type* p) { |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 156 | uint16 size; |
| 157 | if (!ReadParam(m, iter, &size)) |
| 158 | return false; |
| 159 | if (size > sizeof(p->data)) |
| 160 | return false; |
| 161 | p->size = size; |
| 162 | |
| 163 | const char* data; |
| 164 | if (!m->ReadBytes(iter, &data, size)) |
| 165 | return false; |
| 166 | memcpy(p->data, data, size); |
| 167 | return true; |
| 168 | } |
| 169 | |
| 170 | // static |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 171 | void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, |
| 172 | std::string* l) { |
| 173 | l->append("<PP_NetAddress_Private ("); |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 174 | LogParam(p.size, l); |
| 175 | l->append(" bytes)>"); |
| 176 | } |
| 177 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 178 | // PP_ObjectProperty ----------------------------------------------------------- |
| 179 | |
| 180 | // static |
| 181 | void ParamTraits<PP_ObjectProperty>::Write(Message* m, const param_type& p) { |
| 182 | // FIXME(brettw); |
| 183 | } |
| 184 | |
| 185 | // static |
| 186 | bool ParamTraits<PP_ObjectProperty>::Read(const Message* m, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 187 | PickleIterator* iter, |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 188 | param_type* r) { |
| 189 | // FIXME(brettw); |
| 190 | return true; |
| 191 | } |
| 192 | |
| 193 | // static |
| 194 | void ParamTraits<PP_ObjectProperty>::Log(const param_type& p, std::string* l) { |
| 195 | } |
| 196 | |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 197 | // PPB_FileRef_CreateInfo ------------------------------------------------------ |
| 198 | |
| 199 | // static |
| 200 | void ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Write(Message* m, |
| 201 | const param_type& p) { |
| 202 | ParamTraits<ppapi::HostResource>::Write(m, p.resource); |
| 203 | ParamTraits<int>::Write(m, p.file_system_type); |
| 204 | ParamTraits<std::string>::Write(m, p.path); |
| 205 | ParamTraits<std::string>::Write(m, p.name); |
| 206 | } |
| 207 | |
| 208 | // static |
| 209 | bool ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Read(const Message* m, |
| 210 | PickleIterator* iter, |
| 211 | param_type* r) { |
| 212 | return |
| 213 | ParamTraits<ppapi::HostResource>::Read(m, iter, &r->resource) && |
| 214 | ParamTraits<int>::Read(m, iter, &r->file_system_type) && |
| 215 | ParamTraits<std::string>::Read(m, iter, &r->path) && |
| 216 | ParamTraits<std::string>::Read(m, iter, &r->name); |
| 217 | } |
| 218 | |
| 219 | // static |
| 220 | void ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Log(const param_type& p, |
| 221 | std::string* l) { |
| 222 | } |
| 223 | |
| 224 | // HostResource ---------------------------------------------------------------- |
| 225 | |
| 226 | // static |
| 227 | void ParamTraits<ppapi::HostResource>::Write(Message* m, |
| 228 | const param_type& p) { |
| 229 | ParamTraits<PP_Instance>::Write(m, p.instance()); |
| 230 | ParamTraits<PP_Resource>::Write(m, p.host_resource()); |
| 231 | } |
| 232 | |
| 233 | // static |
| 234 | bool ParamTraits<ppapi::HostResource>::Read(const Message* m, |
| 235 | PickleIterator* iter, |
| 236 | param_type* r) { |
| 237 | PP_Instance instance; |
| 238 | PP_Resource resource; |
| 239 | if (!ParamTraits<PP_Instance>::Read(m, iter, &instance) || |
| 240 | !ParamTraits<PP_Resource>::Read(m, iter, &resource)) |
| 241 | return false; |
| 242 | r->SetHostResource(instance, resource); |
| 243 | return true; |
| 244 | } |
| 245 | |
| 246 | // static |
| 247 | void ParamTraits<ppapi::HostResource>::Log(const param_type& p, |
| 248 | std::string* l) { |
| 249 | } |
| 250 | |
| 251 | // SerializedVar --------------------------------------------------------------- |
| 252 | |
| 253 | // static |
| 254 | void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m, |
| 255 | const param_type& p) { |
| 256 | p.WriteToMessage(m); |
| 257 | } |
| 258 | |
| 259 | // static |
| 260 | bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const Message* m, |
| 261 | PickleIterator* iter, |
| 262 | param_type* r) { |
| 263 | return r->ReadFromMessage(m, iter); |
| 264 | } |
| 265 | |
| 266 | // static |
| 267 | void ParamTraits<ppapi::proxy::SerializedVar>::Log(const param_type& p, |
| 268 | std::string* l) { |
| 269 | } |
| 270 | |
| 271 | // std::vector<SerializedVar> -------------------------------------------------- |
| 272 | |
| 273 | void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Write( |
| 274 | Message* m, |
| 275 | const param_type& p) { |
| 276 | WriteVectorWithoutCopy(m, p); |
| 277 | } |
| 278 | |
| 279 | // static |
| 280 | bool ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Read( |
| 281 | const Message* m, |
| 282 | PickleIterator* iter, |
| 283 | param_type* r) { |
| 284 | return ReadVectorWithoutCopy(m, iter, r); |
| 285 | } |
| 286 | |
| 287 | // static |
| 288 | void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( |
| 289 | const param_type& p, |
| 290 | std::string* l) { |
| 291 | } |
| 292 | |
| 293 | // std::vector<PPB_FileRef_CreateInfo> ----------------------------------------- |
| 294 | |
| 295 | void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Write( |
| 296 | Message* m, |
| 297 | const param_type& p) { |
| 298 | WriteVectorWithoutCopy(m, p); |
| 299 | } |
| 300 | |
| 301 | // static |
| 302 | bool ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Read( |
| 303 | const Message* m, |
| 304 | PickleIterator* iter, |
| 305 | param_type* r) { |
| 306 | return ReadVectorWithoutCopy(m, iter, r); |
| 307 | } |
| 308 | |
| 309 | // static |
| 310 | void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Log( |
| 311 | const param_type& p, |
| 312 | std::string* l) { |
| 313 | } |
| 314 | |
[email protected] | 195d4cde | 2012-10-02 18:12:41 | [diff] [blame] | 315 | // ppapi::PpapiPermissions ----------------------------------------------------- |
| 316 | |
| 317 | void ParamTraits<ppapi::PpapiPermissions>::Write(Message* m, |
| 318 | const param_type& p) { |
| 319 | ParamTraits<uint32_t>::Write(m, p.GetBits()); |
| 320 | } |
| 321 | |
| 322 | // static |
| 323 | bool ParamTraits<ppapi::PpapiPermissions>::Read(const Message* m, |
| 324 | PickleIterator* iter, |
| 325 | param_type* r) { |
| 326 | uint32_t bits; |
| 327 | if (!ParamTraits<uint32_t>::Read(m, iter, &bits)) |
| 328 | return false; |
| 329 | *r = ppapi::PpapiPermissions(bits); |
| 330 | return true; |
| 331 | } |
| 332 | |
| 333 | // static |
| 334 | void ParamTraits<ppapi::PpapiPermissions>::Log(const param_type& p, |
| 335 | std::string* l) { |
| 336 | } |
| 337 | |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 338 | // SerializedHandle ------------------------------------------------------------ |
| 339 | |
| 340 | // static |
| 341 | void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m, |
| 342 | const param_type& p) { |
| 343 | ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); |
| 344 | switch (p.type()) { |
| 345 | case ppapi::proxy::SerializedHandle::SHARED_MEMORY: |
| 346 | ParamTraits<base::SharedMemoryHandle>::Write(m, p.shmem()); |
| 347 | break; |
| 348 | case ppapi::proxy::SerializedHandle::SOCKET: |
[email protected] | 8510d28 | 2012-08-30 19:47:38 | [diff] [blame] | 349 | case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 350 | ParamTraits<IPC::PlatformFileForTransit>::Write(m, p.descriptor()); |
| 351 | break; |
| 352 | case ppapi::proxy::SerializedHandle::INVALID: |
| 353 | break; |
| 354 | // No default so the compiler will warn on new types. |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | // static |
| 359 | bool ParamTraits<ppapi::proxy::SerializedHandle>::Read(const Message* m, |
| 360 | PickleIterator* iter, |
| 361 | param_type* r) { |
| 362 | ppapi::proxy::SerializedHandle::Header header; |
| 363 | if (!ppapi::proxy::SerializedHandle::ReadHeader(iter, &header)) |
| 364 | return false; |
| 365 | switch (header.type) { |
| 366 | case ppapi::proxy::SerializedHandle::SHARED_MEMORY: { |
| 367 | base::SharedMemoryHandle handle; |
| 368 | if (ParamTraits<base::SharedMemoryHandle>::Read(m, iter, &handle)) { |
| 369 | r->set_shmem(handle, header.size); |
| 370 | return true; |
| 371 | } |
| 372 | break; |
| 373 | } |
| 374 | case ppapi::proxy::SerializedHandle::SOCKET: { |
| 375 | IPC::PlatformFileForTransit socket; |
| 376 | if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &socket)) { |
| 377 | r->set_socket(socket); |
| 378 | return true; |
| 379 | } |
| 380 | break; |
| 381 | } |
[email protected] | 8510d28 | 2012-08-30 19:47:38 | [diff] [blame] | 382 | case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: { |
| 383 | IPC::PlatformFileForTransit desc; |
| 384 | if (ParamTraits<IPC::PlatformFileForTransit>::Read(m, iter, &desc)) { |
| 385 | r->set_channel_handle(desc); |
| 386 | return true; |
| 387 | } |
| 388 | break; |
| 389 | } |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 390 | case ppapi::proxy::SerializedHandle::INVALID: |
| 391 | return true; |
| 392 | // No default so the compiler will warn us if a new type is added. |
| 393 | } |
| 394 | return false; |
| 395 | } |
| 396 | |
| 397 | // static |
| 398 | void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, |
| 399 | std::string* l) { |
| 400 | } |
| 401 | |
[email protected] | 5a5d9b532 | 2012-10-02 22:20:23 | [diff] [blame] | 402 | // PPBURLLoader_UpdateProgress_Params ------------------------------------------ |
| 403 | |
| 404 | // static |
| 405 | void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Write( |
| 406 | Message* m, |
| 407 | const param_type& p) { |
| 408 | ParamTraits<PP_Instance>::Write(m, p.instance); |
| 409 | ParamTraits<ppapi::HostResource>::Write(m, p.resource); |
| 410 | ParamTraits<int64_t>::Write(m, p.bytes_sent); |
| 411 | ParamTraits<int64_t>::Write(m, p.total_bytes_to_be_sent); |
| 412 | ParamTraits<int64_t>::Write(m, p.bytes_received); |
| 413 | ParamTraits<int64_t>::Write(m, p.total_bytes_to_be_received); |
| 414 | } |
| 415 | |
| 416 | // static |
| 417 | bool ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Read( |
| 418 | const Message* m, |
| 419 | PickleIterator* iter, |
| 420 | param_type* r) { |
| 421 | return |
| 422 | ParamTraits<PP_Instance>::Read(m, iter, &r->instance) && |
| 423 | ParamTraits<ppapi::HostResource>::Read(m, iter, &r->resource) && |
| 424 | ParamTraits<int64_t>::Read(m, iter, &r->bytes_sent) && |
| 425 | ParamTraits<int64_t>::Read(m, iter, &r->total_bytes_to_be_sent) && |
| 426 | ParamTraits<int64_t>::Read(m, iter, &r->bytes_received) && |
| 427 | ParamTraits<int64_t>::Read(m, iter, &r->total_bytes_to_be_received); |
| 428 | } |
| 429 | |
| 430 | // static |
| 431 | void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Log( |
| 432 | const param_type& p, |
| 433 | std::string* l) { |
| 434 | } |
| 435 | |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 436 | #if !defined(OS_NACL) && !defined(NACL_WIN64) |
[email protected] | 6761d63 | 2012-04-18 17:54:49 | [diff] [blame] | 437 | // PPBFlash_DrawGlyphs_Params -------------------------------------------------- |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 438 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 439 | void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 440 | Message* m, |
| 441 | const param_type& p) { |
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 442 | ParamTraits<PP_Instance>::Write(m, p.instance); |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 443 | ParamTraits<ppapi::HostResource>::Write(m, p.image_data); |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 444 | ParamTraits<ppapi::proxy::SerializedFontDescription>::Write(m, p.font_desc); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 445 | ParamTraits<uint32_t>::Write(m, p.color); |
| 446 | ParamTraits<PP_Point>::Write(m, p.position); |
| 447 | ParamTraits<PP_Rect>::Write(m, p.clip); |
| 448 | ParamTraits<float>::Write(m, p.transformation[0][0]); |
| 449 | ParamTraits<float>::Write(m, p.transformation[0][1]); |
| 450 | ParamTraits<float>::Write(m, p.transformation[0][2]); |
| 451 | ParamTraits<float>::Write(m, p.transformation[1][0]); |
| 452 | ParamTraits<float>::Write(m, p.transformation[1][1]); |
| 453 | ParamTraits<float>::Write(m, p.transformation[1][2]); |
| 454 | ParamTraits<float>::Write(m, p.transformation[2][0]); |
| 455 | ParamTraits<float>::Write(m, p.transformation[2][1]); |
| 456 | ParamTraits<float>::Write(m, p.transformation[2][2]); |
[email protected] | 2e4361ae | 2011-12-15 00:03:35 | [diff] [blame] | 457 | ParamTraits<PP_Bool>::Write(m, p.allow_subpixel_aa); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 458 | ParamTraits<std::vector<uint16_t> >::Write(m, p.glyph_indices); |
| 459 | ParamTraits<std::vector<PP_Point> >::Write(m, p.glyph_advances); |
| 460 | } |
| 461 | |
| 462 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 463 | bool ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Read( |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 464 | const Message* m, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 465 | PickleIterator* iter, |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 466 | param_type* r) { |
| 467 | return |
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 468 | ParamTraits<PP_Instance>::Read(m, iter, &r->instance) && |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 469 | ParamTraits<ppapi::HostResource>::Read(m, iter, &r->image_data) && |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 470 | ParamTraits<ppapi::proxy::SerializedFontDescription>::Read(m, iter, |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 471 | &r->font_desc) && |
| 472 | ParamTraits<uint32_t>::Read(m, iter, &r->color) && |
| 473 | ParamTraits<PP_Point>::Read(m, iter, &r->position) && |
| 474 | ParamTraits<PP_Rect>::Read(m, iter, &r->clip) && |
| 475 | ParamTraits<float>::Read(m, iter, &r->transformation[0][0]) && |
| 476 | ParamTraits<float>::Read(m, iter, &r->transformation[0][1]) && |
| 477 | ParamTraits<float>::Read(m, iter, &r->transformation[0][2]) && |
| 478 | ParamTraits<float>::Read(m, iter, &r->transformation[1][0]) && |
| 479 | ParamTraits<float>::Read(m, iter, &r->transformation[1][1]) && |
| 480 | ParamTraits<float>::Read(m, iter, &r->transformation[1][2]) && |
| 481 | ParamTraits<float>::Read(m, iter, &r->transformation[2][0]) && |
| 482 | ParamTraits<float>::Read(m, iter, &r->transformation[2][1]) && |
| 483 | ParamTraits<float>::Read(m, iter, &r->transformation[2][2]) && |
[email protected] | 2e4361ae | 2011-12-15 00:03:35 | [diff] [blame] | 484 | ParamTraits<PP_Bool>::Read(m, iter, &r->allow_subpixel_aa) && |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 485 | ParamTraits<std::vector<uint16_t> >::Read(m, iter, &r->glyph_indices) && |
| 486 | ParamTraits<std::vector<PP_Point> >::Read(m, iter, &r->glyph_advances) && |
| 487 | r->glyph_indices.size() == r->glyph_advances.size(); |
| 488 | } |
| 489 | |
| 490 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 491 | void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Log( |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 492 | const param_type& p, |
| 493 | std::string* l) { |
| 494 | } |
| 495 | |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 496 | // SerializedDirEntry ---------------------------------------------------------- |
| 497 | |
| 498 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 499 | void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(Message* m, |
| 500 | const param_type& p) { |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 501 | ParamTraits<std::string>::Write(m, p.name); |
| 502 | ParamTraits<bool>::Write(m, p.is_dir); |
| 503 | } |
| 504 | |
| 505 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 506 | bool ParamTraits<ppapi::proxy::SerializedDirEntry>::Read(const Message* m, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 507 | PickleIterator* iter, |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 508 | param_type* r) { |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 509 | return ParamTraits<std::string>::Read(m, iter, &r->name) && |
| 510 | ParamTraits<bool>::Read(m, iter, &r->is_dir); |
| 511 | } |
| 512 | |
| 513 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 514 | void ParamTraits<ppapi::proxy::SerializedDirEntry>::Log(const param_type& p, |
| 515 | std::string* l) { |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 516 | } |
| 517 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 518 | // ppapi::proxy::SerializedFontDescription ------------------------------------- |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 519 | |
| 520 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 521 | void ParamTraits<ppapi::proxy::SerializedFontDescription>::Write( |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 522 | Message* m, |
| 523 | const param_type& p) { |
[email protected] | cb65f13 | 2012-10-09 17:06:09 | [diff] [blame^] | 524 | ParamTraits<std::string>::Write(m, p.face); |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 525 | ParamTraits<int32_t>::Write(m, p.family); |
| 526 | ParamTraits<uint32_t>::Write(m, p.size); |
| 527 | ParamTraits<int32_t>::Write(m, p.weight); |
| 528 | ParamTraits<PP_Bool>::Write(m, p.italic); |
| 529 | ParamTraits<PP_Bool>::Write(m, p.small_caps); |
| 530 | ParamTraits<int32_t>::Write(m, p.letter_spacing); |
| 531 | ParamTraits<int32_t>::Write(m, p.word_spacing); |
| 532 | } |
| 533 | |
| 534 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 535 | bool ParamTraits<ppapi::proxy::SerializedFontDescription>::Read( |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 536 | const Message* m, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 537 | PickleIterator* iter, |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 538 | param_type* r) { |
| 539 | return |
[email protected] | cb65f13 | 2012-10-09 17:06:09 | [diff] [blame^] | 540 | ParamTraits<std::string>::Read(m, iter, &r->face) && |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 541 | ParamTraits<int32_t>::Read(m, iter, &r->family) && |
| 542 | ParamTraits<uint32_t>::Read(m, iter, &r->size) && |
| 543 | ParamTraits<int32_t>::Read(m, iter, &r->weight) && |
| 544 | ParamTraits<PP_Bool>::Read(m, iter, &r->italic) && |
| 545 | ParamTraits<PP_Bool>::Read(m, iter, &r->small_caps) && |
| 546 | ParamTraits<int32_t>::Read(m, iter, &r->letter_spacing) && |
| 547 | ParamTraits<int32_t>::Read(m, iter, &r->word_spacing); |
| 548 | } |
| 549 | |
| 550 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 551 | void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log( |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 552 | const param_type& p, |
| 553 | std::string* l) { |
| 554 | } |
| 555 | |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 556 | // SerializedFlashMenu --------------------------------------------------------- |
| 557 | |
| 558 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 559 | void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( |
| 560 | Message* m, |
| 561 | const param_type& p) { |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 562 | p.WriteToMessage(m); |
| 563 | } |
| 564 | |
| 565 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 566 | bool ParamTraits<ppapi::proxy::SerializedFlashMenu>::Read(const Message* m, |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 567 | PickleIterator* iter, |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 568 | param_type* r) { |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 569 | return r->ReadFromMessage(m, iter); |
| 570 | } |
| 571 | |
| 572 | // static |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 573 | void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, |
| 574 | std::string* l) { |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 575 | } |
[email protected] | 667591d | 2012-09-04 21:30:12 | [diff] [blame] | 576 | #endif // !defined(OS_NACL) && !defined(NACL_WIN64) |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 577 | |
[email protected] | de289526 | 2012-04-04 17:15:48 | [diff] [blame] | 578 | // PPB_X509Certificate_Fields -------------------------------------------------- |
| 579 | |
| 580 | // static |
| 581 | void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Write( |
| 582 | Message* m, |
| 583 | const param_type& p) { |
| 584 | ParamTraits<ListValue>::Write(m, p.values_); |
| 585 | } |
| 586 | |
| 587 | // static |
| 588 | bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read(const Message* m, |
| 589 | PickleIterator* iter, |
| 590 | param_type* r) { |
| 591 | return ParamTraits<ListValue>::Read(m, iter, &(r->values_)); |
| 592 | } |
| 593 | |
| 594 | // static |
| 595 | void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, |
| 596 | std::string* l) { |
| 597 | } |
| 598 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 599 | } // namespace IPC |