| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_file_info.h" | 9 #include "ppapi/c/pp_file_info.h" |
| 10 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
| 11 #include "ppapi/c/private/ppb_flash_tcp_socket.h" | 11 #include "ppapi/c/private/ppb_tcp_socket.h" |
| 12 #include "ppapi/proxy/ppapi_messages.h" | 12 #include "ppapi/proxy/ppapi_messages.h" |
| 13 #include "ppapi/proxy/serialized_var.h" | 13 #include "ppapi/proxy/serialized_var.h" |
| 14 #include "ppapi/proxy/serialized_flash_menu.h" | 14 #include "ppapi/proxy/serialized_flash_menu.h" |
| 15 #include "ppapi/shared_impl/host_resource.h" | 15 #include "ppapi/shared_impl/host_resource.h" |
| 16 | 16 |
| 17 namespace IPC { | 17 namespace IPC { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Deserializes a vector from IPC. This special version must be used instead | 21 // Deserializes a vector from IPC. This special version must be used instead |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) | 129 system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) |
| 130 return false; | 130 return false; |
| 131 r->system_type = static_cast<PP_FileSystemType>(system_type); | 131 r->system_type = static_cast<PP_FileSystemType>(system_type); |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 | 134 |
| 135 // static | 135 // static |
| 136 void ParamTraits<PP_FileInfo>::Log(const param_type& p, std::string* l) { | 136 void ParamTraits<PP_FileInfo>::Log(const param_type& p, std::string* l) { |
| 137 } | 137 } |
| 138 | 138 |
| 139 // PP_Flash_NetAddress --------------------------------------------------------- | 139 // PP_NetAddress --------------------------------------------------------- |
| 140 | 140 |
| 141 // static | 141 // static |
| 142 void ParamTraits<PP_Flash_NetAddress>::Write(Message* m, const param_type& p) { | 142 void ParamTraits<PP_NetAddress>::Write(Message* m, const param_type& p) { |
| 143 WriteParam(m, p.size); | 143 WriteParam(m, p.size); |
| 144 m->WriteBytes(p.data, static_cast<int>(p.size)); | 144 m->WriteBytes(p.data, static_cast<int>(p.size)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // static | 147 // static |
| 148 bool ParamTraits<PP_Flash_NetAddress>::Read(const Message* m, | 148 bool ParamTraits<PP_NetAddress>::Read(const Message* m, |
| 149 void** iter, | 149 void** iter, |
| 150 param_type* p) { | 150 param_type* p) { |
| 151 uint16 size; | 151 uint16 size; |
| 152 if (!ReadParam(m, iter, &size)) | 152 if (!ReadParam(m, iter, &size)) |
| 153 return false; | 153 return false; |
| 154 if (size > sizeof(p->data)) | 154 if (size > sizeof(p->data)) |
| 155 return false; | 155 return false; |
| 156 p->size = size; | 156 p->size = size; |
| 157 | 157 |
| 158 const char* data; | 158 const char* data; |
| 159 if (!m->ReadBytes(iter, &data, size)) | 159 if (!m->ReadBytes(iter, &data, size)) |
| 160 return false; | 160 return false; |
| 161 memcpy(p->data, data, size); | 161 memcpy(p->data, data, size); |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 // static | 165 // static |
| 166 void ParamTraits<PP_NetAddress>::Log(const param_type& p, |
| 167 std::string* l) { |
| 168 l->append("<PP_NetAddress ("); |
| 169 LogParam(p.size, l); |
| 170 l->append(" bytes)>"); |
| 171 } |
| 172 |
| 173 // PP_Flash_NetAddress --------------------------------------------------------- |
| 174 |
| 175 // static |
| 176 void ParamTraits<PP_Flash_NetAddress>::Write(Message* m, const param_type& p) { |
| 177 ParamTraits<PP_NetAddress>::Write(m, |
| 178 reinterpret_cast<const ParamTraits<PP_NetAddress>::param_type&>(p)); |
| 179 } |
| 180 |
| 181 // static |
| 182 bool ParamTraits<PP_Flash_NetAddress>::Read(const Message* m, |
| 183 void** iter, |
| 184 param_type* p) { |
| 185 return ParamTraits<PP_NetAddress>::Read(m, iter, |
| 186 reinterpret_cast<ParamTraits<PP_NetAddress>::param_type*>(p)); |
| 187 } |
| 188 |
| 189 // static |
| 166 void ParamTraits<PP_Flash_NetAddress>::Log(const param_type& p, | 190 void ParamTraits<PP_Flash_NetAddress>::Log(const param_type& p, |
| 167 std::string* l) { | 191 std::string* l) { |
| 168 l->append("<PP_Flash_NetAddress ("); | 192 ParamTraits<PP_NetAddress>::Log( |
| 169 LogParam(p.size, l); | 193 reinterpret_cast<const ParamTraits<PP_NetAddress>::param_type&>(p), l); |
| 170 l->append(" bytes)>"); | |
| 171 } | 194 } |
| 172 | 195 |
| 173 // PP_ObjectProperty ----------------------------------------------------------- | 196 // PP_ObjectProperty ----------------------------------------------------------- |
| 174 | 197 |
| 175 // static | 198 // static |
| 176 void ParamTraits<PP_ObjectProperty>::Write(Message* m, const param_type& p) { | 199 void ParamTraits<PP_ObjectProperty>::Write(Message* m, const param_type& p) { |
| 177 // FIXME(brettw); | 200 // FIXME(brettw); |
| 178 } | 201 } |
| 179 | 202 |
| 180 // static | 203 // static |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 param_type* r) { | 497 param_type* r) { |
| 475 return r->ReadFromMessage(m, iter); | 498 return r->ReadFromMessage(m, iter); |
| 476 } | 499 } |
| 477 | 500 |
| 478 // static | 501 // static |
| 479 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, | 502 void ParamTraits<ppapi::proxy::SerializedFlashMenu>::Log(const param_type& p, |
| 480 std::string* l) { | 503 std::string* l) { |
| 481 } | 504 } |
| 482 | 505 |
| 483 } // namespace IPC | 506 } // namespace IPC |
| OLD | NEW |