| 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 "remoting/host/desktop_session_agent.h" | 5 #include "remoting/host/desktop_session_agent.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 | 11 |
| 12 #include "base/posix/eintr_wrapper.h" | 12 #include "base/posix/eintr_wrapper.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
| 15 #include "ipc/ipc_channel_proxy.h" | 15 #include "ipc/ipc_channel_proxy.h" |
| 16 #include "remoting/base/auto_thread_task_runner.h" | 16 #include "remoting/base/auto_thread_task_runner.h" |
| 17 | 17 |
| 18 namespace remoting { | 18 namespace remoting { |
| 19 | 19 |
| 20 // Provides screen/audio capturing and input injection services for | 20 // Provides screen/audio capturing and input injection services for |
| 21 // the network process. | 21 // the network process. |
| 22 class DesktopSessionAgentPosix : public DesktopSessionAgent { | 22 class DesktopSessionAgentPosix : public DesktopSessionAgent { |
| 23 public: | 23 public: |
| 24 DesktopSessionAgentPosix( | 24 DesktopSessionAgentPosix( |
| 25 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 25 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 26 scoped_refptr<AutoThreadTaskRunner> io_task_runner); | 26 scoped_refptr<AutoThreadTaskRunner> io_task_runner); |
| 27 virtual ~DesktopSessionAgentPosix(); | 27 virtual ~DesktopSessionAgentPosix(); |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 virtual bool DoCreateNetworkChannel( | 30 virtual bool CreateChannelForNetworkProcess( |
| 31 IPC::PlatformFileForTransit* client_out, | 31 IPC::PlatformFileForTransit* client_out, |
| 32 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; | 32 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentPosix); | 35 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentPosix); |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 DesktopSessionAgentPosix::DesktopSessionAgentPosix( | 38 DesktopSessionAgentPosix::DesktopSessionAgentPosix( |
| 39 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 39 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 40 scoped_refptr<AutoThreadTaskRunner> io_task_runner) | 40 scoped_refptr<AutoThreadTaskRunner> io_task_runner) |
| 41 : DesktopSessionAgent(caller_task_runner, io_task_runner) { | 41 : DesktopSessionAgent(caller_task_runner, io_task_runner) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 DesktopSessionAgentPosix::~DesktopSessionAgentPosix() { | 44 DesktopSessionAgentPosix::~DesktopSessionAgentPosix() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool DesktopSessionAgentPosix::DoCreateNetworkChannel( | 47 bool DesktopSessionAgentPosix::CreateChannelForNetworkProcess( |
| 48 IPC::PlatformFileForTransit* client_out, | 48 IPC::PlatformFileForTransit* client_out, |
| 49 scoped_ptr<IPC::ChannelProxy>* server_out) { | 49 scoped_ptr<IPC::ChannelProxy>* server_out) { |
| 50 // Create a socket pair. | 50 // Create a socket pair. |
| 51 int pipe_fds[2]; | 51 int pipe_fds[2]; |
| 52 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) { | 52 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) { |
| 53 PLOG(ERROR) << "socketpair()"; | 53 PLOG(ERROR) << "socketpair()"; |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Set both ends to be non-blocking. | 57 // Set both ends to be non-blocking. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 76 IPC::ChannelHandle(socket_name, fd), | 76 IPC::ChannelHandle(socket_name, fd), |
| 77 IPC::Channel::MODE_SERVER, | 77 IPC::Channel::MODE_SERVER, |
| 78 this, | 78 this, |
| 79 io_task_runner())); | 79 io_task_runner())); |
| 80 | 80 |
| 81 *client_out = base::FileDescriptor(pipe_fds[1], false); | 81 *client_out = base::FileDescriptor(pipe_fds[1], false); |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // static | 85 // static |
| 86 scoped_ptr<DesktopSessionAgent> DesktopSessionAgent::Create( | 86 scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create( |
| 87 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 87 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 88 scoped_refptr<AutoThreadTaskRunner> io_task_runner) { | 88 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 89 return scoped_ptr<DesktopSessionAgent>(new DesktopSessionAgentPosix( | 89 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) { |
| 90 caller_task_runner, io_task_runner)); | 90 return scoped_refptr<DesktopSessionAgent>(new DesktopSessionAgentPosix( |
| 91 caller_task_runner, io_task_runner, video_capture_task_runner)); |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace remoting | 94 } // namespace remoting |
| OLD | NEW |