| 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 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner); |
| 28 |
| 29 protected: |
| 27 virtual ~DesktopSessionAgentPosix(); | 30 virtual ~DesktopSessionAgentPosix(); |
| 28 | 31 |
| 29 protected: | 32 virtual bool CreateChannelForNetworkProcess( |
| 30 virtual bool DoCreateNetworkChannel( | |
| 31 IPC::PlatformFileForTransit* client_out, | 33 IPC::PlatformFileForTransit* client_out, |
| 32 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; | 34 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentPosix); | 37 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentPosix); |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 DesktopSessionAgentPosix::DesktopSessionAgentPosix( | 40 DesktopSessionAgentPosix::DesktopSessionAgentPosix( |
| 39 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 41 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 40 scoped_refptr<AutoThreadTaskRunner> io_task_runner) | 42 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 41 : DesktopSessionAgent(caller_task_runner, io_task_runner) { | 43 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) |
| 44 : DesktopSessionAgent(caller_task_runner, io_task_runner, |
| 45 video_capture_task_runner) { |
| 42 } | 46 } |
| 43 | 47 |
| 44 DesktopSessionAgentPosix::~DesktopSessionAgentPosix() { | 48 DesktopSessionAgentPosix::~DesktopSessionAgentPosix() { |
| 45 } | 49 } |
| 46 | 50 |
| 47 bool DesktopSessionAgentPosix::DoCreateNetworkChannel( | 51 bool DesktopSessionAgentPosix::CreateChannelForNetworkProcess( |
| 48 IPC::PlatformFileForTransit* client_out, | 52 IPC::PlatformFileForTransit* client_out, |
| 49 scoped_ptr<IPC::ChannelProxy>* server_out) { | 53 scoped_ptr<IPC::ChannelProxy>* server_out) { |
| 50 // Create a socket pair. | 54 // Create a socket pair. |
| 51 int pipe_fds[2]; | 55 int pipe_fds[2]; |
| 52 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) { | 56 if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds) != 0) { |
| 53 PLOG(ERROR) << "socketpair()"; | 57 PLOG(ERROR) << "socketpair()"; |
| 54 return false; | 58 return false; |
| 55 } | 59 } |
| 56 | 60 |
| 57 // Set both ends to be non-blocking. | 61 // Set both ends to be non-blocking. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 76 IPC::ChannelHandle(socket_name, fd), | 80 IPC::ChannelHandle(socket_name, fd), |
| 77 IPC::Channel::MODE_SERVER, | 81 IPC::Channel::MODE_SERVER, |
| 78 this, | 82 this, |
| 79 io_task_runner())); | 83 io_task_runner())); |
| 80 | 84 |
| 81 *client_out = base::FileDescriptor(pipe_fds[1], false); | 85 *client_out = base::FileDescriptor(pipe_fds[1], false); |
| 82 return true; | 86 return true; |
| 83 } | 87 } |
| 84 | 88 |
| 85 // static | 89 // static |
| 86 scoped_ptr<DesktopSessionAgent> DesktopSessionAgent::Create( | 90 scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create( |
| 87 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 91 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 88 scoped_refptr<AutoThreadTaskRunner> io_task_runner) { | 92 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 89 return scoped_ptr<DesktopSessionAgent>(new DesktopSessionAgentPosix( | 93 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) { |
| 90 caller_task_runner, io_task_runner)); | 94 return scoped_refptr<DesktopSessionAgent>(new DesktopSessionAgentPosix( |
| 95 caller_task_runner, io_task_runner, video_capture_task_runner)); |
| 91 } | 96 } |
| 92 | 97 |
| 93 } // namespace remoting | 98 } // namespace remoting |
| OLD | NEW |