This source file includes following definitions.
- CreateConnectedIpcChannel
#include "remoting/host/ipc_util.h"
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/single_thread_task_runner.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
namespace remoting {
bool CreateConnectedIpcChannel(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
IPC::Listener* listener,
IPC::PlatformFileForTransit* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out) {
int pipe_fds[2];
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) {
PLOG(ERROR) << "socketpair()";
return false;
}
if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) == -1 ||
fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK) == -1) {
PLOG(ERROR) << "fcntl(O_NONBLOCK)";
if (IGNORE_EINTR(close(pipe_fds[0])) < 0)
PLOG(ERROR) << "close()";
if (IGNORE_EINTR(close(pipe_fds[1])) < 0)
PLOG(ERROR) << "close()";
return false;
}
std::string socket_name = "Chromoting socket";
base::FileDescriptor fd(pipe_fds[0], false);
IPC::ChannelHandle handle(socket_name, fd);
server_out->reset(new IPC::ChannelProxy(IPC::ChannelHandle(socket_name, fd),
IPC::Channel::MODE_SERVER,
listener,
io_task_runner.get()));
*client_out = base::FileDescriptor(pipe_fds[1], false);
return true;
}
}