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

Unified Diff: ipc/ipc_message_utils.cc

Issue 2846293002: Make PlatformFileForTransit its own class on Windows. (Closed)
Patch Set: Change message serialization to write nothing if the handle isn't valid. Created 3 years, 8 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') | ipc/ipc_platform_file.h » ('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 db36c0fe7a62622fd0b7e4489c2bfdfd26f4a2f7..a36f51b123c7bd394f9db984c4a673c08b751c3d 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -35,6 +35,7 @@
#if defined(OS_WIN)
#include <tchar.h>
#include "ipc/handle_win.h"
+#include "ipc/ipc_platform_file.h"
#endif
namespace IPC {
@@ -842,6 +843,48 @@ void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p,
}
#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+#if defined(OS_WIN)
+void ParamTraits<PlatformFileForTransit>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ GetParamSize(s, p.IsValid());
+ if (p.IsValid())
+ GetParamSize(s, p.GetHandle());
+}
+
+void ParamTraits<PlatformFileForTransit>::Write(base::Pickle* m,
+ const param_type& p) {
+ m->WriteBool(p.IsValid());
+ if (p.IsValid()) {
+ HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE);
+ ParamTraits<HandleWin>::Write(m, handle_win);
+ ::CloseHandle(p.GetHandle());
+ }
+}
+
+bool ParamTraits<PlatformFileForTransit>::Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ bool is_valid;
+ if (!iter->ReadBool(&is_valid))
+ return false;
+ if (!is_valid) {
+ *r = PlatformFileForTransit();
+ return true;
+ }
+
+ HandleWin handle_win;
+ if (!ParamTraits<HandleWin>::Read(m, iter, &handle_win))
+ return false;
+ *r = PlatformFileForTransit(handle_win.get_handle());
+ return true;
+}
+
+void ParamTraits<PlatformFileForTransit>::Log(const param_type& p,
+ std::string* l) {
+ LogParam(p.GetHandle(), l);
+}
+#endif // defined(OS_WIN)
+
void ParamTraits<base::FilePath>::GetSize(base::PickleSizer* sizer,
const param_type& p) {
p.GetSizeForPickle(sizer);
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | ipc/ipc_platform_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698