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 <string.h> // For memcpy | 7 #include <string.h> // For memcpy |
8 | 8 |
9 #include "ppapi/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // | 36 // |
37 // The solution is to make a new object for each deserialized item, and then | 37 // The solution is to make a new object for each deserialized item, and then |
38 // add it to the vector one at a time. | 38 // add it to the vector one at a time. |
39 template<typename T> | 39 template<typename T> |
40 bool ReadVectorWithoutCopy(const Message* m, | 40 bool ReadVectorWithoutCopy(const Message* m, |
41 PickleIterator* iter, | 41 PickleIterator* iter, |
42 std::vector<T>* output) { | 42 std::vector<T>* output) { |
43 // This part is just a copy of the the default ParamTraits vector Read(). | 43 // This part is just a copy of the the default ParamTraits vector Read(). |
44 int size; | 44 int size; |
45 // ReadLength() checks for < 0 itself. | 45 // ReadLength() checks for < 0 itself. |
46 if (!m->ReadLength(iter, &size)) | 46 if (!iter->ReadLength(&size)) |
47 return false; | 47 return false; |
48 // Resizing beforehand is not safe, see BUG 1006367 for details. | 48 // Resizing beforehand is not safe, see BUG 1006367 for details. |
49 if (INT_MAX / sizeof(T) <= static_cast<size_t>(size)) | 49 if (INT_MAX / sizeof(T) <= static_cast<size_t>(size)) |
50 return false; | 50 return false; |
51 | 51 |
52 output->reserve(size); | 52 output->reserve(size); |
53 for (int i = 0; i < size; i++) { | 53 for (int i = 0; i < size; i++) { |
54 T cur; | 54 T cur; |
55 if (!ReadParam(m, iter, &cur)) | 55 if (!ReadParam(m, iter, &cur)) |
56 return false; | 56 return false; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 PickleIterator* iter, | 111 PickleIterator* iter, |
112 param_type* p) { | 112 param_type* p) { |
113 uint16 size; | 113 uint16 size; |
114 if (!ReadParam(m, iter, &size)) | 114 if (!ReadParam(m, iter, &size)) |
115 return false; | 115 return false; |
116 if (size > sizeof(p->data)) | 116 if (size > sizeof(p->data)) |
117 return false; | 117 return false; |
118 p->size = size; | 118 p->size = size; |
119 | 119 |
120 const char* data; | 120 const char* data; |
121 if (!m->ReadBytes(iter, &data, size)) | 121 if (!iter->ReadBytes(&data, size)) |
122 return false; | 122 return false; |
123 memcpy(p->data, data, size); | 123 memcpy(p->data, data, size); |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 // static | 127 // static |
128 void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, | 128 void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, |
129 std::string* l) { | 129 std::string* l) { |
130 l->append("<PP_NetAddress_Private ("); | 130 l->append("<PP_NetAddress_Private ("); |
131 LogParam(p.size, l); | 131 LogParam(p.size, l); |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 } | 654 } |
655 return true; | 655 return true; |
656 } | 656 } |
657 | 657 |
658 void ParamTraits<ppapi::CompositorLayerData::Transform>::Log( | 658 void ParamTraits<ppapi::CompositorLayerData::Transform>::Log( |
659 const param_type& p, | 659 const param_type& p, |
660 std::string* l) { | 660 std::string* l) { |
661 } | 661 } |
662 | 662 |
663 } // namespace IPC | 663 } // namespace IPC |
OLD | NEW |