message_mojom_traits.h 958 B

12345678910111213141516171819202122232425262728293031
  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. #ifndef IPC_MESSAGE_MOJOM_TRAITS_H_
  5. #define IPC_MESSAGE_MOJOM_TRAITS_H_
  6. #include <vector>
  7. #include "base/containers/span.h"
  8. #include "ipc/ipc.mojom-shared.h"
  9. #include "ipc/message_view.h"
  10. #include "mojo/public/cpp/bindings/struct_traits.h"
  11. #include "mojo/public/interfaces/bindings/native_struct.mojom.h"
  12. #include "third_party/abseil-cpp/absl/types/optional.h"
  13. namespace mojo {
  14. template <>
  15. class StructTraits<IPC::mojom::MessageDataView, IPC::MessageView> {
  16. public:
  17. static base::span<const uint8_t> bytes(IPC::MessageView& view);
  18. static absl::optional<std::vector<mojo::native::SerializedHandlePtr>> handles(
  19. IPC::MessageView& view);
  20. static bool Read(IPC::mojom::MessageDataView data, IPC::MessageView* out);
  21. };
  22. } // namespace mojo
  23. #endif // IPC_MESSAGE_MOJOM_TRAITS_H_