| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ipc/ipc_channel_posix.h" | 5 #include "ipc/ipc_channel_posix.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 // Create the Hello message | 762 // Create the Hello message |
| 763 scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE, | 763 scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE, |
| 764 HELLO_MESSAGE_TYPE, | 764 HELLO_MESSAGE_TYPE, |
| 765 IPC::Message::PRIORITY_NORMAL)); | 765 IPC::Message::PRIORITY_NORMAL)); |
| 766 if (!msg->WriteInt(GetHelloMessageProcId())) { | 766 if (!msg->WriteInt(GetHelloMessageProcId())) { |
| 767 NOTREACHED() << "Unable to pickle hello message proc id"; | 767 NOTREACHED() << "Unable to pickle hello message proc id"; |
| 768 } | 768 } |
| 769 #if defined(IPC_USES_READWRITE) | 769 #if defined(IPC_USES_READWRITE) |
| 770 scoped_ptr<Message> hello; | 770 scoped_ptr<Message> hello; |
| 771 if (remote_fd_pipe_ != -1) { | 771 if (remote_fd_pipe_ != -1) { |
| 772 if (!msg->WriteFileDescriptor(base::FileDescriptor(remote_fd_pipe_, | 772 if (!msg->WriteBorrowingFile(remote_fd_pipe_)) { |
| 773 false))) { | |
| 774 NOTREACHED() << "Unable to pickle hello message file descriptors"; | 773 NOTREACHED() << "Unable to pickle hello message file descriptors"; |
| 775 } | 774 } |
| 776 DCHECK_EQ(msg->file_descriptor_set()->size(), 1U); | 775 DCHECK_EQ(msg->file_descriptor_set()->size(), 1U); |
| 777 } | 776 } |
| 778 #endif // IPC_USES_READWRITE | 777 #endif // IPC_USES_READWRITE |
| 779 output_queue_.push(msg.release()); | 778 output_queue_.push(msg.release()); |
| 780 } | 779 } |
| 781 | 780 |
| 782 ChannelPosix::ReadState ChannelPosix::ReadData( | 781 ChannelPosix::ReadState ChannelPosix::ReadData( |
| 783 char* buffer, | 782 char* buffer, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 int pid; | 983 int pid; |
| 985 if (!msg.ReadInt(&iter, &pid)) | 984 if (!msg.ReadInt(&iter, &pid)) |
| 986 NOTREACHED(); | 985 NOTREACHED(); |
| 987 | 986 |
| 988 #if defined(IPC_USES_READWRITE) | 987 #if defined(IPC_USES_READWRITE) |
| 989 if (mode_ & MODE_SERVER_FLAG) { | 988 if (mode_ & MODE_SERVER_FLAG) { |
| 990 // With IPC_USES_READWRITE, the Hello message from the client to the | 989 // With IPC_USES_READWRITE, the Hello message from the client to the |
| 991 // server also contains the fd_pipe_, which will be used for all | 990 // server also contains the fd_pipe_, which will be used for all |
| 992 // subsequent file descriptor passing. | 991 // subsequent file descriptor passing. |
| 993 DCHECK_EQ(msg.file_descriptor_set()->size(), 1U); | 992 DCHECK_EQ(msg.file_descriptor_set()->size(), 1U); |
| 994 base::FileDescriptor descriptor; | 993 base::File descriptor; |
| 995 if (!msg.ReadFileDescriptor(&iter, &descriptor)) { | 994 if (!msg.ReadFile(&iter, &descriptor)) { |
| 996 NOTREACHED(); | 995 NOTREACHED(); |
| 997 } | 996 } |
| 998 fd_pipe_ = descriptor.fd; | 997 fd_pipe_ = descriptor.TakePlatformFile(); |
| 999 CHECK(descriptor.auto_close); | |
| 1000 } | 998 } |
| 1001 #endif // IPC_USES_READWRITE | 999 #endif // IPC_USES_READWRITE |
| 1002 peer_pid_ = pid; | 1000 peer_pid_ = pid; |
| 1003 listener()->OnChannelConnected(pid); | 1001 listener()->OnChannelConnected(pid); |
| 1004 break; | 1002 break; |
| 1005 | 1003 |
| 1006 #if defined(OS_MACOSX) | 1004 #if defined(OS_MACOSX) |
| 1007 case Channel::CLOSE_FD_MESSAGE_TYPE: | 1005 case Channel::CLOSE_FD_MESSAGE_TYPE: |
| 1008 int fd, hops; | 1006 int fd, hops; |
| 1009 if (!msg.ReadInt(&iter, &hops)) | 1007 if (!msg.ReadInt(&iter, &hops)) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 } | 1088 } |
| 1091 | 1089 |
| 1092 #if defined(OS_LINUX) | 1090 #if defined(OS_LINUX) |
| 1093 // static | 1091 // static |
| 1094 void Channel::SetGlobalPid(int pid) { | 1092 void Channel::SetGlobalPid(int pid) { |
| 1095 ChannelPosix::SetGlobalPid(pid); | 1093 ChannelPosix::SetGlobalPid(pid); |
| 1096 } | 1094 } |
| 1097 #endif // OS_LINUX | 1095 #endif // OS_LINUX |
| 1098 | 1096 |
| 1099 } // namespace IPC | 1097 } // namespace IPC |
| OLD | NEW |