OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/proxy/ppapi_param_traits.h" | 5 #include "ppapi/proxy/ppapi_param_traits.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> // For memcpy | 9 #include <string.h> // For memcpy |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 // | 34 // |
35 // Since we allocate the inner class when you call the default constructor and | 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 | 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 | 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 | 38 // up overwriting the same item over and over, since all the SerializedVars |
39 // will refer to the same thing. | 39 // will refer to the same thing. |
40 // | 40 // |
41 // The solution is to make a new object for each deserialized item, and then | 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. | 42 // add it to the vector one at a time. |
43 template <typename T> | 43 template <typename T> |
44 bool ReadVectorWithoutCopy(const Message* m, | 44 bool ReadVectorWithoutCopy(const base::Pickle* m, |
45 base::PickleIterator* iter, | 45 base::PickleIterator* iter, |
46 std::vector<T>* output) { | 46 std::vector<T>* output) { |
47 // This part is just a copy of the the default ParamTraits vector Read(). | 47 // This part is just a copy of the the default ParamTraits vector Read(). |
48 int size; | 48 int size; |
49 // ReadLength() checks for < 0 itself. | 49 // ReadLength() checks for < 0 itself. |
50 if (!iter->ReadLength(&size)) | 50 if (!iter->ReadLength(&size)) |
51 return false; | 51 return false; |
52 // Resizing beforehand is not safe, see BUG 1006367 for details. | 52 // Resizing beforehand is not safe, see BUG 1006367 for details. |
53 if (INT_MAX / sizeof(T) <= static_cast<size_t>(size)) | 53 if (INT_MAX / sizeof(T) <= static_cast<size_t>(size)) |
54 return false; | 54 return false; |
55 | 55 |
56 output->reserve(size); | 56 output->reserve(size); |
57 for (int i = 0; i < size; i++) { | 57 for (int i = 0; i < size; i++) { |
58 T cur; | 58 T cur; |
59 if (!ReadParam(m, iter, &cur)) | 59 if (!ReadParam(m, iter, &cur)) |
60 return false; | 60 return false; |
61 output->push_back(cur); | 61 output->push_back(cur); |
62 } | 62 } |
63 return true; | 63 return true; |
64 } | 64 } |
65 | 65 |
66 // This serializes the vector of items to the IPC message in exactly the same | 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 | 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 | 68 // saves us from having to copy this code into all ParamTraits that use the |
69 // ReadVectorWithoutCopy function for deserializing. | 69 // ReadVectorWithoutCopy function for deserializing. |
70 template<typename T> | 70 template <typename T> |
71 void WriteVectorWithoutCopy(Message* m, const std::vector<T>& p) { | 71 void WriteVectorWithoutCopy(base::Pickle* m, const std::vector<T>& p) { |
72 WriteParam(m, static_cast<int>(p.size())); | 72 WriteParam(m, static_cast<int>(p.size())); |
73 for (size_t i = 0; i < p.size(); i++) | 73 for (size_t i = 0; i < p.size(); i++) |
74 WriteParam(m, p[i]); | 74 WriteParam(m, p[i]); |
75 } | 75 } |
76 | 76 |
77 } // namespace | 77 } // namespace |
78 | 78 |
79 // PP_Bool --------------------------------------------------------------------- | 79 // PP_Bool --------------------------------------------------------------------- |
80 | 80 |
81 // static | 81 // static |
82 void ParamTraits<PP_Bool>::Write(Message* m, const param_type& p) { | 82 void ParamTraits<PP_Bool>::Write(base::Pickle* m, const param_type& p) { |
83 WriteParam(m, PP_ToBool(p)); | 83 WriteParam(m, PP_ToBool(p)); |
84 } | 84 } |
85 | 85 |
86 // static | 86 // static |
87 bool ParamTraits<PP_Bool>::Read(const Message* m, | 87 bool ParamTraits<PP_Bool>::Read(const base::Pickle* m, |
88 base::PickleIterator* iter, | 88 base::PickleIterator* iter, |
89 param_type* r) { | 89 param_type* r) { |
90 // We specifically want to be strict here about what types of input we accept, | 90 // We specifically want to be strict here about what types of input we accept, |
91 // which ParamTraits<bool> does for us. We don't want to deserialize "2" into | 91 // which ParamTraits<bool> does for us. We don't want to deserialize "2" into |
92 // a PP_Bool, for example. | 92 // a PP_Bool, for example. |
93 bool result = false; | 93 bool result = false; |
94 if (!ReadParam(m, iter, &result)) | 94 if (!ReadParam(m, iter, &result)) |
95 return false; | 95 return false; |
96 *r = PP_FromBool(result); | 96 *r = PP_FromBool(result); |
97 return true; | 97 return true; |
98 } | 98 } |
99 | 99 |
100 // static | 100 // static |
101 void ParamTraits<PP_Bool>::Log(const param_type& p, std::string* l) { | 101 void ParamTraits<PP_Bool>::Log(const param_type& p, std::string* l) { |
102 } | 102 } |
103 | 103 |
104 // PP_KeyInformation ------------------------------------------------------- | 104 // PP_KeyInformation ------------------------------------------------------- |
105 | 105 |
106 // static | 106 // static |
107 void ParamTraits<PP_KeyInformation>::Write(Message* m, const param_type& p) { | 107 void ParamTraits<PP_KeyInformation>::Write(base::Pickle* m, |
| 108 const param_type& p) { |
108 WriteParam(m, p.key_id_size); | 109 WriteParam(m, p.key_id_size); |
109 m->WriteBytes(p.key_id, static_cast<int>(p.key_id_size)); | 110 m->WriteBytes(p.key_id, static_cast<int>(p.key_id_size)); |
110 WriteParam(m, p.key_status); | 111 WriteParam(m, p.key_status); |
111 WriteParam(m, p.system_code); | 112 WriteParam(m, p.system_code); |
112 } | 113 } |
113 | 114 |
114 // static | 115 // static |
115 bool ParamTraits<PP_KeyInformation>::Read(const Message* m, | 116 bool ParamTraits<PP_KeyInformation>::Read(const base::Pickle* m, |
116 base::PickleIterator* iter, | 117 base::PickleIterator* iter, |
117 param_type* p) { | 118 param_type* p) { |
118 uint32_t size; | 119 uint32_t size; |
119 if (!ReadParam(m, iter, &size)) | 120 if (!ReadParam(m, iter, &size)) |
120 return false; | 121 return false; |
121 if (size > sizeof(p->key_id)) | 122 if (size > sizeof(p->key_id)) |
122 return false; | 123 return false; |
123 p->key_id_size = size; | 124 p->key_id_size = size; |
124 | 125 |
125 const char* data; | 126 const char* data; |
(...skipping 17 matching lines...) Expand all Loading... |
143 // static | 144 // static |
144 void ParamTraits<PP_KeyInformation>::Log(const param_type& p, std::string* l) { | 145 void ParamTraits<PP_KeyInformation>::Log(const param_type& p, std::string* l) { |
145 l->append("<PP_KeyInformation ("); | 146 l->append("<PP_KeyInformation ("); |
146 LogParam(p.key_id_size, l); | 147 LogParam(p.key_id_size, l); |
147 l->append(" bytes)>"); | 148 l->append(" bytes)>"); |
148 } | 149 } |
149 | 150 |
150 // PP_NetAddress_Private ------------------------------------------------------- | 151 // PP_NetAddress_Private ------------------------------------------------------- |
151 | 152 |
152 // static | 153 // static |
153 void ParamTraits<PP_NetAddress_Private>::Write(Message* m, | 154 void ParamTraits<PP_NetAddress_Private>::Write(base::Pickle* m, |
154 const param_type& p) { | 155 const param_type& p) { |
155 WriteParam(m, p.size); | 156 WriteParam(m, p.size); |
156 m->WriteBytes(p.data, static_cast<int>(p.size)); | 157 m->WriteBytes(p.data, static_cast<int>(p.size)); |
157 } | 158 } |
158 | 159 |
159 // static | 160 // static |
160 bool ParamTraits<PP_NetAddress_Private>::Read(const Message* m, | 161 bool ParamTraits<PP_NetAddress_Private>::Read(const base::Pickle* m, |
161 base::PickleIterator* iter, | 162 base::PickleIterator* iter, |
162 param_type* p) { | 163 param_type* p) { |
163 uint16_t size; | 164 uint16_t size; |
164 if (!ReadParam(m, iter, &size)) | 165 if (!ReadParam(m, iter, &size)) |
165 return false; | 166 return false; |
166 if (size > sizeof(p->data)) | 167 if (size > sizeof(p->data)) |
167 return false; | 168 return false; |
168 p->size = size; | 169 p->size = size; |
169 | 170 |
170 const char* data; | 171 const char* data; |
171 if (!iter->ReadBytes(&data, size)) | 172 if (!iter->ReadBytes(&data, size)) |
172 return false; | 173 return false; |
173 memcpy(p->data, data, size); | 174 memcpy(p->data, data, size); |
174 return true; | 175 return true; |
175 } | 176 } |
176 | 177 |
177 // static | 178 // static |
178 void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, | 179 void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, |
179 std::string* l) { | 180 std::string* l) { |
180 l->append("<PP_NetAddress_Private ("); | 181 l->append("<PP_NetAddress_Private ("); |
181 LogParam(p.size, l); | 182 LogParam(p.size, l); |
182 l->append(" bytes)>"); | 183 l->append(" bytes)>"); |
183 } | 184 } |
184 | 185 |
185 // HostResource ---------------------------------------------------------------- | 186 // HostResource ---------------------------------------------------------------- |
186 | 187 |
187 // static | 188 // static |
188 void ParamTraits<ppapi::HostResource>::Write(Message* m, | 189 void ParamTraits<ppapi::HostResource>::Write(base::Pickle* m, |
189 const param_type& p) { | 190 const param_type& p) { |
190 WriteParam(m, p.instance()); | 191 WriteParam(m, p.instance()); |
191 WriteParam(m, p.host_resource()); | 192 WriteParam(m, p.host_resource()); |
192 } | 193 } |
193 | 194 |
194 // static | 195 // static |
195 bool ParamTraits<ppapi::HostResource>::Read(const Message* m, | 196 bool ParamTraits<ppapi::HostResource>::Read(const base::Pickle* m, |
196 base::PickleIterator* iter, | 197 base::PickleIterator* iter, |
197 param_type* r) { | 198 param_type* r) { |
198 PP_Instance instance; | 199 PP_Instance instance; |
199 PP_Resource resource; | 200 PP_Resource resource; |
200 if (!ReadParam(m, iter, &instance) || !ReadParam(m, iter, &resource)) | 201 if (!ReadParam(m, iter, &instance) || !ReadParam(m, iter, &resource)) |
201 return false; | 202 return false; |
202 r->SetHostResource(instance, resource); | 203 r->SetHostResource(instance, resource); |
203 return true; | 204 return true; |
204 } | 205 } |
205 | 206 |
206 // static | 207 // static |
207 void ParamTraits<ppapi::HostResource>::Log(const param_type& p, | 208 void ParamTraits<ppapi::HostResource>::Log(const param_type& p, |
208 std::string* l) { | 209 std::string* l) { |
209 } | 210 } |
210 | 211 |
211 // SerializedVar --------------------------------------------------------------- | 212 // SerializedVar --------------------------------------------------------------- |
212 | 213 |
213 // static | 214 // static |
214 void ParamTraits<ppapi::proxy::SerializedVar>::Write(Message* m, | 215 void ParamTraits<ppapi::proxy::SerializedVar>::Write(base::Pickle* m, |
215 const param_type& p) { | 216 const param_type& p) { |
216 p.WriteToMessage(m); | 217 p.WriteToMessage(m); |
217 } | 218 } |
218 | 219 |
219 // static | 220 // static |
220 bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const Message* m, | 221 bool ParamTraits<ppapi::proxy::SerializedVar>::Read(const base::Pickle* m, |
221 base::PickleIterator* iter, | 222 base::PickleIterator* iter, |
222 param_type* r) { | 223 param_type* r) { |
223 return r->ReadFromMessage(m, iter); | 224 return r->ReadFromMessage(m, iter); |
224 } | 225 } |
225 | 226 |
226 // static | 227 // static |
227 void ParamTraits<ppapi::proxy::SerializedVar>::Log(const param_type& p, | 228 void ParamTraits<ppapi::proxy::SerializedVar>::Log(const param_type& p, |
228 std::string* l) { | 229 std::string* l) { |
229 } | 230 } |
230 | 231 |
231 // std::vector<SerializedVar> -------------------------------------------------- | 232 // std::vector<SerializedVar> -------------------------------------------------- |
232 | 233 |
233 void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Write( | 234 void ParamTraits<std::vector<ppapi::proxy::SerializedVar>>::Write( |
234 Message* m, | 235 base::Pickle* m, |
235 const param_type& p) { | 236 const param_type& p) { |
236 WriteVectorWithoutCopy(m, p); | 237 WriteVectorWithoutCopy(m, p); |
237 } | 238 } |
238 | 239 |
239 // static | 240 // static |
240 bool ParamTraits<std::vector<ppapi::proxy::SerializedVar>>::Read( | 241 bool ParamTraits<std::vector<ppapi::proxy::SerializedVar>>::Read( |
241 const Message* m, | 242 const base::Pickle* m, |
242 base::PickleIterator* iter, | 243 base::PickleIterator* iter, |
243 param_type* r) { | 244 param_type* r) { |
244 return ReadVectorWithoutCopy(m, iter, r); | 245 return ReadVectorWithoutCopy(m, iter, r); |
245 } | 246 } |
246 | 247 |
247 // static | 248 // static |
248 void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( | 249 void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( |
249 const param_type& p, | 250 const param_type& p, |
250 std::string* l) { | 251 std::string* l) { |
251 } | 252 } |
252 | 253 |
253 // ppapi::PpapiPermissions ----------------------------------------------------- | 254 // ppapi::PpapiPermissions ----------------------------------------------------- |
254 | 255 |
255 void ParamTraits<ppapi::PpapiPermissions>::Write(Message* m, | 256 void ParamTraits<ppapi::PpapiPermissions>::Write(base::Pickle* m, |
256 const param_type& p) { | 257 const param_type& p) { |
257 WriteParam(m, p.GetBits()); | 258 WriteParam(m, p.GetBits()); |
258 } | 259 } |
259 | 260 |
260 // static | 261 // static |
261 bool ParamTraits<ppapi::PpapiPermissions>::Read(const Message* m, | 262 bool ParamTraits<ppapi::PpapiPermissions>::Read(const base::Pickle* m, |
262 base::PickleIterator* iter, | 263 base::PickleIterator* iter, |
263 param_type* r) { | 264 param_type* r) { |
264 uint32_t bits; | 265 uint32_t bits; |
265 if (!ReadParam(m, iter, &bits)) | 266 if (!ReadParam(m, iter, &bits)) |
266 return false; | 267 return false; |
267 *r = ppapi::PpapiPermissions(bits); | 268 *r = ppapi::PpapiPermissions(bits); |
268 return true; | 269 return true; |
269 } | 270 } |
270 | 271 |
271 // static | 272 // static |
272 void ParamTraits<ppapi::PpapiPermissions>::Log(const param_type& p, | 273 void ParamTraits<ppapi::PpapiPermissions>::Log(const param_type& p, |
273 std::string* l) { | 274 std::string* l) { |
274 } | 275 } |
275 | 276 |
276 // SerializedHandle ------------------------------------------------------------ | 277 // SerializedHandle ------------------------------------------------------------ |
277 | 278 |
278 // static | 279 // static |
279 void ParamTraits<ppapi::proxy::SerializedHandle>::Write(Message* m, | 280 void ParamTraits<ppapi::proxy::SerializedHandle>::Write(base::Pickle* m, |
280 const param_type& p) { | 281 const param_type& p) { |
281 ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); | 282 ppapi::proxy::SerializedHandle::WriteHeader(p.header(), m); |
282 switch (p.type()) { | 283 switch (p.type()) { |
283 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: | 284 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: |
284 WriteParam(m, p.shmem()); | 285 WriteParam(m, p.shmem()); |
285 break; | 286 break; |
286 case ppapi::proxy::SerializedHandle::SOCKET: | 287 case ppapi::proxy::SerializedHandle::SOCKET: |
287 case ppapi::proxy::SerializedHandle::FILE: | 288 case ppapi::proxy::SerializedHandle::FILE: |
288 WriteParam(m, p.descriptor()); | 289 WriteParam(m, p.descriptor()); |
289 break; | 290 break; |
290 case ppapi::proxy::SerializedHandle::INVALID: | 291 case ppapi::proxy::SerializedHandle::INVALID: |
291 break; | 292 break; |
292 // No default so the compiler will warn on new types. | 293 // No default so the compiler will warn on new types. |
293 } | 294 } |
294 } | 295 } |
295 | 296 |
296 // static | 297 // static |
297 bool ParamTraits<ppapi::proxy::SerializedHandle>::Read( | 298 bool ParamTraits<ppapi::proxy::SerializedHandle>::Read( |
298 const Message* m, | 299 const base::Pickle* m, |
299 base::PickleIterator* iter, | 300 base::PickleIterator* iter, |
300 param_type* r) { | 301 param_type* r) { |
301 ppapi::proxy::SerializedHandle::Header header; | 302 ppapi::proxy::SerializedHandle::Header header; |
302 if (!ppapi::proxy::SerializedHandle::ReadHeader(iter, &header)) | 303 if (!ppapi::proxy::SerializedHandle::ReadHeader(iter, &header)) |
303 return false; | 304 return false; |
304 switch (header.type) { | 305 switch (header.type) { |
305 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: { | 306 case ppapi::proxy::SerializedHandle::SHARED_MEMORY: { |
306 base::SharedMemoryHandle handle; | 307 base::SharedMemoryHandle handle; |
307 if (ReadParam(m, iter, &handle)) { | 308 if (ReadParam(m, iter, &handle)) { |
308 r->set_shmem(handle, header.size); | 309 r->set_shmem(handle, header.size); |
(...skipping 26 matching lines...) Expand all Loading... |
335 | 336 |
336 // static | 337 // static |
337 void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, | 338 void ParamTraits<ppapi::proxy::SerializedHandle>::Log(const param_type& p, |
338 std::string* l) { | 339 std::string* l) { |
339 } | 340 } |
340 | 341 |
341 // PPBURLLoader_UpdateProgress_Params ------------------------------------------ | 342 // PPBURLLoader_UpdateProgress_Params ------------------------------------------ |
342 | 343 |
343 // static | 344 // static |
344 void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Write( | 345 void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Write( |
345 Message* m, | 346 base::Pickle* m, |
346 const param_type& p) { | 347 const param_type& p) { |
347 WriteParam(m, p.instance); | 348 WriteParam(m, p.instance); |
348 WriteParam(m, p.resource); | 349 WriteParam(m, p.resource); |
349 WriteParam(m, p.bytes_sent); | 350 WriteParam(m, p.bytes_sent); |
350 WriteParam(m, p.total_bytes_to_be_sent); | 351 WriteParam(m, p.total_bytes_to_be_sent); |
351 WriteParam(m, p.bytes_received); | 352 WriteParam(m, p.bytes_received); |
352 WriteParam(m, p.total_bytes_to_be_received); | 353 WriteParam(m, p.total_bytes_to_be_received); |
353 } | 354 } |
354 | 355 |
355 // static | 356 // static |
356 bool ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Read( | 357 bool ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Read( |
357 const Message* m, | 358 const base::Pickle* m, |
358 base::PickleIterator* iter, | 359 base::PickleIterator* iter, |
359 param_type* r) { | 360 param_type* r) { |
360 return ReadParam(m, iter, &r->instance) && ReadParam(m, iter, &r->resource) && | 361 return ReadParam(m, iter, &r->instance) && ReadParam(m, iter, &r->resource) && |
361 ReadParam(m, iter, &r->bytes_sent) && | 362 ReadParam(m, iter, &r->bytes_sent) && |
362 ReadParam(m, iter, &r->total_bytes_to_be_sent) && | 363 ReadParam(m, iter, &r->total_bytes_to_be_sent) && |
363 ReadParam(m, iter, &r->bytes_received) && | 364 ReadParam(m, iter, &r->bytes_received) && |
364 ReadParam(m, iter, &r->total_bytes_to_be_received); | 365 ReadParam(m, iter, &r->total_bytes_to_be_received); |
365 } | 366 } |
366 | 367 |
367 // static | 368 // static |
368 void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Log( | 369 void ParamTraits<ppapi::proxy::PPBURLLoader_UpdateProgress_Params>::Log( |
369 const param_type& p, | 370 const param_type& p, |
370 std::string* l) { | 371 std::string* l) { |
371 } | 372 } |
372 | 373 |
373 #if !defined(OS_NACL) && !defined(NACL_WIN64) | 374 #if !defined(OS_NACL) && !defined(NACL_WIN64) |
374 // PPBFlash_DrawGlyphs_Params -------------------------------------------------- | 375 // PPBFlash_DrawGlyphs_Params -------------------------------------------------- |
375 // static | 376 // static |
376 void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( | 377 void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( |
377 Message* m, | 378 base::Pickle* m, |
378 const param_type& p) { | 379 const param_type& p) { |
379 WriteParam(m, p.instance); | 380 WriteParam(m, p.instance); |
380 WriteParam(m, p.image_data); | 381 WriteParam(m, p.image_data); |
381 WriteParam(m, p.font_desc); | 382 WriteParam(m, p.font_desc); |
382 WriteParam(m, p.color); | 383 WriteParam(m, p.color); |
383 WriteParam(m, p.position); | 384 WriteParam(m, p.position); |
384 WriteParam(m, p.clip); | 385 WriteParam(m, p.clip); |
385 WriteParam(m, p.transformation[0][0]); | 386 WriteParam(m, p.transformation[0][0]); |
386 WriteParam(m, p.transformation[0][1]); | 387 WriteParam(m, p.transformation[0][1]); |
387 WriteParam(m, p.transformation[0][2]); | 388 WriteParam(m, p.transformation[0][2]); |
388 WriteParam(m, p.transformation[1][0]); | 389 WriteParam(m, p.transformation[1][0]); |
389 WriteParam(m, p.transformation[1][1]); | 390 WriteParam(m, p.transformation[1][1]); |
390 WriteParam(m, p.transformation[1][2]); | 391 WriteParam(m, p.transformation[1][2]); |
391 WriteParam(m, p.transformation[2][0]); | 392 WriteParam(m, p.transformation[2][0]); |
392 WriteParam(m, p.transformation[2][1]); | 393 WriteParam(m, p.transformation[2][1]); |
393 WriteParam(m, p.transformation[2][2]); | 394 WriteParam(m, p.transformation[2][2]); |
394 WriteParam(m, p.allow_subpixel_aa); | 395 WriteParam(m, p.allow_subpixel_aa); |
395 WriteParam(m, p.glyph_indices); | 396 WriteParam(m, p.glyph_indices); |
396 WriteParam(m, p.glyph_advances); | 397 WriteParam(m, p.glyph_advances); |
397 } | 398 } |
398 | 399 |
399 // static | 400 // static |
400 bool ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Read( | 401 bool ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Read( |
401 const Message* m, | 402 const base::Pickle* m, |
402 base::PickleIterator* iter, | 403 base::PickleIterator* iter, |
403 param_type* r) { | 404 param_type* r) { |
404 return ReadParam(m, iter, &r->instance) && | 405 return ReadParam(m, iter, &r->instance) && |
405 ReadParam(m, iter, &r->image_data) && | 406 ReadParam(m, iter, &r->image_data) && |
406 ReadParam(m, iter, &r->font_desc) && ReadParam(m, iter, &r->color) && | 407 ReadParam(m, iter, &r->font_desc) && ReadParam(m, iter, &r->color) && |
407 ReadParam(m, iter, &r->position) && ReadParam(m, iter, &r->clip) && | 408 ReadParam(m, iter, &r->position) && ReadParam(m, iter, &r->clip) && |
408 ReadParam(m, iter, &r->transformation[0][0]) && | 409 ReadParam(m, iter, &r->transformation[0][0]) && |
409 ReadParam(m, iter, &r->transformation[0][1]) && | 410 ReadParam(m, iter, &r->transformation[0][1]) && |
410 ReadParam(m, iter, &r->transformation[0][2]) && | 411 ReadParam(m, iter, &r->transformation[0][2]) && |
411 ReadParam(m, iter, &r->transformation[1][0]) && | 412 ReadParam(m, iter, &r->transformation[1][0]) && |
(...skipping 10 matching lines...) Expand all Loading... |
422 | 423 |
423 // static | 424 // static |
424 void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Log( | 425 void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Log( |
425 const param_type& p, | 426 const param_type& p, |
426 std::string* l) { | 427 std::string* l) { |
427 } | 428 } |
428 | 429 |
429 // SerializedDirEntry ---------------------------------------------------------- | 430 // SerializedDirEntry ---------------------------------------------------------- |
430 | 431 |
431 // static | 432 // static |
432 void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(Message* m, | 433 void ParamTraits<ppapi::proxy::SerializedDirEntry>::Write(base::Pickle* m, |
433 const param_type& p) { | 434 const param_type& p) { |
434 WriteParam(m, p.name); | 435 WriteParam(m, p.name); |
435 WriteParam(m, p.is_dir); | 436 WriteParam(m, p.is_dir); |
436 } | 437 } |
437 | 438 |
438 // static | 439 // static |
439 bool ParamTraits<ppapi::proxy::SerializedDirEntry>::Read( | 440 bool ParamTraits<ppapi::proxy::SerializedDirEntry>::Read( |
440 const Message* m, | 441 const base::Pickle* m, |
441 base::PickleIterator* iter, | 442 base::PickleIterator* iter, |
442 param_type* r) { | 443 param_type* r) { |
443 return ReadParam(m, iter, &r->name) && ReadParam(m, iter, &r->is_dir); | 444 return ReadParam(m, iter, &r->name) && ReadParam(m, iter, &r->is_dir); |
444 } | 445 } |
445 | 446 |
446 // static | 447 // static |
447 void ParamTraits<ppapi::proxy::SerializedDirEntry>::Log(const param_type& p, | 448 void ParamTraits<ppapi::proxy::SerializedDirEntry>::Log(const param_type& p, |
448 std::string* l) { | 449 std::string* l) { |
449 } | 450 } |
450 | 451 |
451 // ppapi::proxy::SerializedFontDescription ------------------------------------- | 452 // ppapi::proxy::SerializedFontDescription ------------------------------------- |
452 | 453 |
453 // static | 454 // static |
454 void ParamTraits<ppapi::proxy::SerializedFontDescription>::Write( | 455 void ParamTraits<ppapi::proxy::SerializedFontDescription>::Write( |
455 Message* m, | 456 base::Pickle* m, |
456 const param_type& p) { | 457 const param_type& p) { |
457 WriteParam(m, p.face); | 458 WriteParam(m, p.face); |
458 WriteParam(m, p.family); | 459 WriteParam(m, p.family); |
459 WriteParam(m, p.size); | 460 WriteParam(m, p.size); |
460 WriteParam(m, p.weight); | 461 WriteParam(m, p.weight); |
461 WriteParam(m, p.italic); | 462 WriteParam(m, p.italic); |
462 WriteParam(m, p.small_caps); | 463 WriteParam(m, p.small_caps); |
463 WriteParam(m, p.letter_spacing); | 464 WriteParam(m, p.letter_spacing); |
464 WriteParam(m, p.word_spacing); | 465 WriteParam(m, p.word_spacing); |
465 } | 466 } |
466 | 467 |
467 // static | 468 // static |
468 bool ParamTraits<ppapi::proxy::SerializedFontDescription>::Read( | 469 bool ParamTraits<ppapi::proxy::SerializedFontDescription>::Read( |
469 const Message* m, | 470 const base::Pickle* m, |
470 base::PickleIterator* iter, | 471 base::PickleIterator* iter, |
471 param_type* r) { | 472 param_type* r) { |
472 return ReadParam(m, iter, &r->face) && ReadParam(m, iter, &r->family) && | 473 return ReadParam(m, iter, &r->face) && ReadParam(m, iter, &r->family) && |
473 ReadParam(m, iter, &r->size) && ReadParam(m, iter, &r->weight) && | 474 ReadParam(m, iter, &r->size) && ReadParam(m, iter, &r->weight) && |
474 ReadParam(m, iter, &r->italic) && ReadParam(m, iter, &r->small_caps) && | 475 ReadParam(m, iter, &r->italic) && ReadParam(m, iter, &r->small_caps) && |
475 ReadParam(m, iter, &r->letter_spacing) && | 476 ReadParam(m, iter, &r->letter_spacing) && |
476 ReadParam(m, iter, &r->word_spacing); | 477 ReadParam(m, iter, &r->word_spacing); |
477 } | 478 } |
478 | 479 |
479 // static | 480 // static |
480 void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log( | 481 void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log( |
481 const param_type& p, | 482 const param_type& p, |
482 std::string* l) { | 483 std::string* l) { |
483 } | 484 } |
484 #endif // !defined(OS_NACL) && !defined(NACL_WIN64) | 485 #endif // !defined(OS_NACL) && !defined(NACL_WIN64) |
485 | 486 |
486 // ppapi::proxy::SerializedTrueTypeFontDesc ------------------------------------ | 487 // ppapi::proxy::SerializedTrueTypeFontDesc ------------------------------------ |
487 | 488 |
488 // static | 489 // static |
489 void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Write( | 490 void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Write( |
490 Message* m, | 491 base::Pickle* m, |
491 const param_type& p) { | 492 const param_type& p) { |
492 WriteParam(m, p.family); | 493 WriteParam(m, p.family); |
493 WriteParam(m, p.generic_family); | 494 WriteParam(m, p.generic_family); |
494 WriteParam(m, p.style); | 495 WriteParam(m, p.style); |
495 WriteParam(m, p.weight); | 496 WriteParam(m, p.weight); |
496 WriteParam(m, p.width); | 497 WriteParam(m, p.width); |
497 WriteParam(m, p.charset); | 498 WriteParam(m, p.charset); |
498 } | 499 } |
499 | 500 |
500 // static | 501 // static |
501 bool ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Read( | 502 bool ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Read( |
502 const Message* m, | 503 const base::Pickle* m, |
503 base::PickleIterator* iter, | 504 base::PickleIterator* iter, |
504 param_type* r) { | 505 param_type* r) { |
505 return ReadParam(m, iter, &r->family) && | 506 return ReadParam(m, iter, &r->family) && |
506 ReadParam(m, iter, &r->generic_family) && | 507 ReadParam(m, iter, &r->generic_family) && |
507 ReadParam(m, iter, &r->style) && ReadParam(m, iter, &r->weight) && | 508 ReadParam(m, iter, &r->style) && ReadParam(m, iter, &r->weight) && |
508 ReadParam(m, iter, &r->width) && ReadParam(m, iter, &r->charset); | 509 ReadParam(m, iter, &r->width) && ReadParam(m, iter, &r->charset); |
509 } | 510 } |
510 | 511 |
511 // static | 512 // static |
512 void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Log( | 513 void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Log( |
513 const param_type& p, | 514 const param_type& p, |
514 std::string* l) { | 515 std::string* l) { |
515 } | 516 } |
516 | 517 |
517 #if !defined(OS_NACL) && !defined(NACL_WIN64) | 518 #if !defined(OS_NACL) && !defined(NACL_WIN64) |
518 // ppapi::PepperFilePath ------------------------------------------------------- | 519 // ppapi::PepperFilePath ------------------------------------------------------- |
519 | 520 |
520 // static | 521 // static |
521 void ParamTraits<ppapi::PepperFilePath>::Write(Message* m, | 522 void ParamTraits<ppapi::PepperFilePath>::Write(base::Pickle* m, |
522 const param_type& p) { | 523 const param_type& p) { |
523 WriteParam(m, static_cast<unsigned>(p.domain())); | 524 WriteParam(m, static_cast<unsigned>(p.domain())); |
524 WriteParam(m, p.path()); | 525 WriteParam(m, p.path()); |
525 } | 526 } |
526 | 527 |
527 // static | 528 // static |
528 bool ParamTraits<ppapi::PepperFilePath>::Read(const Message* m, | 529 bool ParamTraits<ppapi::PepperFilePath>::Read(const base::Pickle* m, |
529 base::PickleIterator* iter, | 530 base::PickleIterator* iter, |
530 param_type* p) { | 531 param_type* p) { |
531 unsigned domain; | 532 unsigned domain; |
532 base::FilePath path; | 533 base::FilePath path; |
533 if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path)) | 534 if (!ReadParam(m, iter, &domain) || !ReadParam(m, iter, &path)) |
534 return false; | 535 return false; |
535 if (domain > ppapi::PepperFilePath::DOMAIN_MAX_VALID) | 536 if (domain > ppapi::PepperFilePath::DOMAIN_MAX_VALID) |
536 return false; | 537 return false; |
537 | 538 |
538 *p = ppapi::PepperFilePath( | 539 *p = ppapi::PepperFilePath( |
539 static_cast<ppapi::PepperFilePath::Domain>(domain), path); | 540 static_cast<ppapi::PepperFilePath::Domain>(domain), path); |
540 return true; | 541 return true; |
541 } | 542 } |
542 | 543 |
543 // static | 544 // static |
544 void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p, | 545 void ParamTraits<ppapi::PepperFilePath>::Log(const param_type& p, |
545 std::string* l) { | 546 std::string* l) { |
546 l->append("("); | 547 l->append("("); |
547 LogParam(static_cast<unsigned>(p.domain()), l); | 548 LogParam(static_cast<unsigned>(p.domain()), l); |
548 l->append(", "); | 549 l->append(", "); |
549 LogParam(p.path(), l); | 550 LogParam(p.path(), l); |
550 l->append(")"); | 551 l->append(")"); |
551 } | 552 } |
552 | 553 |
553 // SerializedFlashMenu --------------------------------------------------------- | 554 // SerializedFlashMenu --------------------------------------------------------- |
554 | 555 |
555 // static | 556 // static |
556 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( | 557 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Write( |
557 Message* m, | 558 base::Pickle* m, |
558 const param_type& p) { | 559 const param_type& p) { |
559 p.WriteToMessage(m); | 560 p.WriteToMessage(m); |
560 } | 561 } |
561 | 562 |
562 // static | 563 // static |
563 bool ParamTraits<ppapi::proxy::SerializedFlashMenu>::Read( | 564 bool ParamTraits<ppapi::proxy::SerializedFlashMenu>::Read( |
564 const Message* m, | 565 const base::Pickle* m, |
565 base::PickleIterator* iter, | 566 base::PickleIterator* iter, |
566 param_type* r) { | 567 param_type* r) { |
567 return r->ReadFromMessage(m, iter); | 568 return r->ReadFromMessage(m, iter); |
568 } | 569 } |
569 | 570 |
570 // static | 571 // static |
571 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, | 572 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, |
572 std::string* l) { | 573 std::string* l) { |
573 } | 574 } |
574 #endif // !defined(OS_NACL) && !defined(NACL_WIN64) | 575 #endif // !defined(OS_NACL) && !defined(NACL_WIN64) |
575 | 576 |
576 // PPB_X509Certificate_Fields -------------------------------------------------- | 577 // PPB_X509Certificate_Fields -------------------------------------------------- |
577 | 578 |
578 // static | 579 // static |
579 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Write( | 580 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Write( |
580 Message* m, | 581 base::Pickle* m, |
581 const param_type& p) { | 582 const param_type& p) { |
582 WriteParam(m, p.values_); | 583 WriteParam(m, p.values_); |
583 } | 584 } |
584 | 585 |
585 // static | 586 // static |
586 bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read( | 587 bool ParamTraits<ppapi::PPB_X509Certificate_Fields>::Read( |
587 const Message* m, | 588 const base::Pickle* m, |
588 base::PickleIterator* iter, | 589 base::PickleIterator* iter, |
589 param_type* r) { | 590 param_type* r) { |
590 return ReadParam(m, iter, &(r->values_)); | 591 return ReadParam(m, iter, &(r->values_)); |
591 } | 592 } |
592 | 593 |
593 // static | 594 // static |
594 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, | 595 void ParamTraits<ppapi::PPB_X509Certificate_Fields>::Log(const param_type& p, |
595 std::string* l) { | 596 std::string* l) { |
596 } | 597 } |
597 | 598 |
598 // ppapi::SocketOptionData ----------------------------------------------------- | 599 // ppapi::SocketOptionData ----------------------------------------------------- |
599 | 600 |
600 // static | 601 // static |
601 void ParamTraits<ppapi::SocketOptionData>::Write(Message* m, | 602 void ParamTraits<ppapi::SocketOptionData>::Write(base::Pickle* m, |
602 const param_type& p) { | 603 const param_type& p) { |
603 ppapi::SocketOptionData::Type type = p.GetType(); | 604 ppapi::SocketOptionData::Type type = p.GetType(); |
604 WriteParam(m, static_cast<int32_t>(type)); | 605 WriteParam(m, static_cast<int32_t>(type)); |
605 switch (type) { | 606 switch (type) { |
606 case ppapi::SocketOptionData::TYPE_INVALID: { | 607 case ppapi::SocketOptionData::TYPE_INVALID: { |
607 break; | 608 break; |
608 } | 609 } |
609 case ppapi::SocketOptionData::TYPE_BOOL: { | 610 case ppapi::SocketOptionData::TYPE_BOOL: { |
610 bool out_value = false; | 611 bool out_value = false; |
611 bool result = p.GetBool(&out_value); | 612 bool result = p.GetBool(&out_value); |
(...skipping 12 matching lines...) Expand all Loading... |
624 DCHECK(result); | 625 DCHECK(result); |
625 | 626 |
626 WriteParam(m, out_value); | 627 WriteParam(m, out_value); |
627 break; | 628 break; |
628 } | 629 } |
629 // No default so the compiler will warn on new types. | 630 // No default so the compiler will warn on new types. |
630 } | 631 } |
631 } | 632 } |
632 | 633 |
633 // static | 634 // static |
634 bool ParamTraits<ppapi::SocketOptionData>::Read(const Message* m, | 635 bool ParamTraits<ppapi::SocketOptionData>::Read(const base::Pickle* m, |
635 base::PickleIterator* iter, | 636 base::PickleIterator* iter, |
636 param_type* r) { | 637 param_type* r) { |
637 *r = ppapi::SocketOptionData(); | 638 *r = ppapi::SocketOptionData(); |
638 int32_t type = 0; | 639 int32_t type = 0; |
639 if (!ReadParam(m, iter, &type)) | 640 if (!ReadParam(m, iter, &type)) |
640 return false; | 641 return false; |
641 if (type != ppapi::SocketOptionData::TYPE_INVALID && | 642 if (type != ppapi::SocketOptionData::TYPE_INVALID && |
642 type != ppapi::SocketOptionData::TYPE_BOOL && | 643 type != ppapi::SocketOptionData::TYPE_BOOL && |
643 type != ppapi::SocketOptionData::TYPE_INT32) { | 644 type != ppapi::SocketOptionData::TYPE_INT32) { |
644 return false; | 645 return false; |
(...skipping 23 matching lines...) Expand all Loading... |
668 | 669 |
669 // static | 670 // static |
670 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, | 671 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, |
671 std::string* l) { | 672 std::string* l) { |
672 } | 673 } |
673 | 674 |
674 // ppapi::CompositorLayerData -------------------------------------------------- | 675 // ppapi::CompositorLayerData -------------------------------------------------- |
675 | 676 |
676 // static | 677 // static |
677 void ParamTraits<ppapi::CompositorLayerData::Transform>::Write( | 678 void ParamTraits<ppapi::CompositorLayerData::Transform>::Write( |
678 Message* m, | 679 base::Pickle* m, |
679 const param_type& p) { | 680 const param_type& p) { |
680 for (size_t i = 0; i < arraysize(p.matrix); i++) | 681 for (size_t i = 0; i < arraysize(p.matrix); i++) |
681 WriteParam(m, p.matrix[i]); | 682 WriteParam(m, p.matrix[i]); |
682 } | 683 } |
683 | 684 |
684 // static | 685 // static |
685 bool ParamTraits<ppapi::CompositorLayerData::Transform>::Read( | 686 bool ParamTraits<ppapi::CompositorLayerData::Transform>::Read( |
686 const Message* m, | 687 const base::Pickle* m, |
687 base::PickleIterator* iter, | 688 base::PickleIterator* iter, |
688 param_type* r) { | 689 param_type* r) { |
689 for (size_t i = 0; i < arraysize(r->matrix);i++) { | 690 for (size_t i = 0; i < arraysize(r->matrix);i++) { |
690 if (!ReadParam(m, iter, &r->matrix[i])) | 691 if (!ReadParam(m, iter, &r->matrix[i])) |
691 return false; | 692 return false; |
692 } | 693 } |
693 return true; | 694 return true; |
694 } | 695 } |
695 | 696 |
696 void ParamTraits<ppapi::CompositorLayerData::Transform>::Log( | 697 void ParamTraits<ppapi::CompositorLayerData::Transform>::Log( |
697 const param_type& p, | 698 const param_type& p, |
698 std::string* l) { | 699 std::string* l) { |
699 } | 700 } |
700 | 701 |
701 } // namespace IPC | 702 } // namespace IPC |
OLD | NEW |