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

Unified Diff: chrome/common/ipc_message_utils.h

Issue 20027: Capability: passing fds over IPC (Closed)
Patch Set: ... Created 11 years, 10 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 | « chrome/common/ipc_message.cc ('k') | chrome/common/ipc_tests.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/ipc_message_utils.h
diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h
index 64f56537dc1267d7a64033ba62bf449d44b7107a..7887dcc0f07ae62760e1848546aa7993452fe40b 100644
--- a/chrome/common/ipc_message_utils.h
+++ b/chrome/common/ipc_message_utils.h
@@ -12,6 +12,9 @@
#include "base/file_path.h"
#include "base/string_util.h"
#include "base/tuple.h"
+#if defined(OS_POSIX)
+#include "chrome/common/file_descriptor_posix.h"
+#endif
#include "chrome/common/ipc_sync_message.h"
#include "chrome/common/thumbnail_score.h"
#include "webkit/glue/cache_manager.h"
@@ -662,6 +665,35 @@ struct ParamTraits<gfx::Size> {
static void Log(const param_type& p, std::wstring* l);
};
+#if defined(OS_POSIX)
+
+template<>
+struct ParamTraits<FileDescriptor> {
+ typedef FileDescriptor param_type;
+ static void Write(Message* m, const param_type& p) {
+ if (p.auto_close) {
+ m->descriptor_set()->AddAndAutoClose(p.fd);
+ } else {
+ m->descriptor_set()->Add(p.fd);
+ }
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ r->auto_close = false;
+ r->fd = m->descriptor_set()->NextDescriptor();
+
+ return r->fd >= 0;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ if (p.auto_close) {
+ l->append(StringPrintf(L"FD(%d auto-close)", p.fd));
+ } else {
+ l->append(StringPrintf(L"FD(%d)", p.fd));
+ }
+ }
+};
+
+#endif // defined(OS_POSIX)
+
template<>
struct ParamTraits<ThumbnailScore> {
typedef ThumbnailScore param_type;
« no previous file with comments | « chrome/common/ipc_message.cc ('k') | chrome/common/ipc_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698