Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / ipc / ipc_channel_posix.cc
index ac9de55..409ff54 100644 (file)
@@ -21,8 +21,8 @@
 #include <string>
 
 #include "base/command_line.h"
-#include "base/file_util.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/location.h"
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
@@ -432,7 +432,7 @@ bool ChannelPosix::ProcessOutgoingMessages() {
       cmsg->cmsg_level = SOL_SOCKET;
       cmsg->cmsg_type = SCM_RIGHTS;
       cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds);
-      msg->file_descriptor_set()->GetDescriptors(
+      msg->file_descriptor_set()->PeekDescriptors(
           reinterpret_cast<int*>(CMSG_DATA(cmsg)));
       msgh.msg_controllen = cmsg->cmsg_len;
 
@@ -769,8 +769,7 @@ void ChannelPosix::QueueHelloMessage() {
 #if defined(IPC_USES_READWRITE)
   scoped_ptr<Message> hello;
   if (remote_fd_pipe_ != -1) {
-    if (!msg->WriteFileDescriptor(base::FileDescriptor(remote_fd_pipe_,
-                                                       false))) {
+    if (!msg->WriteBorrowingFile(remote_fd_pipe_)) {
       NOTREACHED() << "Unable to pickle hello message file descriptors";
     }
     DCHECK_EQ(msg->file_descriptor_set()->size(), 1U);
@@ -896,8 +895,8 @@ bool ChannelPosix::WillDispatchInputMessage(Message* msg) {
   // The shenaniganery below with &foo.front() requires input_fds_ to have
   // contiguous underlying storage (such as a simple array or a std::vector).
   // This is why the header warns not to make input_fds_ a deque<>.
-  msg->file_descriptor_set()->SetDescriptors(&input_fds_.front(),
-                                             header_fds);
+  msg->file_descriptor_set()->AddDescriptorsToOwn(&input_fds_.front(),
+                                                  header_fds);
   input_fds_.erase(input_fds_.begin(), input_fds_.begin() + header_fds);
   return true;
 }
@@ -991,12 +990,11 @@ void ChannelPosix::HandleInternalMessage(const Message& msg) {
         // server also contains the fd_pipe_, which  will be used for all
         // subsequent file descriptor passing.
         DCHECK_EQ(msg.file_descriptor_set()->size(), 1U);
-        base::FileDescriptor descriptor;
-        if (!msg.ReadFileDescriptor(&iter, &descriptor)) {
+        base::ScopedFD descriptor;
+        if (!msg.ReadFile(&iter, &descriptor)) {
           NOTREACHED();
         }
-        fd_pipe_ = descriptor.fd;
-        CHECK(descriptor.auto_close);
+        fd_pipe_ = descriptor.release();
       }
 #endif  // IPC_USES_READWRITE
       peer_pid_ = pid;
@@ -1054,13 +1052,6 @@ base::ProcessId ChannelPosix::GetSelfPID() const {
   return GetHelloMessageProcId();
 }
 
-ChannelHandle ChannelPosix::TakePipeHandle() {
-  ChannelHandle handle = ChannelHandle(pipe_name_,
-                                       base::FileDescriptor(pipe_, false));
-  pipe_ = -1;
-  return handle;
-}
-
 //------------------------------------------------------------------------------
 // Channel's methods