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 // This file implements the Windows service controlling Me2Me host processes | 5 // This file implements the Windows service controlling Me2Me host processes |
6 // running within user sessions. | 6 // running within user sessions. |
7 | 7 |
8 #include "remoting/host/desktop_process.h" | 8 #include "remoting/host/desktop_process.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "ipc/ipc_channel_proxy.h" | 15 #include "ipc/ipc_channel_proxy.h" |
16 #include "remoting/base/auto_thread.h" | 16 #include "remoting/base/auto_thread.h" |
17 #include "remoting/base/auto_thread_task_runner.h" | 17 #include "remoting/base/auto_thread_task_runner.h" |
18 #include "remoting/host/chromoting_messages.h" | 18 #include "remoting/host/chromoting_messages.h" |
19 #include "remoting/host/desktop_session_agent.h" | 19 #include "remoting/host/desktop_session_agent.h" |
20 | 20 |
21 const char kIoThreadName[] = "I/O thread"; | |
22 | |
23 namespace remoting { | 21 namespace remoting { |
24 | 22 |
25 DesktopProcess::DesktopProcess( | 23 DesktopProcess::DesktopProcess( |
26 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 24 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
27 const std::string& daemon_channel_name) | 25 const std::string& daemon_channel_name) |
28 : caller_task_runner_(caller_task_runner), | 26 : caller_task_runner_(caller_task_runner), |
29 daemon_channel_name_(daemon_channel_name) { | 27 daemon_channel_name_(daemon_channel_name) { |
30 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 28 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
31 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 29 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
32 } | 30 } |
(...skipping 20 matching lines...) Expand all Loading... |
53 VLOG(1) << "IPC: desktop <- daemon (" << peer_pid << ")"; | 51 VLOG(1) << "IPC: desktop <- daemon (" << peer_pid << ")"; |
54 | 52 |
55 NOTIMPLEMENTED(); | 53 NOTIMPLEMENTED(); |
56 } | 54 } |
57 | 55 |
58 void DesktopProcess::OnChannelError() { | 56 void DesktopProcess::OnChannelError() { |
59 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 57 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
60 | 58 |
61 // Shutdown the desktop process. | 59 // Shutdown the desktop process. |
62 daemon_channel_.reset(); | 60 daemon_channel_.reset(); |
63 desktop_agent_.reset(); | 61 desktop_agent_->Stop(); |
| 62 desktop_agent_ = NULL; |
64 caller_task_runner_ = NULL; | 63 caller_task_runner_ = NULL; |
65 } | 64 } |
66 | 65 |
67 bool DesktopProcess::Start() { | 66 bool DesktopProcess::Start() { |
68 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 67 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
69 | 68 |
70 // Launch the I/O thread. | 69 // Launch the I/O thread. |
71 scoped_refptr<AutoThreadTaskRunner> io_task_runner = | 70 scoped_refptr<AutoThreadTaskRunner> io_task_runner = |
72 AutoThread::CreateWithType(kIoThreadName, caller_task_runner_, | 71 AutoThread::CreateWithType("I/O thread", caller_task_runner_, |
73 MessageLoop::TYPE_IO); | 72 MessageLoop::TYPE_IO); |
74 | 73 |
| 74 // Launch the video capture thread. |
| 75 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner = |
| 76 AutoThread::Create("Video capture thread", caller_task_runner_); |
| 77 |
75 // Create a desktop agent. | 78 // Create a desktop agent. |
76 desktop_agent_ = DesktopSessionAgent::Create(caller_task_runner_, | 79 desktop_agent_ = DesktopSessionAgent::Create(caller_task_runner_, |
77 io_task_runner); | 80 io_task_runner, |
| 81 video_capture_task_runner); |
78 | 82 |
79 // Start the agent and create an IPC channel to talk to it. It is safe to | 83 // Start the agent and create an IPC channel to talk to it. It is safe to |
80 // use base::Unretained(this) here because the message loop below will run | 84 // use base::Unretained(this) here because the message loop below will run |
81 // until |desktop_agent_| is completely destroyed. | 85 // until |desktop_agent_| is completely destroyed. |
82 IPC::PlatformFileForTransit desktop_pipe; | 86 IPC::PlatformFileForTransit desktop_pipe; |
83 if (!desktop_agent_->Start(base::Bind(&DesktopProcess::OnChannelError, | 87 if (!desktop_agent_->Start(base::Bind(&DesktopProcess::OnChannelError, |
84 base::Unretained(this)), | 88 base::Unretained(this)), |
85 &desktop_pipe)) { | 89 &desktop_pipe)) { |
86 desktop_agent_.reset(); | 90 desktop_agent_ = NULL; |
| 91 caller_task_runner_ = NULL; |
87 return false; | 92 return false; |
88 } | 93 } |
89 | 94 |
90 // Connect to the daemon. | 95 // Connect to the daemon. |
91 daemon_channel_.reset(new IPC::ChannelProxy(daemon_channel_name_, | 96 daemon_channel_.reset(new IPC::ChannelProxy(daemon_channel_name_, |
92 IPC::Channel::MODE_CLIENT, | 97 IPC::Channel::MODE_CLIENT, |
93 this, | 98 this, |
94 io_task_runner)); | 99 io_task_runner)); |
95 | 100 |
96 // Pass |desktop_pipe| to the daemon. | 101 // Pass |desktop_pipe| to the daemon. |
97 daemon_channel_->Send( | 102 daemon_channel_->Send( |
98 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe)); | 103 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe)); |
99 | 104 |
100 return true; | 105 return true; |
101 } | 106 } |
102 | 107 |
103 void DesktopProcess::OnCrash(const std::string& function_name, | 108 void DesktopProcess::OnCrash(const std::string& function_name, |
104 const std::string& file_name, | 109 const std::string& file_name, |
105 const int& line_number) { | 110 const int& line_number) { |
106 // The daemon requested us to crash the process. | 111 // The daemon requested us to crash the process. |
107 CHECK(false); | 112 CHECK(false); |
108 } | 113 } |
109 | 114 |
110 } // namespace remoting | 115 } // namespace remoting |
OLD | NEW |