blob: d6152769efd59e8d7300515684c4546f9f6022f7 [file] [log] [blame]
Luis Hector Chavez645501c2016-12-28 10:56:26 -08001// 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
5#ifndef IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
6#define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
7
8#include "base/files/file.h"
9#include "base/macros.h"
10#include "build/build_config.h"
11#include "ipc/ipc_export.h"
12#include "ipc/ipc_message_attachment.h"
13#include "mojo/public/cpp/system/handle.h"
14
15namespace IPC {
16
17namespace internal {
18
19// A MessageAttachment that holds a MojoHandle.
20// This can hold any type of transferrable Mojo handle (i.e. message pipe, data
21// pipe, etc), but the receiver is expected to know what type of handle to
22// expect.
23class IPC_EXPORT MojoHandleAttachment : public MessageAttachment {
24 public:
25 explicit MojoHandleAttachment(mojo::ScopedHandle handle);
26
27 Type GetType() const override;
28
Luis Hector Chavez645501c2016-12-28 10:56:26 -080029 // Returns the owning handle transferring the ownership.
30 mojo::ScopedHandle TakeHandle();
31
32 private:
33 ~MojoHandleAttachment() override;
34 mojo::ScopedHandle handle_;
35
36 DISALLOW_COPY_AND_ASSIGN(MojoHandleAttachment);
37};
38
39} // namespace internal
40} // namespace IPC
41
42#endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_