| 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 // This file is used to define IPC::ParamTraits<> specializations for a number | 5 // This file is used to define IPC::ParamTraits<> specializations for a number |
| 6 // of types so that they can be serialized over IPC. IPC::ParamTraits<> | 6 // of types so that they can be serialized over IPC. IPC::ParamTraits<> |
| 7 // specializations for basic types (like int and std::string) and types in the | 7 // specializations for basic types (like int and std::string) and types in the |
| 8 // 'base' project can be found in ipc/ipc_message_utils.h. This file contains | 8 // 'base' project can be found in ipc/ipc_message_utils.h. This file contains |
| 9 // specializations for types that are used by the content code, and which need | 9 // specializations for types that are used by the content code, and which need |
| 10 // manual serialization code. This is usually because they're not structs with | 10 // manual serialization code. This is usually because they're not structs with |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 ReadParam(m, iter, &r->sequence_num)); | 175 ReadParam(m, iter, &r->sequence_num)); |
| 176 } | 176 } |
| 177 static void Log(const param_type& p, std::string* l) { | 177 static void Log(const param_type& p, std::string* l) { |
| 178 l->append("TransportDIB("); | 178 l->append("TransportDIB("); |
| 179 LogParam(p.handle, l); | 179 LogParam(p.handle, l); |
| 180 l->append(", "); | 180 l->append(", "); |
| 181 LogParam(p.sequence_num, l); | 181 LogParam(p.sequence_num, l); |
| 182 l->append(")"); | 182 l->append(")"); |
| 183 } | 183 } |
| 184 }; | 184 }; |
| 185 #endif | 185 |
| 186 #if defined(USE_AURA) |
| 187 template <> |
| 188 struct ParamTraits<HWND> { |
| 189 typedef HWND param_type; |
| 190 static void Write(Message* m, const param_type& p) { |
| 191 m->WriteUInt32(reinterpret_cast<uint32>(p)); |
| 192 } |
| 193 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |
| 194 DCHECK_EQ(sizeof(param_type), sizeof(uint32)); |
| 195 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); |
| 196 } |
| 197 static void Log(const param_type& p, std::string* l) { |
| 198 l->append("<HWND>"); |
| 199 } |
| 200 }; |
| 201 #endif // defined(USE_AURA) |
| 202 #endif // defined(OS_WIN) |
| 186 | 203 |
| 187 #if defined(USE_X11) | 204 #if defined(USE_X11) |
| 188 template<> | 205 template<> |
| 189 struct ParamTraits<TransportDIB::Id> { | 206 struct ParamTraits<TransportDIB::Id> { |
| 190 typedef TransportDIB::Id param_type; | 207 typedef TransportDIB::Id param_type; |
| 191 static void Write(Message* m, const param_type& p) { | 208 static void Write(Message* m, const param_type& p) { |
| 192 WriteParam(m, p.shmkey); | 209 WriteParam(m, p.shmkey); |
| 193 } | 210 } |
| 194 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { | 211 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |
| 195 return ReadParam(m, iter, &r->shmkey); | 212 return ReadParam(m, iter, &r->shmkey); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 210 // Note: This function expects parameter |r| to be of type &SkBitmap since | 227 // Note: This function expects parameter |r| to be of type &SkBitmap since |
| 211 // r->SetConfig() and r->SetPixels() are called. | 228 // r->SetConfig() and r->SetPixels() are called. |
| 212 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | 229 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
| 213 | 230 |
| 214 static void Log(const param_type& p, std::string* l); | 231 static void Log(const param_type& p, std::string* l); |
| 215 }; | 232 }; |
| 216 | 233 |
| 217 } // namespace IPC | 234 } // namespace IPC |
| 218 | 235 |
| 219 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ | 236 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ |
| OLD | NEW |