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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ = IPC::ChannelProxy::CreateClient( | 276 channel_client_.reset(new IPC::ChannelProxy( |
277 IPC::ChannelHandle(channel_name_), | 277 IPC::ChannelHandle(channel_name_), |
| 278 IPC::Channel::MODE_CLIENT, |
278 &client_listener_, | 279 &client_listener_, |
279 task_runner_); | 280 task_runner_)); |
280 | 281 |
281 // Pretend that |kLaunchSuccessTimeoutSeconds| passed since launching | 282 // Pretend that |kLaunchSuccessTimeoutSeconds| passed since launching |
282 // the worker process. This will make the backoff algorithm think that this | 283 // the worker process. This will make the backoff algorithm think that this |
283 // launch attempt was successful and it will not delay the next launch. | 284 // launch attempt was successful and it will not delay the next launch. |
284 launcher_->RecordSuccessfulLaunchForTest(); | 285 launcher_->RecordSuccessfulLaunchForTest(); |
285 } | 286 } |
286 | 287 |
287 void WorkerProcessLauncherTest::DisconnectClient() { | 288 void WorkerProcessLauncherTest::DisconnectClient() { |
288 channel_client_.reset(); | 289 channel_client_.reset(); |
289 } | 290 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 &temp_process_info)); | 354 &temp_process_info)); |
354 base::win::ScopedProcessInformation process_information(temp_process_info); | 355 base::win::ScopedProcessInformation process_information(temp_process_info); |
355 worker_process_.Set(process_information.TakeProcessHandle()); | 356 worker_process_.Set(process_information.TakeProcessHandle()); |
356 ASSERT_TRUE(worker_process_.IsValid()); | 357 ASSERT_TRUE(worker_process_.IsValid()); |
357 | 358 |
358 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); | 359 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); |
359 ScopedHandle pipe; | 360 ScopedHandle pipe; |
360 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); | 361 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); |
361 | 362 |
362 // Wrap the pipe into an IPC channel. | 363 // Wrap the pipe into an IPC channel. |
363 channel_server_ = IPC::ChannelProxy::CreateServer( | 364 channel_server_.reset(new IPC::ChannelProxy( |
364 IPC::ChannelHandle(pipe), | 365 IPC::ChannelHandle(pipe), |
| 366 IPC::Channel::MODE_SERVER, |
365 this, | 367 this, |
366 task_runner_); | 368 task_runner_)); |
367 | 369 |
368 HANDLE temp_handle; | 370 HANDLE temp_handle; |
369 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), | 371 ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), |
370 worker_process_, | 372 worker_process_, |
371 GetCurrentProcess(), | 373 GetCurrentProcess(), |
372 &temp_handle, | 374 &temp_handle, |
373 0, | 375 0, |
374 FALSE, | 376 FALSE, |
375 DUPLICATE_SAME_ACCESS)); | 377 DUPLICATE_SAME_ACCESS)); |
376 ScopedHandle copy(temp_handle); | 378 ScopedHandle copy(temp_handle); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) | 525 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) |
524 .Times(1) | 526 .Times(1) |
525 .WillOnce(InvokeWithoutArgs( | 527 .WillOnce(InvokeWithoutArgs( |
526 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); | 528 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); |
527 | 529 |
528 StartWorker(); | 530 StartWorker(); |
529 message_loop_.Run(); | 531 message_loop_.Run(); |
530 } | 532 } |
531 | 533 |
532 } // namespace remoting | 534 } // namespace remoting |
OLD | NEW |