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

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

Issue 810133003: replace NULL->nullptr in src/remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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/win/wts_session_process_delegate.h" 8 #include "remoting/host/win/wts_session_process_delegate.h"
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 }; 142 };
143 143
144 WtsSessionProcessDelegate::Core::Core( 144 WtsSessionProcessDelegate::Core::Core(
145 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 145 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
146 scoped_ptr<base::CommandLine> target_command, 146 scoped_ptr<base::CommandLine> target_command,
147 bool launch_elevated, 147 bool launch_elevated,
148 const std::string& channel_security) 148 const std::string& channel_security)
149 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), 149 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()),
150 io_task_runner_(io_task_runner), 150 io_task_runner_(io_task_runner),
151 channel_security_(channel_security), 151 channel_security_(channel_security),
152 event_handler_(NULL), 152 event_handler_(nullptr),
153 get_named_pipe_client_pid_(NULL), 153 get_named_pipe_client_pid_(nullptr),
154 launch_elevated_(launch_elevated), 154 launch_elevated_(launch_elevated),
155 launch_pending_(false), 155 launch_pending_(false),
156 target_command_(target_command.Pass()) { 156 target_command_(target_command.Pass()) {
157 } 157 }
158 158
159 bool WtsSessionProcessDelegate::Core::Initialize(uint32 session_id) { 159 bool WtsSessionProcessDelegate::Core::Initialize(uint32 session_id) {
160 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 160 DCHECK(caller_task_runner_->BelongsToCurrentThread());
161 161
162 // Windows XP does not support elevation. 162 // Windows XP does not support elevation.
163 if (base::win::GetVersion() < base::win::VERSION_VISTA) 163 if (base::win::GetVersion() < base::win::VERSION_VISTA)
164 launch_elevated_ = false; 164 launch_elevated_ = false;
165 165
166 if (launch_elevated_) { 166 if (launch_elevated_) {
167 // GetNamedPipeClientProcessId() is available starting from Vista. 167 // GetNamedPipeClientProcessId() is available starting from Vista.
168 HMODULE kernel32 = ::GetModuleHandle(L"kernel32.dll"); 168 HMODULE kernel32 = ::GetModuleHandle(L"kernel32.dll");
169 CHECK(kernel32 != NULL); 169 CHECK(kernel32 != nullptr);
170 170
171 get_named_pipe_client_pid_ = 171 get_named_pipe_client_pid_ =
172 reinterpret_cast<GetNamedPipeClientProcessIdFn>( 172 reinterpret_cast<GetNamedPipeClientProcessIdFn>(
173 GetProcAddress(kernel32, "GetNamedPipeClientProcessId")); 173 GetProcAddress(kernel32, "GetNamedPipeClientProcessId"));
174 CHECK(get_named_pipe_client_pid_ != NULL); 174 CHECK(get_named_pipe_client_pid_ != nullptr);
175 175
176 ScopedHandle job; 176 ScopedHandle job;
177 job.Set(CreateJobObject(NULL, NULL)); 177 job.Set(CreateJobObject(nullptr, nullptr));
178 if (!job.IsValid()) { 178 if (!job.IsValid()) {
179 PLOG(ERROR) << "Failed to create a job object"; 179 PLOG(ERROR) << "Failed to create a job object";
180 return false; 180 return false;
181 } 181 }
182 182
183 // Limit the number of active processes in the job to two (the helper 183 // Limit the number of active processes in the job to two (the helper
184 // process performing elevation and the worker process itself) and make sure 184 // process performing elevation and the worker process itself) and make sure
185 // that all processes will be killed once the job object is destroyed. 185 // that all processes will be killed once the job object is destroyed.
186 JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; 186 JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
187 memset(&info, 0, sizeof(info)); 187 memset(&info, 0, sizeof(info));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 248 DCHECK(caller_task_runner_->BelongsToCurrentThread());
249 249
250 channel_.reset(); 250 channel_.reset();
251 pipe_.Close(); 251 pipe_.Close();
252 } 252 }
253 253
254 void WtsSessionProcessDelegate::Core::KillProcess() { 254 void WtsSessionProcessDelegate::Core::KillProcess() {
255 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 255 DCHECK(caller_task_runner_->BelongsToCurrentThread());
256 256
257 channel_.reset(); 257 channel_.reset();
258 event_handler_ = NULL; 258 event_handler_ = nullptr;
259 launch_pending_ = false; 259 launch_pending_ = false;
260 pipe_.Close(); 260 pipe_.Close();
261 261
262 if (launch_elevated_) { 262 if (launch_elevated_) {
263 if (job_.IsValid()) 263 if (job_.IsValid())
264 TerminateJobObject(job_.Get(), CONTROL_C_EXIT); 264 TerminateJobObject(job_.Get(), CONTROL_C_EXIT);
265 } else { 265 } else {
266 if (worker_process_.IsValid()) 266 if (worker_process_.IsValid())
267 TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT); 267 TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT);
268 } 268 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // Pass the name of the IPC channel to use. 388 // Pass the name of the IPC channel to use.
389 command_line.AppendSwitchNative(kDaemonPipeSwitchName, 389 command_line.AppendSwitchNative(kDaemonPipeSwitchName,
390 base::UTF8ToWide(channel_name)); 390 base::UTF8ToWide(channel_name));
391 391
392 // Try to launch the process. 392 // Try to launch the process.
393 ScopedHandle worker_process; 393 ScopedHandle worker_process;
394 ScopedHandle worker_thread; 394 ScopedHandle worker_thread;
395 if (!LaunchProcessWithToken(command_line.GetProgram(), 395 if (!LaunchProcessWithToken(command_line.GetProgram(),
396 command_line.GetCommandLineString(), 396 command_line.GetCommandLineString(),
397 session_token_.Get(), 397 session_token_.Get(),
398 NULL, 398 nullptr,
399 NULL, 399 nullptr,
400 false, 400 false,
401 CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB, 401 CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB,
402 base::UTF8ToUTF16(kDefaultDesktopName).c_str(), 402 base::UTF8ToUTF16(kDefaultDesktopName).c_str(),
403 &worker_process, 403 &worker_process,
404 &worker_thread)) { 404 &worker_thread)) {
405 ReportFatalError(); 405 ReportFatalError();
406 return; 406 return;
407 } 407 }
408 408
409 if (launch_elevated_) { 409 if (launch_elevated_) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 489 }
490 } 490 }
491 491
492 void WtsSessionProcessDelegate::Core::ReportFatalError() { 492 void WtsSessionProcessDelegate::Core::ReportFatalError() {
493 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 493 DCHECK(caller_task_runner_->BelongsToCurrentThread());
494 494
495 channel_.reset(); 495 channel_.reset();
496 pipe_.Close(); 496 pipe_.Close();
497 497
498 WorkerProcessLauncher* event_handler = event_handler_; 498 WorkerProcessLauncher* event_handler = event_handler_;
499 event_handler_ = NULL; 499 event_handler_ = nullptr;
500 event_handler->OnFatalError(); 500 event_handler->OnFatalError();
501 } 501 }
502 502
503 void WtsSessionProcessDelegate::Core::ReportProcessLaunched( 503 void WtsSessionProcessDelegate::Core::ReportProcessLaunched(
504 base::win::ScopedHandle worker_process) { 504 base::win::ScopedHandle worker_process) {
505 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 505 DCHECK(caller_task_runner_->BelongsToCurrentThread());
506 DCHECK(!worker_process_.IsValid()); 506 DCHECK(!worker_process_.IsValid());
507 507
508 worker_process_ = worker_process.Pass(); 508 worker_process_ = worker_process.Pass();
509 509
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 void WtsSessionProcessDelegate::CloseChannel() { 559 void WtsSessionProcessDelegate::CloseChannel() {
560 core_->CloseChannel(); 560 core_->CloseChannel();
561 } 561 }
562 562
563 void WtsSessionProcessDelegate::KillProcess() { 563 void WtsSessionProcessDelegate::KillProcess() {
564 core_->KillProcess(); 564 core_->KillProcess();
565 } 565 }
566 566
567 } // namespace remoting 567 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/worker_process_launcher_unittest.cc ('k') | remoting/protocol/audio_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698