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 | 185 #endif |
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) | |
203 | 186 |
204 #if defined(USE_X11) | 187 #if defined(USE_X11) |
205 template<> | 188 template<> |
206 struct ParamTraits<TransportDIB::Id> { | 189 struct ParamTraits<TransportDIB::Id> { |
207 typedef TransportDIB::Id param_type; | 190 typedef TransportDIB::Id param_type; |
208 static void Write(Message* m, const param_type& p) { | 191 static void Write(Message* m, const param_type& p) { |
209 WriteParam(m, p.shmkey); | 192 WriteParam(m, p.shmkey); |
210 } | 193 } |
211 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { | 194 static bool Read(const Message* m, PickleIterator* iter, param_type* r) { |
212 return ReadParam(m, iter, &r->shmkey); | 195 return ReadParam(m, iter, &r->shmkey); |
(...skipping 14 matching lines...) Expand all Loading... |
227 // Note: This function expects parameter |r| to be of type &SkBitmap since | 210 // Note: This function expects parameter |r| to be of type &SkBitmap since |
228 // r->SetConfig() and r->SetPixels() are called. | 211 // r->SetConfig() and r->SetPixels() are called. |
229 static bool Read(const Message* m, PickleIterator* iter, param_type* r); | 212 static bool Read(const Message* m, PickleIterator* iter, param_type* r); |
230 | 213 |
231 static void Log(const param_type& p, std::string* l); | 214 static void Log(const param_type& p, std::string* l); |
232 }; | 215 }; |
233 | 216 |
234 } // namespace IPC | 217 } // namespace IPC |
235 | 218 |
236 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ | 219 #endif // CONTENT_PUBLIC_COMMON_COMMON_PARAM_TRAITS_H_ |
OLD | NEW |