summaryrefslogtreecommitdiffstats
path: root/chromium/ipc/message_mojom_traits.h
blob: 6b5064a12191e9a663519e7b5cb7c5f907a75054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IPC_MESSAGE_MOJOM_TRAITS_H_
#define IPC_MESSAGE_MOJOM_TRAITS_H_

#include <vector>

#include "base/containers/span.h"
#include "base/optional.h"
#include "ipc/ipc.mojom-shared.h"
#include "ipc/message_view.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/interfaces/bindings/native_struct.mojom.h"

namespace mojo {

template <>
class StructTraits<IPC::mojom::MessageDataView, IPC::MessageView> {
 public:
  static base::span<const uint8_t> bytes(IPC::MessageView& view);
  static base::Optional<std::vector<mojo::native::SerializedHandlePtr>> handles(
      IPC::MessageView& view);

  static bool Read(IPC::mojom::MessageDataView data, IPC::MessageView* out);
};

}  // namespace mojo

#endif  // IPC_MESSAGE_MOJOM_TRAITS_H_