blob: 1b425eb12c97183565582b033360c8c201a064d7 [file] [log] [blame]
Avi Drissmanea1be232022-09-14 23:29:061// Copyright 2015 The Chromium Authors
morrita81b17e02015-02-06 00:58:302// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
amistryd4aa70d2016-06-23 07:52:375#ifndef IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
6#define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
morrita81b17e02015-02-06 00:58:307
avi246998d82015-12-22 02:39:048#include "build/build_config.h"
morrita81b17e02015-02-06 00:58:309#include "ipc/ipc_message_attachment.h"
Ken Rockotfd907632017-09-14 04:23:4110#include "ipc/ipc_message_support_export.h"
rockot85dce0862015-11-13 01:33:5911#include "mojo/public/cpp/system/handle.h"
morrita81b17e02015-02-06 00:58:3012
13namespace IPC {
14
15namespace internal {
16
17// A MessageAttachment that holds a MojoHandle.
amistry980a61b2016-06-09 02:51:2018// This can hold any type of transferrable Mojo handle (i.e. message pipe, data
19// pipe, etc), but the receiver is expected to know what type of handle to
20// expect.
Ken Rockotfd907632017-09-14 04:23:4121class IPC_MESSAGE_SUPPORT_EXPORT MojoHandleAttachment
22 : public MessageAttachment {
morrita81b17e02015-02-06 00:58:3023 public:
24 explicit MojoHandleAttachment(mojo::ScopedHandle handle);
25
Peter Boström896f1372021-11-05 01:12:3026 MojoHandleAttachment(const MojoHandleAttachment&) = delete;
27 MojoHandleAttachment& operator=(const MojoHandleAttachment&) = delete;
28
morrita81b17e02015-02-06 00:58:3029 Type GetType() const override;
30
morrita81b17e02015-02-06 00:58:3031 // Returns the owning handle transferring the ownership.
32 mojo::ScopedHandle TakeHandle();
33
34 private:
35 ~MojoHandleAttachment() override;
36 mojo::ScopedHandle handle_;
morrita81b17e02015-02-06 00:58:3037};
38
39} // namespace internal
40} // namespace IPC
41
amistryd4aa70d2016-06-23 07:52:3742#endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_