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_environment.h" |
19 #include "remoting/host/desktop_session_agent.h" | 20 #include "remoting/host/desktop_session_agent.h" |
20 | 21 |
21 namespace remoting { | 22 namespace remoting { |
22 | 23 |
23 DesktopProcess::DesktopProcess( | 24 DesktopProcess::DesktopProcess( |
24 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 25 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
25 const std::string& daemon_channel_name) | 26 const std::string& daemon_channel_name) |
26 : caller_task_runner_(caller_task_runner), | 27 : caller_task_runner_(caller_task_runner), |
27 daemon_channel_name_(daemon_channel_name) { | 28 daemon_channel_name_(daemon_channel_name) { |
28 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 29 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
29 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 30 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
30 } | 31 } |
31 | 32 |
32 DesktopProcess::~DesktopProcess() { | 33 DesktopProcess::~DesktopProcess() { |
33 DCHECK(!daemon_channel_); | 34 DCHECK(!daemon_channel_); |
34 DCHECK(!desktop_agent_); | 35 DCHECK(!desktop_agent_); |
35 } | 36 } |
36 | 37 |
| 38 DesktopEnvironmentFactory& DesktopProcess::desktop_environment_factory() { |
| 39 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 40 |
| 41 return *desktop_environment_factory_; |
| 42 } |
| 43 |
37 void DesktopProcess::OnNetworkProcessDisconnected() { | 44 void DesktopProcess::OnNetworkProcessDisconnected() { |
38 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 45 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
39 | 46 |
40 OnChannelError(); | 47 OnChannelError(); |
41 } | 48 } |
42 | 49 |
43 void DesktopProcess::InjectSas() { | 50 void DesktopProcess::InjectSas() { |
44 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 51 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
45 | 52 |
46 daemon_channel_->Send(new ChromotingDesktopDaemonMsg_InjectSas()); | 53 daemon_channel_->Send(new ChromotingDesktopDaemonMsg_InjectSas()); |
(...skipping 19 matching lines...) Expand all Loading... |
66 void DesktopProcess::OnChannelError() { | 73 void DesktopProcess::OnChannelError() { |
67 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 74 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
68 | 75 |
69 // Shutdown the desktop process. | 76 // Shutdown the desktop process. |
70 daemon_channel_.reset(); | 77 daemon_channel_.reset(); |
71 desktop_agent_->Stop(); | 78 desktop_agent_->Stop(); |
72 desktop_agent_ = NULL; | 79 desktop_agent_ = NULL; |
73 caller_task_runner_ = NULL; | 80 caller_task_runner_ = NULL; |
74 } | 81 } |
75 | 82 |
76 bool DesktopProcess::Start() { | 83 bool DesktopProcess::Start( |
| 84 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory) { |
77 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 85 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 86 DCHECK(!desktop_environment_factory_); |
| 87 DCHECK(desktop_environment_factory); |
| 88 |
| 89 desktop_environment_factory_ = desktop_environment_factory.Pass(); |
78 | 90 |
79 // Launch the audio capturing thread. | 91 // Launch the audio capturing thread. |
80 scoped_refptr<AutoThreadTaskRunner> audio_task_runner; | 92 scoped_refptr<AutoThreadTaskRunner> audio_task_runner; |
81 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
82 // On Windows the AudioCapturer requires COM, so we run a single-threaded | 94 // On Windows the AudioCapturer requires COM, so we run a single-threaded |
83 // apartment, which requires a UI thread. | 95 // apartment, which requires a UI thread. |
84 audio_task_runner = AutoThread::CreateWithLoopAndComInitTypes( | 96 audio_task_runner = AutoThread::CreateWithLoopAndComInitTypes( |
85 "ChromotingAudioThread", caller_task_runner_, MessageLoop::TYPE_UI, | 97 "ChromotingAudioThread", caller_task_runner_, MessageLoop::TYPE_UI, |
86 AutoThread::COM_INIT_STA); | 98 AutoThread::COM_INIT_STA); |
87 #else // !defined(OS_WIN) | 99 #else // !defined(OS_WIN) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 144 } |
133 | 145 |
134 void DesktopProcess::OnCrash(const std::string& function_name, | 146 void DesktopProcess::OnCrash(const std::string& function_name, |
135 const std::string& file_name, | 147 const std::string& file_name, |
136 const int& line_number) { | 148 const int& line_number) { |
137 // The daemon requested us to crash the process. | 149 // The daemon requested us to crash the process. |
138 CHECK(false); | 150 CHECK(false); |
139 } | 151 } |
140 | 152 |
141 } // namespace remoting | 153 } // namespace remoting |
OLD | NEW |