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

Side by Side Diff: remoting/host/win/wts_console_session_process_driver.cc

Issue 15077010: [Chromoting] Refactored worker process launching code and speeded up the desktop process launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 7 months 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 | Annotate | Revision Log
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 #include "remoting/host/win/wts_console_session_process_driver.h" 5 #include "remoting/host/win/wts_console_session_process_driver.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/win/windows_version.h"
12 #include "ipc/ipc_message.h" 13 #include "ipc/ipc_message.h"
13 #include "ipc/ipc_message_macros.h" 14 #include "ipc/ipc_message_macros.h"
14 #include "remoting/host/chromoting_messages.h" 15 #include "remoting/host/chromoting_messages.h"
15 #include "remoting/host/host_main.h" 16 #include "remoting/host/host_main.h"
16 #include "remoting/host/ipc_constants.h" 17 #include "remoting/host/ipc_constants.h"
17 #include "remoting/host/sas_injector.h" 18 #include "remoting/host/sas_injector.h"
18 #include "remoting/host/win/worker_process_launcher.h" 19 #include "remoting/host/win/worker_process_launcher.h"
19 #include "remoting/host/win/wts_session_process_delegate.h" 20 #include "remoting/host/win/wts_session_process_delegate.h"
20 #include "remoting/host/win/wts_terminal_monitor.h" 21 #include "remoting/host/win/wts_terminal_monitor.h"
21 22
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 83
83 void WtsConsoleSessionProcessDriver::OnSessionAttached(uint32 session_id) { 84 void WtsConsoleSessionProcessDriver::OnSessionAttached(uint32 session_id) {
84 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 85 DCHECK(caller_task_runner_->BelongsToCurrentThread());
85 86
86 if (stoppable_state() != Stoppable::kRunning) { 87 if (stoppable_state() != Stoppable::kRunning) {
87 return; 88 return;
88 } 89 }
89 90
90 DCHECK(launcher_.get() == NULL); 91 DCHECK(launcher_.get() == NULL);
91 92
92 // Get the host binary name. 93 // Launch elevated on Win8 to be able to inject Alt+Tab.
94 bool launch_elevated = base::win::GetVersion() >= base::win::VERSION_WIN8;
95
96 // Get the name of the executable to run. |kDesktopBinaryName| specifies
97 // uiAccess="true" in it's manifest.
93 base::FilePath desktop_binary; 98 base::FilePath desktop_binary;
94 if (!GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary)) { 99 bool result;
100 if (launch_elevated) {
101 result = GetInstalledBinaryPath(kDesktopBinaryName, &desktop_binary);
102 } else {
103 result = GetInstalledBinaryPath(kHostBinaryName, &desktop_binary);
104 }
105
106 if (!result) {
95 Stop(); 107 Stop();
96 return; 108 return;
97 } 109 }
98 110
99 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary)); 111 scoped_ptr<CommandLine> target(new CommandLine(desktop_binary));
100 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeHost); 112 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeHost);
101 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(), 113 target->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
102 kCopiedSwitchNames, 114 kCopiedSwitchNames,
103 arraysize(kCopiedSwitchNames)); 115 arraysize(kCopiedSwitchNames));
104 116
105 // Create a Delegate capable of launching an elevated process in the session. 117 // Create a Delegate capable of launching an elevated process in the session.
106 scoped_ptr<WtsSessionProcessDelegate> delegate( 118 scoped_ptr<WtsSessionProcessDelegate> delegate(
107 new WtsSessionProcessDelegate(caller_task_runner_, 119 new WtsSessionProcessDelegate(io_task_runner_,
108 io_task_runner_,
109 target.Pass(), 120 target.Pass(),
110 session_id, 121 launch_elevated,
111 true,
112 kDaemonIpcSecurityDescriptor)); 122 kDaemonIpcSecurityDescriptor));
123 if (!delegate->Initialize(session_id)) {
124 Stop();
125 return;
126 }
113 127
114 // Use the Delegate to launch the host process. 128 // Use the Delegate to launch the host process.
115 launcher_.reset(new WorkerProcessLauncher( 129 launcher_.reset(new WorkerProcessLauncher(delegate.Pass(), this));
116 caller_task_runner_, delegate.Pass(), this));
117 } 130 }
118 131
119 void WtsConsoleSessionProcessDriver::OnSessionDetached() { 132 void WtsConsoleSessionProcessDriver::OnSessionDetached() {
120 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 133 DCHECK(caller_task_runner_->BelongsToCurrentThread());
121 DCHECK(launcher_.get() != NULL); 134 DCHECK(launcher_.get() != NULL);
122 135
123 launcher_.reset(); 136 launcher_.reset();
124 } 137 }
125 138
126 void WtsConsoleSessionProcessDriver::DoStop() { 139 void WtsConsoleSessionProcessDriver::DoStop() {
127 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 140 DCHECK(caller_task_runner_->BelongsToCurrentThread());
128 141
129 launcher_.reset(); 142 launcher_.reset();
130 CompleteStopping(); 143 CompleteStopping();
131 } 144 }
132 145
133 void WtsConsoleSessionProcessDriver::OnSendSasToConsole() { 146 void WtsConsoleSessionProcessDriver::OnSendSasToConsole() {
134 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 147 DCHECK(caller_task_runner_->BelongsToCurrentThread());
135 148
136 if (!launcher_) 149 if (!launcher_)
137 return; 150 return;
138 151
139 if (!sas_injector_) 152 if (!sas_injector_)
140 sas_injector_ = SasInjector::Create(); 153 sas_injector_ = SasInjector::Create();
141 if (!sas_injector_->InjectSas()) 154 if (!sas_injector_->InjectSas())
142 LOG(ERROR) << "Failed to inject Secure Attention Sequence."; 155 LOG(ERROR) << "Failed to inject Secure Attention Sequence.";
143 } 156 }
144 157
145 } // namespace remoting 158 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/worker_process_launcher_unittest.cc ('k') | remoting/host/win/wts_session_process_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698