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

Unified Diff: ipc/ipc_message.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.h ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message.cc
diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc
index 1ac4d6e3026a35e7817b068a95ba446e72d15b4f..7bd7a697c4fdc9d1c8cc649204de3228b76608d3 100644
--- a/ipc/ipc_message.cc
+++ b/ipc/ipc_message.cc
@@ -9,6 +9,7 @@
#include "build/build_config.h"
#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
#include "ipc/file_descriptor_set_posix.h"
#endif
@@ -122,19 +123,21 @@ void Message::set_received_time(int64 time) const {
#endif
#if defined(OS_POSIX)
-bool Message::WriteFileDescriptor(const base::FileDescriptor& descriptor) {
+bool Message::WriteFile(base::ScopedFD descriptor) {
// We write the index of the descriptor so that we don't have to
// keep the current descriptor as extra decoding state when deserialising.
WriteInt(file_descriptor_set()->size());
- if (descriptor.auto_close) {
- return file_descriptor_set()->AddAndAutoClose(descriptor.fd);
- } else {
- return file_descriptor_set()->Add(descriptor.fd);
- }
+ return file_descriptor_set()->AddToOwn(descriptor.Pass());
}
-bool Message::ReadFileDescriptor(PickleIterator* iter,
- base::FileDescriptor* descriptor) const {
+bool Message::WriteBorrowingFile(const base::PlatformFile& descriptor) {
+ // We write the index of the descriptor so that we don't have to
+ // keep the current descriptor as extra decoding state when deserialising.
+ WriteInt(file_descriptor_set()->size());
+ return file_descriptor_set()->AddToBorrow(descriptor);
+}
+
+bool Message::ReadFile(PickleIterator* iter, base::ScopedFD* descriptor) const {
int descriptor_index;
if (!ReadInt(iter, &descriptor_index))
return false;
@@ -143,10 +146,13 @@ bool Message::ReadFileDescriptor(PickleIterator* iter,
if (!file_descriptor_set)
return false;
- descriptor->fd = file_descriptor_set->GetDescriptorAt(descriptor_index);
- descriptor->auto_close = true;
+ base::PlatformFile file =
+ file_descriptor_set->TakeDescriptorAt(descriptor_index);
+ if (file < 0)
+ return false;
- return descriptor->fd >= 0;
+ descriptor->reset(file);
+ return true;
}
bool Message::HasFileDescriptors() const {
« no previous file with comments | « ipc/ipc_message.h ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698