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 CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ | 5 #ifndef CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ |
6 #define CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ | 6 #define CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "cc/ipc/surface_id.mojom-shared.h" | 8 #include "cc/ipc/surface_id.mojom-shared.h" |
9 #include "cc/surfaces/surface_id.h" | 9 #include "cc/surfaces/surface_id.h" |
10 #include "mojo/common/common_custom_types_struct_traits.h" | |
10 | 11 |
11 namespace mojo { | 12 namespace mojo { |
12 | 13 |
13 template <> | 14 template <> |
14 struct StructTraits<cc::mojom::SurfaceIdDataView, cc::SurfaceId> { | 15 struct StructTraits<cc::mojom::SurfaceIdDataView, cc::SurfaceId> { |
15 static uint32_t client_id(const cc::SurfaceId& id) { return id.client_id(); } | 16 static uint32_t client_id(const cc::SurfaceId& id) { return id.client_id(); } |
16 | 17 |
17 static uint32_t local_id(const cc::SurfaceId& id) { return id.local_id(); } | 18 static uint32_t local_id(const cc::SurfaceId& id) { return id.local_id(); } |
18 | 19 |
19 static uint64_t nonce(const cc::SurfaceId& id) { return id.nonce(); } | 20 static base::UnguessableToken nonce(const cc::SurfaceId& id) { |
Fady Samuel
2016/09/30 20:30:41
const base::UnguessableToken&
Alex Z.
2016/10/05 18:10:45
Done.
| |
21 return id.nonce(); | |
22 } | |
20 | 23 |
21 static bool Read(cc::mojom::SurfaceIdDataView data, cc::SurfaceId* out) { | 24 static bool Read(cc::mojom::SurfaceIdDataView data, cc::SurfaceId* out) { |
22 *out = cc::SurfaceId(data.client_id(), data.local_id(), data.nonce()); | 25 base::UnguessableToken nonce; |
26 if (!data.ReadNonce(&nonce)) | |
27 return false; | |
28 *out = cc::SurfaceId(data.client_id(), data.local_id(), nonce); | |
23 return true; | 29 return true; |
24 } | 30 } |
25 }; | 31 }; |
26 | 32 |
27 } // namespace mojo | 33 } // namespace mojo |
28 | 34 |
29 #endif // CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ | 35 #endif // CC_IPC_SURFACE_ID_STRUCT_TRAITS_H_ |
OLD | NEW |