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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 daemon_channel_name_(daemon_channel_name) { | 27 daemon_channel_name_(daemon_channel_name) { |
28 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 28 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
29 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 29 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
30 } | 30 } |
31 | 31 |
32 DesktopProcess::~DesktopProcess() { | 32 DesktopProcess::~DesktopProcess() { |
33 DCHECK(!daemon_channel_); | 33 DCHECK(!daemon_channel_); |
34 DCHECK(!desktop_agent_); | 34 DCHECK(!desktop_agent_); |
35 } | 35 } |
36 | 36 |
| 37 void DesktopProcess::OnNetworkProcessDisconnected() { |
| 38 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 39 |
| 40 OnChannelError(); |
| 41 } |
| 42 |
| 43 void DesktopProcess::InjectSas() { |
| 44 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 45 |
| 46 daemon_channel_->Send(new ChromotingDesktopDaemonMsg_InjectSas()); |
| 47 } |
| 48 |
37 bool DesktopProcess::OnMessageReceived(const IPC::Message& message) { | 49 bool DesktopProcess::OnMessageReceived(const IPC::Message& message) { |
38 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 50 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
39 | 51 |
40 bool handled = true; | 52 bool handled = true; |
41 IPC_BEGIN_MESSAGE_MAP(DesktopProcess, message) | 53 IPC_BEGIN_MESSAGE_MAP(DesktopProcess, message) |
42 IPC_MESSAGE_HANDLER(ChromotingDaemonDesktopMsg_Crash, OnCrash) | 54 IPC_MESSAGE_HANDLER(ChromotingDaemonDesktopMsg_Crash, OnCrash) |
43 IPC_MESSAGE_UNHANDLED(handled = false) | 55 IPC_MESSAGE_UNHANDLED(handled = false) |
44 IPC_END_MESSAGE_MAP() | 56 IPC_END_MESSAGE_MAP() |
45 return handled; | 57 return handled; |
46 } | 58 } |
(...skipping 30 matching lines...) Expand all Loading... |
77 // Launch the video capture thread. | 89 // Launch the video capture thread. |
78 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner = | 90 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner = |
79 AutoThread::Create("Video capture thread", caller_task_runner_); | 91 AutoThread::Create("Video capture thread", caller_task_runner_); |
80 | 92 |
81 // Create a desktop agent. | 93 // Create a desktop agent. |
82 desktop_agent_ = DesktopSessionAgent::Create(caller_task_runner_, | 94 desktop_agent_ = DesktopSessionAgent::Create(caller_task_runner_, |
83 input_task_runner, | 95 input_task_runner, |
84 io_task_runner, | 96 io_task_runner, |
85 video_capture_task_runner); | 97 video_capture_task_runner); |
86 | 98 |
87 // Start the agent and create an IPC channel to talk to it. It is safe to | 99 // Start the agent and create an IPC channel to talk to it. |
88 // use base::Unretained(this) here because the message loop below will run | |
89 // until |desktop_agent_| is completely destroyed. | |
90 IPC::PlatformFileForTransit desktop_pipe; | 100 IPC::PlatformFileForTransit desktop_pipe; |
91 if (!desktop_agent_->Start(base::Bind(&DesktopProcess::OnChannelError, | 101 if (!desktop_agent_->Start(AsWeakPtr(), &desktop_pipe)) { |
92 base::Unretained(this)), | |
93 &desktop_pipe)) { | |
94 desktop_agent_ = NULL; | 102 desktop_agent_ = NULL; |
95 caller_task_runner_ = NULL; | 103 caller_task_runner_ = NULL; |
96 return false; | 104 return false; |
97 } | 105 } |
98 | 106 |
99 // Connect to the daemon. | 107 // Connect to the daemon. |
100 daemon_channel_.reset(new IPC::ChannelProxy(daemon_channel_name_, | 108 daemon_channel_.reset(new IPC::ChannelProxy(daemon_channel_name_, |
101 IPC::Channel::MODE_CLIENT, | 109 IPC::Channel::MODE_CLIENT, |
102 this, | 110 this, |
103 io_task_runner)); | 111 io_task_runner)); |
104 | 112 |
105 // Pass |desktop_pipe| to the daemon. | 113 // Pass |desktop_pipe| to the daemon. |
106 daemon_channel_->Send( | 114 daemon_channel_->Send( |
107 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe)); | 115 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe)); |
108 | 116 |
109 return true; | 117 return true; |
110 } | 118 } |
111 | 119 |
112 void DesktopProcess::OnCrash(const std::string& function_name, | 120 void DesktopProcess::OnCrash(const std::string& function_name, |
113 const std::string& file_name, | 121 const std::string& file_name, |
114 const int& line_number) { | 122 const int& line_number) { |
115 // The daemon requested us to crash the process. | 123 // The daemon requested us to crash the process. |
116 CHECK(false); | 124 CHECK(false); |
117 } | 125 } |
118 | 126 |
119 } // namespace remoting | 127 } // namespace remoting |
OLD | NEW |