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

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

Issue 310853003: Add IPC::ChannelProxy::Create() and IPC::SyncChannel::Create() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Landing Created 6 years, 6 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
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | remoting/host/win/wts_session_process_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_, exit_code);
273 } 273 }
274 274
275 void WorkerProcessLauncherTest::ConnectClient() { 275 void WorkerProcessLauncherTest::ConnectClient() {
276 channel_client_.reset(new IPC::ChannelProxy( 276 channel_client_ = IPC::ChannelProxy::Create(IPC::ChannelHandle(channel_name_),
277 IPC::ChannelHandle(channel_name_), 277 IPC::Channel::MODE_CLIENT,
278 IPC::Channel::MODE_CLIENT, 278 &client_listener_,
279 &client_listener_, 279 task_runner_);
280 task_runner_));
281 280
282 // Pretend that |kLaunchSuccessTimeoutSeconds| passed since launching 281 // Pretend that |kLaunchSuccessTimeoutSeconds| passed since launching
283 // 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
284 // launch attempt was successful and it will not delay the next launch. 283 // launch attempt was successful and it will not delay the next launch.
285 launcher_->RecordSuccessfulLaunchForTest(); 284 launcher_->RecordSuccessfulLaunchForTest();
286 } 285 }
287 286
288 void WorkerProcessLauncherTest::DisconnectClient() { 287 void WorkerProcessLauncherTest::DisconnectClient() {
289 channel_client_.reset(); 288 channel_client_.reset();
290 } 289 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 &temp_process_info)); 353 &temp_process_info));
355 base::win::ScopedProcessInformation process_information(temp_process_info); 354 base::win::ScopedProcessInformation process_information(temp_process_info);
356 worker_process_.Set(process_information.TakeProcessHandle()); 355 worker_process_.Set(process_information.TakeProcessHandle());
357 ASSERT_TRUE(worker_process_.IsValid()); 356 ASSERT_TRUE(worker_process_.IsValid());
358 357
359 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); 358 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID();
360 ScopedHandle pipe; 359 ScopedHandle pipe;
361 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); 360 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe));
362 361
363 // Wrap the pipe into an IPC channel. 362 // Wrap the pipe into an IPC channel.
364 channel_server_.reset(new IPC::ChannelProxy( 363 channel_server_ = IPC::ChannelProxy::Create(
365 IPC::ChannelHandle(pipe), 364 IPC::ChannelHandle(pipe), IPC::Channel::MODE_SERVER, this, task_runner_);
366 IPC::Channel::MODE_SERVER,
367 this,
368 task_runner_));
369 365
370 HANDLE temp_handle; 366 HANDLE temp_handle;
371 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), 367 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(),
372 worker_process_, 368 worker_process_,
373 GetCurrentProcess(), 369 GetCurrentProcess(),
374 &temp_handle, 370 &temp_handle,
375 0, 371 0,
376 FALSE, 372 FALSE,
377 DUPLICATE_SAME_ACCESS)); 373 DUPLICATE_SAME_ACCESS));
378 ScopedHandle copy(temp_handle); 374 ScopedHandle copy(temp_handle);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) 521 EXPECT_CALL(client_listener_, OnCrash(_, _, _))
526 .Times(1) 522 .Times(1)
527 .WillOnce(InvokeWithoutArgs( 523 .WillOnce(InvokeWithoutArgs(
528 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); 524 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher));
529 525
530 StartWorker(); 526 StartWorker();
531 message_loop_.Run(); 527 message_loop_.Run();
532 } 528 }
533 529
534 } // namespace remoting 530 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.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