[go: nahoru, domu]

blob: 5461ffa6d914ad26fdff8ccabe3fed3a78c74238 [file] [log] [blame]
Ken Rockot4c5bd802018-07-12 01:37:111// 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_VIEW_H_
6#define IPC_MESSAGE_VIEW_H_
7
8#include <vector>
9
10#include "base/component_export.h"
11#include "base/containers/span.h"
12#include "base/macros.h"
13#include "ipc/ipc_message.h"
Takuto Ikutaaa3b796c2019-02-06 02:54:5614#include "mojo/public/interfaces/bindings/native_struct.mojom-forward.h"
Lei Zhang698df03c2021-05-21 04:23:3415#include "third_party/abseil-cpp/absl/types/optional.h"
Ken Rockot4c5bd802018-07-12 01:37:1116
17namespace IPC {
18
19class COMPONENT_EXPORT(IPC_MOJOM) MessageView {
20 public:
21 MessageView();
22 MessageView(
Ken Rockot85bd7c82021-03-04 23:38:1323 base::span<const uint8_t> bytes,
Anton Bikineev1f42a452021-05-15 18:02:5024 absl::optional<std::vector<mojo::native::SerializedHandlePtr>> handles);
Ken Rockot4c5bd802018-07-12 01:37:1125 MessageView(MessageView&&);
26 ~MessageView();
27
28 MessageView& operator=(MessageView&&);
29
Ken Rockot85bd7c82021-03-04 23:38:1330 base::span<const uint8_t> bytes() const { return bytes_; }
Anton Bikineev1f42a452021-05-15 18:02:5031 absl::optional<std::vector<mojo::native::SerializedHandlePtr>> TakeHandles();
Ken Rockot4c5bd802018-07-12 01:37:1132
33 private:
Ken Rockot85bd7c82021-03-04 23:38:1334 base::span<const uint8_t> bytes_;
Anton Bikineev1f42a452021-05-15 18:02:5035 absl::optional<std::vector<mojo::native::SerializedHandlePtr>> handles_;
Ken Rockot4c5bd802018-07-12 01:37:1136
37 DISALLOW_COPY_AND_ASSIGN(MessageView);
38};
39
40} // namespace IPC
41
42#endif // IPC_MESSAGE_VIEW_H_