Ken Rockot | 4c5bd80 | 2018-07-12 01:37:11 | [diff] [blame] | 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_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 Ikuta | aa3b796c | 2019-02-06 02:54:56 | [diff] [blame] | 14 | #include "mojo/public/interfaces/bindings/native_struct.mojom-forward.h" |
Lei Zhang | 698df03c | 2021-05-21 04:23:34 | [diff] [blame] | 15 | #include "third_party/abseil-cpp/absl/types/optional.h" |
Ken Rockot | 4c5bd80 | 2018-07-12 01:37:11 | [diff] [blame] | 16 | |
| 17 | namespace IPC { |
| 18 | |
| 19 | class COMPONENT_EXPORT(IPC_MOJOM) MessageView { |
| 20 | public: |
| 21 | MessageView(); |
| 22 | MessageView( |
Ken Rockot | 85bd7c8 | 2021-03-04 23:38:13 | [diff] [blame] | 23 | base::span<const uint8_t> bytes, |
Anton Bikineev | 1f42a45 | 2021-05-15 18:02:50 | [diff] [blame] | 24 | absl::optional<std::vector<mojo::native::SerializedHandlePtr>> handles); |
Ken Rockot | 4c5bd80 | 2018-07-12 01:37:11 | [diff] [blame] | 25 | MessageView(MessageView&&); |
| 26 | ~MessageView(); |
| 27 | |
| 28 | MessageView& operator=(MessageView&&); |
| 29 | |
Ken Rockot | 85bd7c8 | 2021-03-04 23:38:13 | [diff] [blame] | 30 | base::span<const uint8_t> bytes() const { return bytes_; } |
Anton Bikineev | 1f42a45 | 2021-05-15 18:02:50 | [diff] [blame] | 31 | absl::optional<std::vector<mojo::native::SerializedHandlePtr>> TakeHandles(); |
Ken Rockot | 4c5bd80 | 2018-07-12 01:37:11 | [diff] [blame] | 32 | |
| 33 | private: |
Ken Rockot | 85bd7c8 | 2021-03-04 23:38:13 | [diff] [blame] | 34 | base::span<const uint8_t> bytes_; |
Anton Bikineev | 1f42a45 | 2021-05-15 18:02:50 | [diff] [blame] | 35 | absl::optional<std::vector<mojo::native::SerializedHandlePtr>> handles_; |
Ken Rockot | 4c5bd80 | 2018-07-12 01:37:11 | [diff] [blame] | 36 | |
| 37 | DISALLOW_COPY_AND_ASSIGN(MessageView); |
| 38 | }; |
| 39 | |
| 40 | } // namespace IPC |
| 41 | |
| 42 | #endif // IPC_MESSAGE_VIEW_H_ |