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

Unified Diff: ipc/ipc_message_utils.cc

Issue 1163943004: Make SharedMemoryHandle a class on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_make_class3_base
Patch Set: Use right include on windows. Created 5 years, 6 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
« base/memory/shared_memory_handle_mac.cc ('K') | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_utils.cc
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index f86022c691a09cded39dc2cd21928bcaca8b9646..52abd08e5ce0f716fd697900ec3acb2f9ac2b849 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -20,6 +20,10 @@
#include "ipc/ipc_platform_file_attachment_posix.h"
#endif
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+#include "base/memory/shared_memory_handle.h"
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+
#if defined(OS_WIN)
#include <tchar.h>
#endif
@@ -516,6 +520,44 @@ void ParamTraits<base::FileDescriptor>::Log(const param_type& p,
}
#endif // defined(OS_POSIX)
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+void ParamTraits<base::SharedMemoryHandle>::Write(Message* m,
+ const param_type& p) {
+ uint32_t mechanism = p.GetMechanismForWire();
+ WriteParam(m, mechanism);
+
+ if (p.IsBackedByPOSIXFd())
+ ParamTraits<base::FileDescriptor>::Write(m, *p.GetFileDescriptor());
+}
+
+bool ParamTraits<base::SharedMemoryHandle>::Read(const Message* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ uint32_t mechanism;
+ if (!ReadParam(m, iter, &mechanism))
+ return false;
+
+ bool success = r->SetMechanismFromWire(mechanism);
+ if (!success)
+ return false;
+
+ if (r->IsBackedByPOSIXFd()) {
+ return ParamTraits<base::FileDescriptor>::Read(m, iter,
+ r->GetFileDescriptor());
+ }
+
+ return true;
+}
+
+void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p,
+ std::string* l) {
+ if (p.IsBackedByPOSIXFd()) {
+ l->append(base::StringPrintf("Mechanism POSIX Fd"));
+ ParamTraits<base::FileDescriptor>::Log(*p.GetFileDescriptor(), l);
+ }
+}
+#endif
+
void ParamTraits<base::FilePath>::Write(Message* m, const param_type& p) {
p.WriteToPickle(m);
}
« base/memory/shared_memory_handle_mac.cc ('K') | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698