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

Unified Diff: ipc/mach_port_attachment_mac.h

Issue 1385143002: ipc: Update MachPortMac ownership semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase errors. Created 5 years, 2 months 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_message_attachment_set.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 efe93c46a13be202a60e6f3fecd013f2ee419cf9..48dc9aadd8da0625647deeeac54a1d19ab7ae450 100644
--- a/ipc/mach_port_attachment_mac.h
+++ b/ipc/mach_port_attachment_mac.h
@@ -45,7 +45,13 @@ class IPC_EXPORT MachPortAttachmentMac : public BrokerableAttachment {
AttachmentId attachment_id;
};
+ // 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.
explicit MachPortAttachmentMac(mach_port_t mach_port);
+
+ // These constructors do not take ownership of |mach_port|, and should only be
+ // called by the receiver of a Chrome IPC message.
explicit MachPortAttachmentMac(const WireFormat& wire_format);
explicit MachPortAttachmentMac(const BrokerableAttachment::AttachmentId& id);
@@ -56,9 +62,21 @@ class IPC_EXPORT MachPortAttachmentMac : public BrokerableAttachment {
mach_port_t get_mach_port() const { return mach_port_; }
+ // The caller of this method has taken ownership of |mach_port_|.
+ void reset_mach_port_ownership() { owns_mach_port_ = false; }
+
private:
~MachPortAttachmentMac() override;
mach_port_t mach_port_;
+
+ // In the sender process, the attachment owns the Mach port of a newly created
+ // message. The attachment broker will eventually take ownership, and set
+ // this member to |false|.
+ // In the destination process, the attachment never owns the Mach port. The
+ // client code that receives the Chrome IPC message is always expected to take
+ // ownership.
+ bool owns_mach_port_;
+ DISALLOW_COPY_AND_ASSIGN(MachPortAttachmentMac);
};
} // namespace internal
« no previous file with comments | « ipc/ipc_message_attachment_set.cc ('k') | ipc/mach_port_attachment_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698