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

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

Issue 90963002: Revert of Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 "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
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 PROCESS_INFORMATION temp_process_info = {}; 346 base::win::ScopedProcessInformation process_information;
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 &temp_process_info)); 356 process_information.Receive()));
357 base::win::ScopedProcessInformation process_information(temp_process_info);
358 worker_process_.Set(process_information.TakeProcessHandle()); 357 worker_process_.Set(process_information.TakeProcessHandle());
359 ASSERT_TRUE(worker_process_.IsValid()); 358 ASSERT_TRUE(worker_process_.IsValid());
360 359
361 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); 360 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID();
362 ScopedHandle pipe; 361 ScopedHandle pipe;
363 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); 362 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe));
364 363
365 // Wrap the pipe into an IPC channel. 364 // Wrap the pipe into an IPC channel.
366 channel_server_.reset(new IPC::ChannelProxy( 365 channel_server_.reset(new IPC::ChannelProxy(
367 IPC::ChannelHandle(pipe), 366 IPC::ChannelHandle(pipe),
368 IPC::Channel::MODE_SERVER, 367 IPC::Channel::MODE_SERVER,
369 this, 368 this,
370 task_runner_)); 369 task_runner_));
371 370
372 HANDLE temp_handle; 371 ScopedHandle copy;
373 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), 372 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(),
374 worker_process_, 373 worker_process_,
375 GetCurrentProcess(), 374 GetCurrentProcess(),
376 &temp_handle, 375 copy.Receive(),
377 0, 376 0,
378 FALSE, 377 FALSE,
379 DUPLICATE_SAME_ACCESS)); 378 DUPLICATE_SAME_ACCESS));
380 ScopedHandle copy(temp_handle);
381 379
382 event_handler_->OnProcessLaunched(copy.Pass()); 380 event_handler_->OnProcessLaunched(copy.Pass());
383 } 381 }
384 382
385 TEST_F(WorkerProcessLauncherTest, Start) { 383 TEST_F(WorkerProcessLauncherTest, Start) {
386 EXPECT_CALL(*launcher_delegate_, LaunchProcess(_)) 384 EXPECT_CALL(*launcher_delegate_, LaunchProcess(_))
387 .Times(1) 385 .Times(1)
388 .WillRepeatedly(Invoke(this, &WorkerProcessLauncherTest::LaunchProcess)); 386 .WillRepeatedly(Invoke(this, &WorkerProcessLauncherTest::LaunchProcess));
389 387
390 EXPECT_CALL(server_listener_, OnChannelConnected(_)) 388 EXPECT_CALL(server_listener_, OnChannelConnected(_))
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) 525 EXPECT_CALL(client_listener_, OnCrash(_, _, _))
528 .Times(1) 526 .Times(1)
529 .WillOnce(InvokeWithoutArgs( 527 .WillOnce(InvokeWithoutArgs(
530 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); 528 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher));
531 529
532 StartWorker(); 530 StartWorker();
533 message_loop_.Run(); 531 message_loop_.Run();
534 } 532 }
535 533
536 } // namespace remoting 534 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/unprivileged_process_delegate.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