OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GPU_IPC_ID_TYPE_TRAITS_H_ |
| 6 #define GPU_IPC_ID_TYPE_TRAITS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/pickle.h" |
| 11 #include "gpu/command_buffer/common/id_type.h" |
| 12 #include "ipc/ipc_message_utils.h" |
| 13 #include "ipc/ipc_param_traits.h" |
| 14 |
| 15 namespace IPC { |
| 16 |
| 17 template <typename TypeMarker, typename WrappedType, WrappedType kInvalidValue> |
| 18 struct ParamTraits<gpu::IdType<TypeMarker, WrappedType, kInvalidValue>> { |
| 19 using param_type = gpu::IdType<TypeMarker, WrappedType, kInvalidValue>; |
| 20 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
| 21 GetParamSize(sizer, p.GetUnsafeValue()); |
| 22 } |
| 23 static void Write(base::Pickle* m, const param_type& p) { |
| 24 WriteParam(m, p.GetUnsafeValue()); |
| 25 } |
| 26 static bool Read(const base::Pickle* m, |
| 27 base::PickleIterator* iter, |
| 28 param_type* r) { |
| 29 WrappedType value; |
| 30 if (!ReadParam(m, iter, &value)) |
| 31 return false; |
| 32 *r = param_type::FromUnsafeValue(value); |
| 33 return true; |
| 34 } |
| 35 static void Log(const param_type& p, std::string* l) { |
| 36 LogParam(p.GetUnsafeValue(), l); |
| 37 } |
| 38 }; |
| 39 |
| 40 } // namespace IPC |
| 41 |
| 42 #endif // GPU_IPC_ID_TYPE_TRAITS_H_ |
OLD | NEW |