Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Side by Side Diff: remoting/host/desktop_process.cc

Issue 2451953002: Use ChannelMojo between the remoting network and desktop processes. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/daemon_process_win.cc ('k') | remoting/host/desktop_process_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/debug/alias.h" 14 #include "base/debug/alias.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "ipc/attachment_broker_unprivileged.h"
21 #include "ipc/ipc_channel_proxy.h" 20 #include "ipc/ipc_channel_proxy.h"
22 #include "remoting/base/auto_thread.h" 21 #include "remoting/base/auto_thread.h"
23 #include "remoting/base/auto_thread_task_runner.h" 22 #include "remoting/base/auto_thread_task_runner.h"
24 #include "remoting/host/chromoting_messages.h" 23 #include "remoting/host/chromoting_messages.h"
25 #include "remoting/host/desktop_environment.h" 24 #include "remoting/host/desktop_environment.h"
26 #include "remoting/host/desktop_session_agent.h" 25 #include "remoting/host/desktop_session_agent.h"
27 26
28 #if defined(OS_WIN) 27 #if defined(OS_WIN)
29 #include "base/win/windows_version.h" 28 #include "base/win/windows_version.h"
30 #endif // defined(OS_WIN) 29 #endif // defined(OS_WIN)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 96 }
98 97
99 void DesktopProcess::OnChannelConnected(int32_t peer_pid) { 98 void DesktopProcess::OnChannelConnected(int32_t peer_pid) {
100 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 99 DCHECK(caller_task_runner_->BelongsToCurrentThread());
101 100
102 VLOG(1) << "IPC: desktop <- daemon (" << peer_pid << ")"; 101 VLOG(1) << "IPC: desktop <- daemon (" << peer_pid << ")";
103 } 102 }
104 103
105 void DesktopProcess::OnChannelError() { 104 void DesktopProcess::OnChannelError() {
106 // Shutdown the desktop process. 105 // Shutdown the desktop process.
107 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
108 if (broker && !broker->IsPrivilegedBroker())
109 broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get());
110 daemon_channel_.reset(); 106 daemon_channel_.reset();
111 if (desktop_agent_.get()) { 107 if (desktop_agent_.get()) {
112 desktop_agent_->Stop(); 108 desktop_agent_->Stop();
113 desktop_agent_ = nullptr; 109 desktop_agent_ = nullptr;
114 } 110 }
115 111
116 caller_task_runner_ = nullptr; 112 caller_task_runner_ = nullptr;
117 input_task_runner_ = nullptr; 113 input_task_runner_ = nullptr;
118 io_task_runner_ = nullptr; 114 io_task_runner_ = nullptr;
119 desktop_environment_factory_.reset(); 115 desktop_environment_factory_.reset();
120 } 116 }
121 117
122 bool DesktopProcess::Start( 118 bool DesktopProcess::Start(
123 std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory) { 119 std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory) {
124 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 120 DCHECK(caller_task_runner_->BelongsToCurrentThread());
125 DCHECK(!desktop_environment_factory_); 121 DCHECK(!desktop_environment_factory_);
126 DCHECK(desktop_environment_factory); 122 DCHECK(desktop_environment_factory);
127 123
128 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
129
130 desktop_environment_factory_ = std::move(desktop_environment_factory); 124 desktop_environment_factory_ = std::move(desktop_environment_factory);
131 125
132 // Launch the audio capturing thread. 126 // Launch the audio capturing thread.
133 scoped_refptr<AutoThreadTaskRunner> audio_task_runner; 127 scoped_refptr<AutoThreadTaskRunner> audio_task_runner;
134 #if defined(OS_WIN) 128 #if defined(OS_WIN)
135 // On Windows the AudioCapturer requires COM, so we run a single-threaded 129 // On Windows the AudioCapturer requires COM, so we run a single-threaded
136 // apartment, which requires a UI thread. 130 // apartment, which requires a UI thread.
137 audio_task_runner = 131 audio_task_runner =
138 AutoThread::CreateWithLoopAndComInitTypes("ChromotingAudioThread", 132 AutoThread::CreateWithLoopAndComInitTypes("ChromotingAudioThread",
139 caller_task_runner_, 133 caller_task_runner_,
140 base::MessageLoop::TYPE_UI, 134 base::MessageLoop::TYPE_UI,
141 AutoThread::COM_INIT_STA); 135 AutoThread::COM_INIT_STA);
142 #else // !defined(OS_WIN) 136 #else // !defined(OS_WIN)
143 audio_task_runner = AutoThread::CreateWithType( 137 audio_task_runner = AutoThread::CreateWithType(
144 "ChromotingAudioThread", caller_task_runner_, base::MessageLoop::TYPE_IO); 138 "ChromotingAudioThread", caller_task_runner_, base::MessageLoop::TYPE_IO);
145 #endif // !defined(OS_WIN) 139 #endif // !defined(OS_WIN)
146 140
147 // Create a desktop agent. 141 // Create a desktop agent.
148 desktop_agent_ = 142 desktop_agent_ =
149 new DesktopSessionAgent(audio_task_runner, caller_task_runner_, 143 new DesktopSessionAgent(audio_task_runner, caller_task_runner_,
150 input_task_runner_, io_task_runner_); 144 input_task_runner_, io_task_runner_);
151 145
152 // Start the agent and create an IPC channel to talk to it. 146 // Start the agent and create an IPC channel to talk to it.
153 IPC::PlatformFileForTransit desktop_pipe; 147 mojo::ScopedMessagePipeHandle desktop_pipe =
154 if (!desktop_agent_->Start(AsWeakPtr(), &desktop_pipe)) { 148 desktop_agent_->Start(AsWeakPtr());
155 desktop_agent_ = nullptr;
156 caller_task_runner_ = nullptr;
157 input_task_runner_ = nullptr;
158 desktop_environment_factory_.reset();
159 return false;
160 }
161 149
162 // Connect to the daemon. 150 // Connect to the daemon.
163 daemon_channel_.reset(new IPC::ChannelProxy(this, io_task_runner_)); 151 daemon_channel_ = IPC::ChannelProxy::Create(daemon_channel_handle_.release(),
164 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 152 IPC::Channel::MODE_CLIENT, this,
165 if (broker && !broker->IsPrivilegedBroker()) { 153 io_task_runner_);
166 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
167 }
168 daemon_channel_->Init(daemon_channel_handle_.release(),
169 IPC::Channel::MODE_CLIENT,
170 /*create_pipe_now=*/true);
171 154
172 // Pass |desktop_pipe| to the daemon. 155 // Pass |desktop_pipe| to the daemon.
173 daemon_channel_->Send( 156 daemon_channel_->Send(
174 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe)); 157 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe.release()));
175 158
176 return true; 159 return true;
177 } 160 }
178 161
179 void DesktopProcess::OnCrash(const std::string& function_name, 162 void DesktopProcess::OnCrash(const std::string& function_name,
180 const std::string& file_name, 163 const std::string& file_name,
181 const int& line_number) { 164 const int& line_number) {
182 char message[1024]; 165 char message[1024];
183 base::snprintf(message, sizeof(message), 166 base::snprintf(message, sizeof(message),
184 "Requested by %s at %s, line %d.", 167 "Requested by %s at %s, line %d.",
185 function_name.c_str(), file_name.c_str(), line_number); 168 function_name.c_str(), file_name.c_str(), line_number);
186 base::debug::Alias(message); 169 base::debug::Alias(message);
187 170
188 // The daemon requested us to crash the process. 171 // The daemon requested us to crash the process.
189 CHECK(false) << message; 172 CHECK(false) << message;
190 } 173 }
191 174
192 } // namespace remoting 175 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/daemon_process_win.cc ('k') | remoting/host/desktop_process_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698