| 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/test/multiprocess_test.h" | 9 #include "base/test/multiprocess_test.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 DCHECK(ok); | 403 DCHECK(ok); |
| 404 if (!ok) { | 404 if (!ok) { |
| 405 LOG(ERROR) << "Failed to open shared memory segment."; | 405 LOG(ERROR) << "Failed to open shared memory segment."; |
| 406 return -1; | 406 return -1; |
| 407 } | 407 } |
| 408 | 408 |
| 409 mem.Map(CrossProcessNotificationMultiProcessTest::kSharedMemSize); | 409 mem.Map(CrossProcessNotificationMultiProcessTest::kSharedMemSize); |
| 410 CrudeIpc* ipc = reinterpret_cast<CrudeIpc*>(mem.memory()); | 410 CrudeIpc* ipc = reinterpret_cast<CrudeIpc*>(mem.memory()); |
| 411 | 411 |
| 412 while (!ipc->ready) | 412 while (!ipc->ready) |
| 413 base::PlatformThread::Sleep(10); | 413 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); |
| 414 | 414 |
| 415 CrossProcessNotification notifier(ipc->handle_1, ipc->handle_2); | 415 CrossProcessNotification notifier(ipc->handle_1, ipc->handle_2); |
| 416 notifier.Wait(); | 416 notifier.Wait(); |
| 417 notifier.Signal(); | 417 notifier.Signal(); |
| 418 | 418 |
| 419 return 0; | 419 return 0; |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Spawns a new process and hands a CrossProcessNotification instance to the | 422 // Spawns a new process and hands a CrossProcessNotification instance to the |
| 423 // new process. Once that's done, it waits for the child process to signal | 423 // new process. Once that's done, it waits for the child process to signal |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 456 |
| 457 ipc->ready = true; | 457 ipc->ready = true; |
| 458 | 458 |
| 459 a.Signal(); | 459 a.Signal(); |
| 460 a.Wait(); | 460 a.Wait(); |
| 461 | 461 |
| 462 int exit_code = -1; | 462 int exit_code = -1; |
| 463 base::WaitForExitCode(process, &exit_code); | 463 base::WaitForExitCode(process, &exit_code); |
| 464 EXPECT_EQ(0, exit_code); | 464 EXPECT_EQ(0, exit_code); |
| 465 } | 465 } |
| OLD | NEW |