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

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

Issue 2446053002: Use ChannelMojo between the remoting daemon 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/desktop_process.h ('k') | remoting/host/desktop_process_main.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>
(...skipping 16 matching lines...) Expand all
27 27
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 #include "base/win/windows_version.h" 29 #include "base/win/windows_version.h"
30 #endif // defined(OS_WIN) 30 #endif // defined(OS_WIN)
31 31
32 namespace remoting { 32 namespace remoting {
33 33
34 DesktopProcess::DesktopProcess( 34 DesktopProcess::DesktopProcess(
35 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 35 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
36 scoped_refptr<AutoThreadTaskRunner> input_task_runner, 36 scoped_refptr<AutoThreadTaskRunner> input_task_runner,
37 const std::string& daemon_channel_name) 37 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
38 mojo::ScopedMessagePipeHandle daemon_channel_handle)
38 : caller_task_runner_(caller_task_runner), 39 : caller_task_runner_(caller_task_runner),
39 input_task_runner_(input_task_runner), 40 input_task_runner_(input_task_runner),
40 daemon_channel_name_(daemon_channel_name) { 41 io_task_runner_(io_task_runner),
42 daemon_channel_handle_(std::move(daemon_channel_handle)) {
41 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 43 DCHECK(caller_task_runner_->BelongsToCurrentThread());
42 DCHECK(base::MessageLoopForUI::IsCurrent()); 44 DCHECK(base::MessageLoopForUI::IsCurrent());
43 } 45 }
44 46
45 DesktopProcess::~DesktopProcess() { 47 DesktopProcess::~DesktopProcess() {
46 DCHECK(!daemon_channel_); 48 DCHECK(!daemon_channel_);
47 DCHECK(!desktop_agent_.get()); 49 DCHECK(!desktop_agent_.get());
48 } 50 }
49 51
50 DesktopEnvironmentFactory& DesktopProcess::desktop_environment_factory() { 52 DesktopEnvironmentFactory& DesktopProcess::desktop_environment_factory() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (broker && !broker->IsPrivilegedBroker()) 108 if (broker && !broker->IsPrivilegedBroker())
107 broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get()); 109 broker->DeregisterBrokerCommunicationChannel(daemon_channel_.get());
108 daemon_channel_.reset(); 110 daemon_channel_.reset();
109 if (desktop_agent_.get()) { 111 if (desktop_agent_.get()) {
110 desktop_agent_->Stop(); 112 desktop_agent_->Stop();
111 desktop_agent_ = nullptr; 113 desktop_agent_ = nullptr;
112 } 114 }
113 115
114 caller_task_runner_ = nullptr; 116 caller_task_runner_ = nullptr;
115 input_task_runner_ = nullptr; 117 input_task_runner_ = nullptr;
118 io_task_runner_ = nullptr;
116 desktop_environment_factory_.reset(); 119 desktop_environment_factory_.reset();
117 } 120 }
118 121
119 bool DesktopProcess::Start( 122 bool DesktopProcess::Start(
120 std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory) { 123 std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory) {
121 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 124 DCHECK(caller_task_runner_->BelongsToCurrentThread());
122 DCHECK(!desktop_environment_factory_); 125 DCHECK(!desktop_environment_factory_);
123 DCHECK(desktop_environment_factory); 126 DCHECK(desktop_environment_factory);
124 127
125 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); 128 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
126 129
127 desktop_environment_factory_ = std::move(desktop_environment_factory); 130 desktop_environment_factory_ = std::move(desktop_environment_factory);
128 131
129 // Launch the audio capturing thread. 132 // Launch the audio capturing thread.
130 scoped_refptr<AutoThreadTaskRunner> audio_task_runner; 133 scoped_refptr<AutoThreadTaskRunner> audio_task_runner;
131 #if defined(OS_WIN) 134 #if defined(OS_WIN)
132 // On Windows the AudioCapturer requires COM, so we run a single-threaded 135 // On Windows the AudioCapturer requires COM, so we run a single-threaded
133 // apartment, which requires a UI thread. 136 // apartment, which requires a UI thread.
134 audio_task_runner = 137 audio_task_runner =
135 AutoThread::CreateWithLoopAndComInitTypes("ChromotingAudioThread", 138 AutoThread::CreateWithLoopAndComInitTypes("ChromotingAudioThread",
136 caller_task_runner_, 139 caller_task_runner_,
137 base::MessageLoop::TYPE_UI, 140 base::MessageLoop::TYPE_UI,
138 AutoThread::COM_INIT_STA); 141 AutoThread::COM_INIT_STA);
139 #else // !defined(OS_WIN) 142 #else // !defined(OS_WIN)
140 audio_task_runner = AutoThread::CreateWithType( 143 audio_task_runner = AutoThread::CreateWithType(
141 "ChromotingAudioThread", caller_task_runner_, base::MessageLoop::TYPE_IO); 144 "ChromotingAudioThread", caller_task_runner_, base::MessageLoop::TYPE_IO);
142 #endif // !defined(OS_WIN) 145 #endif // !defined(OS_WIN)
143 146
144 // Launch the I/O thread.
145 scoped_refptr<AutoThreadTaskRunner> io_task_runner =
146 AutoThread::CreateWithType(
147 "I/O thread", caller_task_runner_, base::MessageLoop::TYPE_IO);
148
149 // Create a desktop agent. 147 // Create a desktop agent.
150 desktop_agent_ = 148 desktop_agent_ =
151 new DesktopSessionAgent(audio_task_runner, caller_task_runner_, 149 new DesktopSessionAgent(audio_task_runner, caller_task_runner_,
152 input_task_runner_, io_task_runner); 150 input_task_runner_, io_task_runner_);
153 151
154 // Start the agent and create an IPC channel to talk to it. 152 // Start the agent and create an IPC channel to talk to it.
155 IPC::PlatformFileForTransit desktop_pipe; 153 IPC::PlatformFileForTransit desktop_pipe;
156 if (!desktop_agent_->Start(AsWeakPtr(), &desktop_pipe)) { 154 if (!desktop_agent_->Start(AsWeakPtr(), &desktop_pipe)) {
157 desktop_agent_ = nullptr; 155 desktop_agent_ = nullptr;
158 caller_task_runner_ = nullptr; 156 caller_task_runner_ = nullptr;
159 input_task_runner_ = nullptr; 157 input_task_runner_ = nullptr;
160 desktop_environment_factory_.reset(); 158 desktop_environment_factory_.reset();
161 return false; 159 return false;
162 } 160 }
163 161
164 // Connect to the daemon. 162 // Connect to the daemon.
165 daemon_channel_.reset(new IPC::ChannelProxy(this, io_task_runner.get())); 163 daemon_channel_.reset(new IPC::ChannelProxy(this, io_task_runner_));
166 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 164 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
167 if (broker && !broker->IsPrivilegedBroker()) { 165 if (broker && !broker->IsPrivilegedBroker()) {
168 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get()); 166 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
169 } 167 }
170 daemon_channel_->Init(daemon_channel_name_, IPC::Channel::MODE_CLIENT, 168 daemon_channel_->Init(daemon_channel_handle_.release(),
169 IPC::Channel::MODE_CLIENT,
171 /*create_pipe_now=*/true); 170 /*create_pipe_now=*/true);
172 171
173 // Pass |desktop_pipe| to the daemon. 172 // Pass |desktop_pipe| to the daemon.
174 daemon_channel_->Send( 173 daemon_channel_->Send(
175 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe)); 174 new ChromotingDesktopDaemonMsg_DesktopAttached(desktop_pipe));
176 175
177 return true; 176 return true;
178 } 177 }
179 178
180 void DesktopProcess::OnCrash(const std::string& function_name, 179 void DesktopProcess::OnCrash(const std::string& function_name,
181 const std::string& file_name, 180 const std::string& file_name,
182 const int& line_number) { 181 const int& line_number) {
183 char message[1024]; 182 char message[1024];
184 base::snprintf(message, sizeof(message), 183 base::snprintf(message, sizeof(message),
185 "Requested by %s at %s, line %d.", 184 "Requested by %s at %s, line %d.",
186 function_name.c_str(), file_name.c_str(), line_number); 185 function_name.c_str(), file_name.c_str(), line_number);
187 base::debug::Alias(message); 186 base::debug::Alias(message);
188 187
189 // The daemon requested us to crash the process. 188 // The daemon requested us to crash the process.
190 CHECK(false) << message; 189 CHECK(false) << message;
191 } 190 }
192 191
193 } // namespace remoting 192 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_process.h ('k') | remoting/host/desktop_process_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698