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

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

Issue 301973003: Introduce IPC::ChannelProxy::Create*() and IPC::SynChannel::Create*() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing mac build 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') | tools/ipc_fuzzer/replay/replay_process.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::CreateClient(
277 IPC::ChannelHandle(channel_name_), 277 IPC::ChannelHandle(channel_name_),
278 IPC::Channel::MODE_CLIENT,
279 &client_listener_, 278 &client_listener_,
280 task_runner_)); 279 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::CreateServer(
365 IPC::ChannelHandle(pipe), 364 IPC::ChannelHandle(pipe),
366 IPC::Channel::MODE_SERVER,
367 this, 365 this,
368 task_runner_)); 366 task_runner_);
369 367
370 HANDLE temp_handle; 368 HANDLE temp_handle;
371 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), 369 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(),
372 worker_process_, 370 worker_process_,
373 GetCurrentProcess(), 371 GetCurrentProcess(),
374 &temp_handle, 372 &temp_handle,
375 0, 373 0,
376 FALSE, 374 FALSE,
377 DUPLICATE_SAME_ACCESS)); 375 DUPLICATE_SAME_ACCESS));
378 ScopedHandle copy(temp_handle); 376 ScopedHandle copy(temp_handle);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) 523 EXPECT_CALL(client_listener_, OnCrash(_, _, _))
526 .Times(1) 524 .Times(1)
527 .WillOnce(InvokeWithoutArgs( 525 .WillOnce(InvokeWithoutArgs(
528 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); 526 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher));
529 527
530 StartWorker(); 528 StartWorker();
531 message_loop_.Run(); 529 message_loop_.Run();
532 } 530 }
533 531
534 } // namespace remoting 532 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/remoting_me2me_host.cc ('k') | tools/ipc_fuzzer/replay/replay_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698