OLD | NEW |
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 EXPECT_TRUE(event_handler_); | 336 EXPECT_TRUE(event_handler_); |
337 EXPECT_FALSE(worker_process_.IsValid()); | 337 EXPECT_FALSE(worker_process_.IsValid()); |
338 | 338 |
339 WCHAR notepad[MAX_PATH + 1]; | 339 WCHAR notepad[MAX_PATH + 1]; |
340 ASSERT_GT(ExpandEnvironmentStrings( | 340 ASSERT_GT(ExpandEnvironmentStrings( |
341 L"\045SystemRoot\045\\system32\\notepad.exe", notepad, MAX_PATH), 0u); | 341 L"\045SystemRoot\045\\system32\\notepad.exe", notepad, MAX_PATH), 0u); |
342 | 342 |
343 STARTUPINFOW startup_info = { 0 }; | 343 STARTUPINFOW startup_info = { 0 }; |
344 startup_info.cb = sizeof(startup_info); | 344 startup_info.cb = sizeof(startup_info); |
345 | 345 |
346 base::win::ScopedProcessInformation process_information; | 346 PROCESS_INFORMATION temp_process_info = {}; |
347 ASSERT_TRUE(CreateProcess(NULL, | 347 ASSERT_TRUE(CreateProcess(NULL, |
348 notepad, | 348 notepad, |
349 NULL, // default process attibutes | 349 NULL, // default process attibutes |
350 NULL, // default thread attibutes | 350 NULL, // default thread attibutes |
351 FALSE, // do not inherit handles | 351 FALSE, // do not inherit handles |
352 CREATE_SUSPENDED, | 352 CREATE_SUSPENDED, |
353 NULL, // no environment | 353 NULL, // no environment |
354 NULL, // default current directory | 354 NULL, // default current directory |
355 &startup_info, | 355 &startup_info, |
356 process_information.Receive())); | 356 &temp_process_info)); |
| 357 base::win::ScopedProcessInformation process_information(temp_process_info); |
357 worker_process_.Set(process_information.TakeProcessHandle()); | 358 worker_process_.Set(process_information.TakeProcessHandle()); |
358 ASSERT_TRUE(worker_process_.IsValid()); | 359 ASSERT_TRUE(worker_process_.IsValid()); |
359 | 360 |
360 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); | 361 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); |
361 ScopedHandle pipe; | 362 ScopedHandle pipe; |
362 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); | 363 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); |
363 | 364 |
364 // Wrap the pipe into an IPC channel. | 365 // Wrap the pipe into an IPC channel. |
365 channel_server_.reset(new IPC::ChannelProxy( | 366 channel_server_.reset(new IPC::ChannelProxy( |
366 IPC::ChannelHandle(pipe), | 367 IPC::ChannelHandle(pipe), |
367 IPC::Channel::MODE_SERVER, | 368 IPC::Channel::MODE_SERVER, |
368 this, | 369 this, |
369 task_runner_)); | 370 task_runner_)); |
370 | 371 |
371 ScopedHandle copy; | 372 HANDLE temp_handle; |
372 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), | 373 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), |
373 worker_process_, | 374 worker_process_, |
374 GetCurrentProcess(), | 375 GetCurrentProcess(), |
375 copy.Receive(), | 376 &temp_handle, |
376 0, | 377 0, |
377 FALSE, | 378 FALSE, |
378 DUPLICATE_SAME_ACCESS)); | 379 DUPLICATE_SAME_ACCESS)); |
| 380 ScopedHandle copy(temp_handle); |
379 | 381 |
380 event_handler_->OnProcessLaunched(copy.Pass()); | 382 event_handler_->OnProcessLaunched(copy.Pass()); |
381 } | 383 } |
382 | 384 |
383 TEST_F(WorkerProcessLauncherTest, Start) { | 385 TEST_F(WorkerProcessLauncherTest, Start) { |
384 EXPECT_CALL(*launcher_delegate_, LaunchProcess(_)) | 386 EXPECT_CALL(*launcher_delegate_, LaunchProcess(_)) |
385 .Times(1) | 387 .Times(1) |
386 .WillRepeatedly(Invoke(this, &WorkerProcessLauncherTest::LaunchProcess)); | 388 .WillRepeatedly(Invoke(this, &WorkerProcessLauncherTest::LaunchProcess)); |
387 | 389 |
388 EXPECT_CALL(server_listener_, OnChannelConnected(_)) | 390 EXPECT_CALL(server_listener_, OnChannelConnected(_)) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) | 527 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) |
526 .Times(1) | 528 .Times(1) |
527 .WillOnce(InvokeWithoutArgs( | 529 .WillOnce(InvokeWithoutArgs( |
528 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); | 530 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); |
529 | 531 |
530 StartWorker(); | 532 StartWorker(); |
531 message_loop_.Run(); | 533 message_loop_.Run(); |
532 } | 534 } |
533 | 535 |
534 } // namespace remoting | 536 } // namespace remoting |
OLD | NEW |