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