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

Unified Diff: ipc/ipc_message_utils.cc

Issue 583473002: IPC: Get rid of FileDescriptor usage from FileDescriptorSet and Message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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.cc ('k') | ipc/mojo/ipc_channel_mojo.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 f5543ff71496b26fa6af8a116f278fbeab6d9c20..be8795b00efa360cee2cc0a8f69e3168f79e988e 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -462,8 +462,14 @@ void ParamTraits<base::FileDescriptor>::Write(Message* m, const param_type& p) {
const bool valid = p.fd >= 0;
WriteParam(m, valid);
- if (valid) {
- if (!m->WriteFileDescriptor(p))
+ if (!valid)
+ return;
+
+ if (p.auto_close) {
+ if (!m->WriteFile(base::ScopedFD(p.fd)))
+ NOTREACHED();
+ } else {
+ if (!m->WriteBorrowingFile(p.fd))
NOTREACHED();
}
}
@@ -471,17 +477,22 @@ void ParamTraits<base::FileDescriptor>::Write(Message* m, const param_type& p) {
bool ParamTraits<base::FileDescriptor>::Read(const Message* m,
PickleIterator* iter,
param_type* r) {
+ *r = base::FileDescriptor();
+
bool valid;
if (!ReadParam(m, iter, &valid))
return false;
- if (!valid) {
- r->fd = -1;
- r->auto_close = false;
+ // TODO(morrita): Seems like this should return false.
+ if (!valid)
return true;
- }
- return m->ReadFileDescriptor(iter, r);
+ base::ScopedFD fd;
+ if (!m->ReadFile(iter, &fd))
+ return false;
+
+ *r = base::FileDescriptor(fd.release(), true);
+ return true;
}
void ParamTraits<base::FileDescriptor>::Log(const param_type& p,
« no previous file with comments | « ipc/ipc_message.cc ('k') | ipc/mojo/ipc_channel_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698