xref: /aosp_15_r20/external/cronet/ipc/message_mojom_traits.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2018 The Chromium Authors
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 <optional>
9 #include <vector>
10 
11 #include "base/containers/span.h"
12 #include "ipc/ipc.mojom-shared.h"
13 #include "ipc/message_view.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 base::span<const uint8_t> bytes(IPC::MessageView& view);
23   static std::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