ipc_mojo_handle_attachment.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) 2015 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_IPC_MOJO_HANDLE_ATTACHMENT_H_
  5. #define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
  6. #include "build/build_config.h"
  7. #include "ipc/ipc_message_attachment.h"
  8. #include "ipc/ipc_message_support_export.h"
  9. #include "mojo/public/cpp/system/handle.h"
  10. namespace IPC {
  11. namespace internal {
  12. // A MessageAttachment that holds a MojoHandle.
  13. // This can hold any type of transferrable Mojo handle (i.e. message pipe, data
  14. // pipe, etc), but the receiver is expected to know what type of handle to
  15. // expect.
  16. class IPC_MESSAGE_SUPPORT_EXPORT MojoHandleAttachment
  17. : public MessageAttachment {
  18. public:
  19. explicit MojoHandleAttachment(mojo::ScopedHandle handle);
  20. MojoHandleAttachment(const MojoHandleAttachment&) = delete;
  21. MojoHandleAttachment& operator=(const MojoHandleAttachment&) = delete;
  22. Type GetType() const override;
  23. // Returns the owning handle transferring the ownership.
  24. mojo::ScopedHandle TakeHandle();
  25. private:
  26. ~MojoHandleAttachment() override;
  27. mojo::ScopedHandle handle_;
  28. };
  29. } // namespace internal
  30. } // namespace IPC
  31. #endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_