1 // Copyright 2018 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 IPC_MESSAGE_MOJOM_TRAITS_H_
6 #define IPC_MESSAGE_MOJOM_TRAITS_H_
7 
8 #include <vector>
9 
10 #include "base/optional.h"
11 #include "ipc/ipc.mojom-shared.h"
12 #include "ipc/message_view.h"
13 #include "mojo/public/cpp/base/big_buffer.h"
14 #include "mojo/public/cpp/bindings/struct_traits.h"
15 #include "mojo/public/interfaces/bindings/native_struct.mojom.h"
16 
17 namespace mojo {
18 
19 template <>
20 class StructTraits<IPC::mojom::MessageDataView, IPC::MessageView> {
21  public:
22   static mojo_base::BigBufferView buffer(IPC::MessageView& view);
23   static base::Optional<std::vector<mojo::native::SerializedHandlePtr>> handles(
24       IPC::MessageView& view);
25 
26   static bool Read(IPC::mojom::MessageDataView data, IPC::MessageView* out);
27 };
28 
29 }  // namespace mojo
30 
31 #endif  // IPC_MESSAGE_MOJOM_TRAITS_H_
32