| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace | 293 } // namespace |
| 294 //------------------------------------------------------------------------------ | 294 //------------------------------------------------------------------------------ |
| 295 | 295 |
| 296 Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle, | 296 Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle, |
| 297 Mode mode, Listener* listener) | 297 Mode mode, Listener* listener) |
| 298 : mode_(mode), | 298 : mode_(mode), |
| 299 is_blocked_on_write_(false), | 299 is_blocked_on_write_(false), |
| 300 message_send_bytes_written_(0), | 300 message_send_bytes_written_(0), |
| 301 uses_fifo_( | 301 uses_fifo_(CommandLine::ForCurrentProcess()->HasSwitch( |
| 302 CommandLine::ForCurrentProcess()->HasSwitch(switches::kIPCUseFIFO) || | 302 switches::kIPCUseFIFO)), |
| 303 mode == MODE_NAMED_SERVER || mode == MODE_NAMED_CLIENT), | |
| 304 server_listen_pipe_(-1), | 303 server_listen_pipe_(-1), |
| 305 pipe_(-1), | 304 pipe_(-1), |
| 306 client_pipe_(-1), | 305 client_pipe_(-1), |
| 307 #if defined(IPC_USES_READWRITE) | 306 #if defined(IPC_USES_READWRITE) |
| 308 fd_pipe_(-1), | 307 fd_pipe_(-1), |
| 309 remote_fd_pipe_(-1), | 308 remote_fd_pipe_(-1), |
| 310 #endif | 309 #endif |
| 311 listener_(listener), | 310 listener_(listener), |
| 312 waiting_connect_(true), | 311 waiting_connect_(true), |
| 313 factory_(this) { | 312 factory_(this) { |
| 314 if (mode_ == MODE_NAMED_SERVER) | |
| 315 mode_ = MODE_SERVER; | |
| 316 if (mode_ == MODE_NAMED_CLIENT) | |
| 317 mode_ = MODE_CLIENT; | |
| 318 | |
| 319 if (!CreatePipe(channel_handle, mode_)) { | 313 if (!CreatePipe(channel_handle, mode_)) { |
| 320 // The pipe may have been closed already. | 314 // The pipe may have been closed already. |
| 321 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name | 315 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name |
| 322 << "\" in " << (mode_ == MODE_SERVER ? "server" : "client") | 316 << "\" in " << (mode_ == MODE_SERVER ? "server" : "client") |
| 323 << " mode"; | 317 << " mode"; |
| 324 } | 318 } |
| 325 } | 319 } |
| 326 | 320 |
| 327 Channel::ChannelImpl::~ChannelImpl() { | 321 Channel::ChannelImpl::~ChannelImpl() { |
| 328 Close(); | 322 Close(); |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1096 |
| 1103 bool Channel::Send(Message* message) { | 1097 bool Channel::Send(Message* message) { |
| 1104 return channel_impl_->Send(message); | 1098 return channel_impl_->Send(message); |
| 1105 } | 1099 } |
| 1106 | 1100 |
| 1107 int Channel::GetClientFileDescriptor() const { | 1101 int Channel::GetClientFileDescriptor() const { |
| 1108 return channel_impl_->GetClientFileDescriptor(); | 1102 return channel_impl_->GetClientFileDescriptor(); |
| 1109 } | 1103 } |
| 1110 | 1104 |
| 1111 } // namespace IPC | 1105 } // namespace IPC |
| OLD | NEW |