message_view.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_VIEW_H_
  5. #define IPC_MESSAGE_VIEW_H_
  6. #include <vector>
  7. #include "base/component_export.h"
  8. #include "base/containers/span.h"
  9. #include "ipc/ipc_message.h"
  10. #include "mojo/public/interfaces/bindings/native_struct.mojom-forward.h"
  11. #include "third_party/abseil-cpp/absl/types/optional.h"
  12. namespace IPC {
  13. class COMPONENT_EXPORT(IPC_MOJOM) MessageView {
  14. public:
  15. MessageView();
  16. MessageView(
  17. base::span<const uint8_t> bytes,
  18. absl::optional<std::vector<mojo::native::SerializedHandlePtr>> handles);
  19. MessageView(MessageView&&);
  20. MessageView(const MessageView&) = delete;
  21. MessageView& operator=(const MessageView&) = delete;
  22. ~MessageView();
  23. MessageView& operator=(MessageView&&);
  24. base::span<const uint8_t> bytes() const { return bytes_; }
  25. absl::optional<std::vector<mojo::native::SerializedHandlePtr>> TakeHandles();
  26. private:
  27. base::span<const uint8_t> bytes_;
  28. absl::optional<std::vector<mojo::native::SerializedHandlePtr>> handles_;
  29. };
  30. } // namespace IPC
  31. #endif // IPC_MESSAGE_VIEW_H_