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

Side by Side Diff: remoting/host/win/unprivileged_process_delegate.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/remoting_me2me_host.cc ('k') | remoting/host/win/wts_session_process_delegate.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 1
2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 // 5 //
6 // This file implements the Windows service controlling Me2Me host processes 6 // This file implements the Windows service controlling Me2Me host processes
7 // running within user sessions. 7 // running within user sessions.
8 8
9 #include "remoting/host/win/unprivileged_process_delegate.h" 9 #include "remoting/host/win/unprivileged_process_delegate.h"
10 10
11 #include <sddl.h> 11 #include <sddl.h>
12 12
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/files/file.h" 16 #include "base/files/file.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/rand_util.h" 18 #include "base/rand_util.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
24 #include "base/win/scoped_handle.h" 24 #include "base/win/scoped_handle.h"
25 #include "ipc/attachment_broker.h"
26 #include "ipc/ipc_channel.h" 25 #include "ipc/ipc_channel.h"
27 #include "ipc/ipc_channel_proxy.h" 26 #include "ipc/ipc_channel_proxy.h"
28 #include "ipc/ipc_message.h" 27 #include "ipc/ipc_message.h"
29 #include "mojo/edk/embedder/embedder.h" 28 #include "mojo/edk/embedder/embedder.h"
30 #include "mojo/edk/embedder/platform_channel_pair.h" 29 #include "mojo/edk/embedder/platform_channel_pair.h"
31 #include "remoting/base/typed_buffer.h" 30 #include "remoting/base/typed_buffer.h"
32 #include "remoting/host/switches.h" 31 #include "remoting/host/switches.h"
33 #include "remoting/host/win/launch_process_with_token.h" 32 #include "remoting/host/win/launch_process_with_token.h"
34 #include "remoting/host/win/security_descriptor.h" 33 #include "remoting/host/win/security_descriptor.h"
35 #include "remoting/host/win/window_station_and_desktop.h" 34 #include "remoting/host/win/window_station_and_desktop.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 WindowStationAndDesktop handles; 279 WindowStationAndDesktop handles;
281 if (!CreateWindowStationAndDesktop(std::move(logon_sid), &handles)) { 280 if (!CreateWindowStationAndDesktop(std::move(logon_sid), &handles)) {
282 PLOG(ERROR) << "Failed to create a window station and desktop"; 281 PLOG(ERROR) << "Failed to create a window station and desktop";
283 ReportFatalError(); 282 ReportFatalError();
284 return; 283 return;
285 } 284 }
286 285
287 const std::string mojo_child_token = mojo::edk::GenerateRandomToken(); 286 const std::string mojo_child_token = mojo::edk::GenerateRandomToken();
288 const std::string mojo_message_pipe_token = mojo::edk::GenerateRandomToken(); 287 const std::string mojo_message_pipe_token = mojo::edk::GenerateRandomToken();
289 288
290 std::unique_ptr<IPC::ChannelProxy> server = 289 std::unique_ptr<IPC::ChannelProxy> server = IPC::ChannelProxy::Create(
291 base::MakeUnique<IPC::ChannelProxy>(this, io_task_runner_); 290 mojo::edk::CreateParentMessagePipe(mojo_message_pipe_token,
292 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( 291 mojo_child_token)
293 server.get(), io_task_runner_); 292 .release(),
294 server->Init(mojo::edk::CreateParentMessagePipe(mojo_message_pipe_token, 293 IPC::Channel::MODE_SERVER, this, io_task_runner_);
295 mojo_child_token)
296 .release(),
297 IPC::Channel::MODE_SERVER, /*create_pipe_now=*/true);
298 base::CommandLine command_line(target_command_->argv()); 294 base::CommandLine command_line(target_command_->argv());
299 command_line.AppendSwitchASCII(kMojoPipeToken, mojo_message_pipe_token); 295 command_line.AppendSwitchASCII(kMojoPipeToken, mojo_message_pipe_token);
300 296
301 base::HandlesToInheritVector handles_to_inherit = { 297 base::HandlesToInheritVector handles_to_inherit = {
302 handles.desktop(), handles.window_station(), 298 handles.desktop(), handles.window_station(),
303 }; 299 };
304 mojo::edk::PlatformChannelPair mojo_channel; 300 mojo::edk::PlatformChannelPair mojo_channel;
305 mojo_channel.PrepareToPassClientHandleToChildProcess(&command_line, 301 mojo_channel.PrepareToPassClientHandleToChildProcess(&command_line,
306 &handles_to_inherit); 302 &handles_to_inherit);
307 303
(...skipping 23 matching lines...) Expand all
331 327
332 if (channel_) { 328 if (channel_) {
333 channel_->Send(message); 329 channel_->Send(message);
334 } else { 330 } else {
335 delete message; 331 delete message;
336 } 332 }
337 } 333 }
338 334
339 void UnprivilegedProcessDelegate::CloseChannel() { 335 void UnprivilegedProcessDelegate::CloseChannel() {
340 DCHECK(CalledOnValidThread()); 336 DCHECK(CalledOnValidThread());
341
342 if (!channel_)
343 return;
344
345 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
346 channel_.get());
347 channel_.reset(); 337 channel_.reset();
348 } 338 }
349 339
350 void UnprivilegedProcessDelegate::KillProcess() { 340 void UnprivilegedProcessDelegate::KillProcess() {
351 DCHECK(CalledOnValidThread()); 341 DCHECK(CalledOnValidThread());
352 342
353 CloseChannel(); 343 CloseChannel();
354 event_handler_ = nullptr; 344 event_handler_ = nullptr;
355 345
356 if (worker_process_.IsValid()) { 346 if (worker_process_.IsValid()) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 PLOG(ERROR) << "Failed to duplicate a handle"; 405 PLOG(ERROR) << "Failed to duplicate a handle";
416 ReportFatalError(); 406 ReportFatalError();
417 return; 407 return;
418 } 408 }
419 ScopedHandle limited_handle(temp_handle); 409 ScopedHandle limited_handle(temp_handle);
420 410
421 event_handler_->OnProcessLaunched(std::move(limited_handle)); 411 event_handler_->OnProcessLaunched(std::move(limited_handle));
422 } 412 }
423 413
424 } // namespace remoting 414 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | remoting/host/win/wts_session_process_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698