blob: 7f7137d87b20f7483fdcfbfc75406ed1beb1c5fc [file] [log] [blame]
morrita98b7aaa2015-01-26 22:42:541// 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_MESSAGE_ATTACHMENT_H_
6#define IPC_IPC_MESSAGE_ATTACHMENT_H_
7
morrita1aa788c2015-01-31 05:45:428#include "base/files/file.h"
9#include "base/macros.h"
morrita98b7aaa2015-01-26 22:42:5410#include "base/memory/ref_counted.h"
rockot502c94f2016-02-03 20:20:1611#include "base/pickle.h"
avi246998d82015-12-22 02:39:0412#include "build/build_config.h"
morrita98b7aaa2015-01-26 22:42:5413#include "ipc/ipc_export.h"
14
15namespace IPC {
16
17// Auxiliary data sent with |Message|. This can be a platform file descriptor
18// or a mojo |MessagePipe|. |GetType()| returns the type of the subclass.
rockot502c94f2016-02-03 20:20:1619class IPC_EXPORT MessageAttachment : public base::Pickle::Attachment {
morrita98b7aaa2015-01-26 22:42:5420 public:
21 enum Type {
erikcheneece6c32015-07-07 22:13:1122 TYPE_PLATFORM_FILE, // The instance is |PlatformFileAttachment|.
23 TYPE_MOJO_HANDLE, // The instance is |MojoHandleAttachment|.
24 TYPE_BROKERABLE_ATTACHMENT, // The instance is |BrokerableAttachment|.
morrita98b7aaa2015-01-26 22:42:5425 };
26
27 virtual Type GetType() const = 0;
morrita81b17e02015-02-06 00:58:3028
29#if defined(OS_POSIX)
morrita1aa788c2015-01-31 05:45:4230 virtual base::PlatformFile TakePlatformFile() = 0;
morrita81b17e02015-02-06 00:58:3031#endif // OS_POSIX
morrita98b7aaa2015-01-26 22:42:5432
33 protected:
erikchenfa705362015-10-30 23:16:2934 friend class base::RefCountedThreadSafe<MessageAttachment>;
morrita1aa788c2015-01-31 05:45:4235 MessageAttachment();
rockot502c94f2016-02-03 20:20:1636 ~MessageAttachment() override;
morrita1aa788c2015-01-31 05:45:4237
38 DISALLOW_COPY_AND_ASSIGN(MessageAttachment);
morrita98b7aaa2015-01-26 22:42:5439};
40
41} // namespace IPC
42
43#endif // IPC_IPC_MESSAGE_ATTACHMENT_H_