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