blob: 6aa1888c02d49c2490d3ab835afea47d3d171cd7 [file] [log] [blame]
morrita81b17e02015-02-06 00:58:301// 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
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
8#include "base/files/file.h"
avi246998d82015-12-22 02:39:049#include "base/macros.h"
10#include "build/build_config.h"
morrita81b17e02015-02-06 00:58:3011#include "ipc/ipc_export.h"
12#include "ipc/ipc_message_attachment.h"
rockot85dce0862015-11-13 01:33:5913#include "mojo/public/cpp/system/handle.h"
morrita81b17e02015-02-06 00:58:3014
15namespace IPC {
16
17namespace internal {
18
19// A MessageAttachment that holds a MojoHandle.
amistry980a61b2016-06-09 02:51:2020// 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.
amistryd4aa70d2016-06-23 07:52:3723class IPC_EXPORT MojoHandleAttachment : public MessageAttachment {
morrita81b17e02015-02-06 00:58:3024 public:
25 explicit MojoHandleAttachment(mojo::ScopedHandle handle);
26
27 Type GetType() const override;
28
29#if defined(OS_POSIX)
amistry980a61b2016-06-09 02:51:2030 // Should not be called.
morrita81b17e02015-02-06 00:58:3031 base::PlatformFile TakePlatformFile() override;
32#endif // OS_POSIX
33
34 // Returns the owning handle transferring the ownership.
35 mojo::ScopedHandle TakeHandle();
36
37 private:
38 ~MojoHandleAttachment() override;
39 mojo::ScopedHandle handle_;
40
41 DISALLOW_COPY_AND_ASSIGN(MojoHandleAttachment);
42};
43
44} // namespace internal
45} // namespace IPC
46
amistryd4aa70d2016-06-23 07:52:3747#endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_