| 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/types.h> | 10 #include <sys/types.h> |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 //------------------------------------------------------------------------------ | 296 //------------------------------------------------------------------------------ |
| 297 | 297 |
| 298 #if defined(OS_LINUX) | 298 #if defined(OS_LINUX) |
| 299 int Channel::ChannelImpl::global_pid_ = 0; | 299 int Channel::ChannelImpl::global_pid_ = 0; |
| 300 #endif // OS_LINUX | 300 #endif // OS_LINUX |
| 301 | 301 |
| 302 Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle, | 302 Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle, |
| 303 Mode mode, Listener* listener) | 303 Mode mode, Listener* listener) |
| 304 : ChannelReader(listener), | 304 : ChannelReader(listener), |
| 305 mode_(mode), | 305 mode_(mode), |
| 306 peer_pid_(base::kNullProcessId), |
| 306 is_blocked_on_write_(false), | 307 is_blocked_on_write_(false), |
| 307 waiting_connect_(true), | 308 waiting_connect_(true), |
| 308 message_send_bytes_written_(0), | 309 message_send_bytes_written_(0), |
| 309 server_listen_pipe_(-1), | 310 server_listen_pipe_(-1), |
| 310 pipe_(-1), | 311 pipe_(-1), |
| 311 client_pipe_(-1), | 312 client_pipe_(-1), |
| 312 #if defined(IPC_USES_READWRITE) | 313 #if defined(IPC_USES_READWRITE) |
| 313 fd_pipe_(-1), | 314 fd_pipe_(-1), |
| 314 remote_fd_pipe_(-1), | 315 remote_fd_pipe_(-1), |
| 315 #endif // IPC_USES_READWRITE | 316 #endif // IPC_USES_READWRITE |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 // subsequent file descriptor passing. | 1075 // subsequent file descriptor passing. |
| 1075 DCHECK_EQ(msg.file_descriptor_set()->size(), 1U); | 1076 DCHECK_EQ(msg.file_descriptor_set()->size(), 1U); |
| 1076 base::FileDescriptor descriptor; | 1077 base::FileDescriptor descriptor; |
| 1077 if (!msg.ReadFileDescriptor(&iter, &descriptor)) { | 1078 if (!msg.ReadFileDescriptor(&iter, &descriptor)) { |
| 1078 NOTREACHED(); | 1079 NOTREACHED(); |
| 1079 } | 1080 } |
| 1080 fd_pipe_ = descriptor.fd; | 1081 fd_pipe_ = descriptor.fd; |
| 1081 CHECK(descriptor.auto_close); | 1082 CHECK(descriptor.auto_close); |
| 1082 } | 1083 } |
| 1083 #endif // IPC_USES_READWRITE | 1084 #endif // IPC_USES_READWRITE |
| 1085 peer_pid_ = pid; |
| 1084 listener()->OnChannelConnected(pid); | 1086 listener()->OnChannelConnected(pid); |
| 1085 } | 1087 } |
| 1086 | 1088 |
| 1087 void Channel::ChannelImpl::Close() { | 1089 void Channel::ChannelImpl::Close() { |
| 1088 // Close can be called multiple time, so we need to make sure we're | 1090 // Close can be called multiple time, so we need to make sure we're |
| 1089 // idempotent. | 1091 // idempotent. |
| 1090 | 1092 |
| 1091 ResetToAcceptingConnectionState(); | 1093 ResetToAcceptingConnectionState(); |
| 1092 | 1094 |
| 1093 if (must_unlink_) { | 1095 if (must_unlink_) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1121 } | 1123 } |
| 1122 | 1124 |
| 1123 void Channel::Close() { | 1125 void Channel::Close() { |
| 1124 channel_impl_->Close(); | 1126 channel_impl_->Close(); |
| 1125 } | 1127 } |
| 1126 | 1128 |
| 1127 void Channel::set_listener(Listener* listener) { | 1129 void Channel::set_listener(Listener* listener) { |
| 1128 channel_impl_->set_listener(listener); | 1130 channel_impl_->set_listener(listener); |
| 1129 } | 1131 } |
| 1130 | 1132 |
| 1133 base::ProcessId Channel::peer_pid() const { |
| 1134 return channel_impl_->peer_pid(); |
| 1135 } |
| 1136 |
| 1131 bool Channel::Send(Message* message) { | 1137 bool Channel::Send(Message* message) { |
| 1132 return channel_impl_->Send(message); | 1138 return channel_impl_->Send(message); |
| 1133 } | 1139 } |
| 1134 | 1140 |
| 1135 int Channel::GetClientFileDescriptor() const { | 1141 int Channel::GetClientFileDescriptor() const { |
| 1136 return channel_impl_->GetClientFileDescriptor(); | 1142 return channel_impl_->GetClientFileDescriptor(); |
| 1137 } | 1143 } |
| 1138 | 1144 |
| 1139 int Channel::TakeClientFileDescriptor() { | 1145 int Channel::TakeClientFileDescriptor() { |
| 1140 return channel_impl_->TakeClientFileDescriptor(); | 1146 return channel_impl_->TakeClientFileDescriptor(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 | 1181 |
| 1176 | 1182 |
| 1177 #if defined(OS_LINUX) | 1183 #if defined(OS_LINUX) |
| 1178 // static | 1184 // static |
| 1179 void Channel::SetGlobalPid(int pid) { | 1185 void Channel::SetGlobalPid(int pid) { |
| 1180 ChannelImpl::SetGlobalPid(pid); | 1186 ChannelImpl::SetGlobalPid(pid); |
| 1181 } | 1187 } |
| 1182 #endif // OS_LINUX | 1188 #endif // OS_LINUX |
| 1183 | 1189 |
| 1184 } // namespace IPC | 1190 } // namespace IPC |
| OLD | NEW |