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

Unified Diff: ipc/ipc_message_utils.cc

Issue 1197853004: Revert of Revert of Make SharedMemoryHandle a class on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_make_class3_base
Patch Set: 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
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | ppapi/proxy/nacl_message_scanner.cc » ('j') | 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..b6b979278a9e387a9af83c9ca2da97de130426b6 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -19,6 +19,10 @@
#if defined(OS_POSIX)
#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>
@@ -516,6 +520,58 @@
}
#endif // defined(OS_POSIX)
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+void ParamTraits<base::SharedMemoryHandle>::Write(Message* m,
+ const param_type& p) {
+ m->WriteInt(p.GetType());
+
+ if (p.GetType() == base::SharedMemoryHandle::POSIX)
+ ParamTraits<base::FileDescriptor>::Write(m, p.GetFileDescriptor());
+}
+
+bool ParamTraits<base::SharedMemoryHandle>::Read(const Message* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ base::SharedMemoryHandle::TypeWireFormat type;
+ if (!iter->ReadInt(&type))
+ return false;
+
+ base::SharedMemoryHandle::Type shm_type = base::SharedMemoryHandle::POSIX;
+ switch (type) {
+ case base::SharedMemoryHandle::POSIX:
+ case base::SharedMemoryHandle::MACH: {
+ shm_type = static_cast<base::SharedMemoryHandle::Type>(type);
+ break;
+ }
+ default:
+ return false;
+ }
+
+ if (shm_type == base::SharedMemoryHandle::POSIX) {
+ base::FileDescriptor file_descriptor;
+
+ bool success =
+ ParamTraits<base::FileDescriptor>::Read(m, iter, &file_descriptor);
+ if (!success)
+ return false;
+
+ *r = base::SharedMemoryHandle(file_descriptor.fd,
+ file_descriptor.auto_close);
+ return true;
+ }
+
+ return true;
+}
+
+void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p,
+ std::string* l) {
+ if (p.GetType() == base::SharedMemoryHandle::POSIX) {
+ l->append(base::StringPrintf("Mechanism POSIX Fd"));
+ ParamTraits<base::FileDescriptor>::Log(p.GetFileDescriptor(), l);
+ }
+}
+#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+
void ParamTraits<base::FilePath>::Write(Message* m, const param_type& p) {
p.WriteToPickle(m);
}
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | ppapi/proxy/nacl_message_scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698