Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1407)

Unified Diff: ipc/mach_port_attachment_mac.h

Issue 2504063002: Revert of Remove IPC::BrokerableAttachment. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_platform_file_attachment_posix.cc ('k') | ipc/mach_port_attachment_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mach_port_attachment_mac.h
diff --git a/ipc/mach_port_attachment_mac.h b/ipc/mach_port_attachment_mac.h
index 861c4e3065635191d42876ff994acb2e17bf6ff7..efc2c11a784a74f8af82fdadd1a467cc97d63a88 100644
--- a/ipc/mach_port_attachment_mac.h
+++ b/ipc/mach_port_attachment_mac.h
@@ -10,16 +10,36 @@
#include "base/macros.h"
#include "base/process/process_handle.h"
+#include "ipc/brokerable_attachment.h"
#include "ipc/ipc_export.h"
-#include "ipc/ipc_message_attachment.h"
#include "ipc/mach_port_mac.h"
namespace IPC {
namespace internal {
// This class represents an OSX mach_port_t attached to a Chrome IPC message.
-class IPC_EXPORT MachPortAttachmentMac : public MessageAttachment {
+class IPC_EXPORT MachPortAttachmentMac : public BrokerableAttachment {
public:
+ struct IPC_EXPORT WireFormat {
+ // IPC translation requires that classes passed through IPC have a default
+ // constructor.
+ WireFormat() : mach_port(0), destination_process(0) {}
+
+ WireFormat(uint32_t mach_port, const base::ProcessId& destination_process)
+ : mach_port(mach_port), destination_process(destination_process) {}
+
+ // The mach port that is intended for duplication, or the mach port that has
+ // been duplicated, depending on context.
+ // The type is uint32_t instead of mach_port_t to ensure that the wire
+ // format stays consistent.
+ uint32_t mach_port;
+ static_assert(sizeof(mach_port_t) <= sizeof(uint32_t),
+ "mach_port_t must be smaller than uint32_t");
+
+ // The id of the destination process that the handle is duplicated into.
+ base::ProcessId destination_process;
+ };
+
// This constructor increments the ref count of |mach_port_| and takes
// ownership of the result. Should only be called by the sender of a Chrome
// IPC message.
@@ -32,7 +52,15 @@
// ref count. Should only be called by the receiver of a Chrome IPC message.
MachPortAttachmentMac(mach_port_t mach_port, FromWire from_wire);
- Type GetType() const override;
+ // This constructor takes ownership of |wire_format.mach_port|, but does not
+ // modify its ref count. Should only be called by the receiver of a Chrome IPC
+ // message.
+ explicit MachPortAttachmentMac(const WireFormat& wire_format);
+
+ BrokerableType GetBrokerableType() const override;
+
+ // Returns the wire format of this attachment.
+ WireFormat GetWireFormat(const base::ProcessId& destination) const;
mach_port_t get_mach_port() const { return mach_port_; }
« no previous file with comments | « ipc/ipc_platform_file_attachment_posix.cc ('k') | ipc/mach_port_attachment_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698