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

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

Issue 602763003: Remove implicit HANDLE conversions from remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/win/scoped_handle.h" 9 #include "base/win/scoped_handle.h"
10 #include "base/win/scoped_process_information.h" 10 #include "base/win/scoped_process_information.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 task_runner_->PostTask( 255 task_runner_->PostTask(
256 FROM_HERE, 256 FROM_HERE,
257 base::Bind(&WorkerProcessLauncherTest::StopWorker, 257 base::Bind(&WorkerProcessLauncherTest::StopWorker,
258 base::Unretained(this))); 258 base::Unretained(this)));
259 } 259 }
260 260
261 void WorkerProcessLauncherTest::KillProcess() { 261 void WorkerProcessLauncherTest::KillProcess() {
262 event_handler_ = NULL; 262 event_handler_ = NULL;
263 263
264 if (worker_process_.IsValid()) { 264 if (worker_process_.IsValid()) {
265 TerminateProcess(worker_process_, CONTROL_C_EXIT); 265 TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT);
266 worker_process_.Close(); 266 worker_process_.Close();
267 } 267 }
268 } 268 }
269 269
270 void WorkerProcessLauncherTest::TerminateWorker(DWORD exit_code) { 270 void WorkerProcessLauncherTest::TerminateWorker(DWORD exit_code) {
271 if (worker_process_.IsValid()) 271 if (worker_process_.IsValid())
272 TerminateProcess(worker_process_, exit_code); 272 TerminateProcess(worker_process_.Get(), exit_code);
273 } 273 }
274 274
275 void WorkerProcessLauncherTest::ConnectClient() { 275 void WorkerProcessLauncherTest::ConnectClient() {
276 channel_client_ = IPC::ChannelProxy::Create(IPC::ChannelHandle(channel_name_), 276 channel_client_ = IPC::ChannelProxy::Create(IPC::ChannelHandle(channel_name_),
277 IPC::Channel::MODE_CLIENT, 277 IPC::Channel::MODE_CLIENT,
278 &client_listener_, 278 &client_listener_,
279 task_runner_); 279 task_runner_);
280 280
281 // Pretend that |kLaunchSuccessTimeoutSeconds| passed since launching 281 // Pretend that |kLaunchSuccessTimeoutSeconds| passed since launching
282 // the worker process. This will make the backoff algorithm think that this 282 // the worker process. This will make the backoff algorithm think that this
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 base::win::ScopedProcessInformation process_information(temp_process_info); 355 base::win::ScopedProcessInformation process_information(temp_process_info);
356 worker_process_.Set(process_information.TakeProcessHandle()); 356 worker_process_.Set(process_information.TakeProcessHandle());
357 ASSERT_TRUE(worker_process_.IsValid()); 357 ASSERT_TRUE(worker_process_.IsValid());
358 358
359 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); 359 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID();
360 ScopedHandle pipe; 360 ScopedHandle pipe;
361 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); 361 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe));
362 362
363 // Wrap the pipe into an IPC channel. 363 // Wrap the pipe into an IPC channel.
364 channel_server_ = IPC::ChannelProxy::Create( 364 channel_server_ = IPC::ChannelProxy::Create(
365 IPC::ChannelHandle(pipe), IPC::Channel::MODE_SERVER, this, task_runner_); 365 IPC::ChannelHandle(pipe.Get()), IPC::Channel::MODE_SERVER, this,
366 task_runner_);
366 367
367 HANDLE temp_handle; 368 HANDLE temp_handle;
368 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), 369 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(),
369 worker_process_, 370 worker_process_.Get(),
370 GetCurrentProcess(), 371 GetCurrentProcess(),
371 &temp_handle, 372 &temp_handle,
372 0, 373 0,
373 FALSE, 374 FALSE,
374 DUPLICATE_SAME_ACCESS)); 375 DUPLICATE_SAME_ACCESS));
375 ScopedHandle copy(temp_handle); 376 ScopedHandle copy(temp_handle);
376 377
377 event_handler_->OnProcessLaunched(copy.Pass()); 378 event_handler_->OnProcessLaunched(copy.Pass());
378 } 379 }
379 380
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) 523 EXPECT_CALL(client_listener_, OnCrash(_, _, _))
523 .Times(1) 524 .Times(1)
524 .WillOnce(InvokeWithoutArgs( 525 .WillOnce(InvokeWithoutArgs(
525 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); 526 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher));
526 527
527 StartWorker(); 528 StartWorker();
528 message_loop_.Run(); 529 message_loop_.Run();
529 } 530 }
530 531
531 } // namespace remoting 532 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/worker_process_launcher.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