Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/scoped_file.h" | 14 #include "base/files/scoped_file.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/threading/platform_thread.h" // For |Sleep()|. | 20 #include "base/threading/platform_thread.h" // For |Sleep()|. |
| 21 #include "build/build_config.h" // TODO(vtl): Remove this. | 21 #include "build/build_config.h" // TODO(vtl): Remove this. |
| 22 #include "mojo/common/test/test_utils.h" | 22 #include "mojo/common/test/test_utils.h" |
| 23 #include "mojo/embedder/platform_channel_pair.h" | 23 #include "mojo/embedder/platform_channel_pair.h" |
| 24 #include "mojo/embedder/platform_shared_buffer.h" | 24 #include "mojo/embedder/platform_shared_buffer.h" |
| 25 #include "mojo/embedder/scoped_platform_handle.h" | 25 #include "mojo/embedder/scoped_platform_handle.h" |
| 26 #include "mojo/embedder/simple_platform_support.h" | 26 #include "mojo/embedder/simple_platform_support.h" |
| 27 #include "mojo/system/channel.h" | 27 #include "mojo/system/channel.h" |
| 28 #include "mojo/system/local_message_pipe_endpoint.h" | |
| 29 #include "mojo/system/message_pipe.h" | 28 #include "mojo/system/message_pipe.h" |
| 30 #include "mojo/system/message_pipe_dispatcher.h" | 29 #include "mojo/system/message_pipe_dispatcher.h" |
| 31 #include "mojo/system/platform_handle_dispatcher.h" | 30 #include "mojo/system/platform_handle_dispatcher.h" |
| 32 #include "mojo/system/proxy_message_pipe_endpoint.h" | |
| 33 #include "mojo/system/raw_channel.h" | 31 #include "mojo/system/raw_channel.h" |
| 34 #include "mojo/system/shared_buffer_dispatcher.h" | 32 #include "mojo/system/shared_buffer_dispatcher.h" |
| 35 #include "mojo/system/test_utils.h" | 33 #include "mojo/system/test_utils.h" |
| 36 #include "mojo/system/waiter.h" | 34 #include "mojo/system/waiter.h" |
| 37 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 38 | 36 |
| 39 namespace mojo { | 37 namespace mojo { |
| 40 namespace system { | 38 namespace system { |
| 41 namespace { | 39 namespace { |
| 42 | 40 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 char buffer[100] = {0}; | 184 char buffer[100] = {0}; |
| 187 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); | 185 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
| 188 Waiter waiter; | 186 Waiter waiter; |
| 189 HandleSignalsState hss; | 187 HandleSignalsState hss; |
| 190 uint32_t context = 0; | 188 uint32_t context = 0; |
| 191 | 189 |
| 192 // Connect message pipes. MP 0, port 1 will be attached to channel 0 and | 190 // Connect message pipes. MP 0, port 1 will be attached to channel 0 and |
| 193 // connected to MP 1, port 0, which will be attached to channel 1. This leaves | 191 // connected to MP 1, port 0, which will be attached to channel 1. This leaves |
| 194 // MP 0, port 0 and MP 1, port 1 as the "user-facing" endpoints. | 192 // MP 0, port 0 and MP 1, port 1 as the "user-facing" endpoints. |
| 195 | 193 |
| 196 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 194 scoped_refptr<MessagePipe> mp0(new MessagePipe(MessagePipe::LocalProxy())); |
| 197 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 195 scoped_refptr<MessagePipe> mp1(new MessagePipe(MessagePipe::ProxyLocal())); |
| 198 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 199 scoped_refptr<MessagePipe> mp1(new MessagePipe( | |
| 200 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 201 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 202 ConnectMessagePipes(mp0, mp1); | 196 ConnectMessagePipes(mp0, mp1); |
| 203 | 197 |
| 204 // Write in one direction: MP 0, port 0 -> ... -> MP 1, port 1. | 198 // Write in one direction: MP 0, port 0 -> ... -> MP 1, port 1. |
| 205 | 199 |
| 206 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do | 200 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do |
| 207 // it later, it might already be readable.) | 201 // it later, it might already be readable.) |
| 208 waiter.Init(); | 202 waiter.Init(); |
| 209 ASSERT_EQ(MOJO_RESULT_OK, | 203 ASSERT_EQ(MOJO_RESULT_OK, |
| 210 mp1->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, NULL)); | 204 mp1->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, NULL)); |
| 211 | 205 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 static const char kHello[] = "hello"; | 293 static const char kHello[] = "hello"; |
| 300 static const char kWorld[] = "world!!!1!!!1!"; | 294 static const char kWorld[] = "world!!!1!!!1!"; |
| 301 char buffer[100] = {0}; | 295 char buffer[100] = {0}; |
| 302 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); | 296 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
| 303 Waiter waiter; | 297 Waiter waiter; |
| 304 HandleSignalsState hss; | 298 HandleSignalsState hss; |
| 305 uint32_t context = 0; | 299 uint32_t context = 0; |
| 306 | 300 |
| 307 // Connect message pipes as in the |Basic| test. | 301 // Connect message pipes as in the |Basic| test. |
| 308 | 302 |
| 309 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 303 scoped_refptr<MessagePipe> mp0(new MessagePipe(MessagePipe::LocalProxy())); |
| 310 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 304 scoped_refptr<MessagePipe> mp1(new MessagePipe(MessagePipe::ProxyLocal())); |
| 311 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 312 scoped_refptr<MessagePipe> mp1(new MessagePipe( | |
| 313 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 314 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 315 ConnectMessagePipes(mp0, mp1); | 305 ConnectMessagePipes(mp0, mp1); |
| 316 | 306 |
| 317 // Now put another message pipe on the channel. | 307 // Now put another message pipe on the channel. |
| 318 | 308 |
| 319 scoped_refptr<MessagePipe> mp2(new MessagePipe( | 309 scoped_refptr<MessagePipe> mp2(new MessagePipe(MessagePipe::LocalProxy())); |
| 320 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 310 scoped_refptr<MessagePipe> mp3(new MessagePipe(MessagePipe::ProxyLocal())); |
| 321 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 322 scoped_refptr<MessagePipe> mp3(new MessagePipe( | |
| 323 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 324 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 325 ConnectMessagePipes(mp2, mp3); | 311 ConnectMessagePipes(mp2, mp3); |
| 326 | 312 |
| 327 // Write: MP 2, port 0 -> MP 3, port 1. | 313 // Write: MP 2, port 0 -> MP 3, port 1. |
| 328 | 314 |
| 329 waiter.Init(); | 315 waiter.Init(); |
| 330 ASSERT_EQ(MOJO_RESULT_OK, | 316 ASSERT_EQ(MOJO_RESULT_OK, |
| 331 mp3->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 789, NULL)); | 317 mp3->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 789, NULL)); |
| 332 | 318 |
| 333 EXPECT_EQ(MOJO_RESULT_OK, | 319 EXPECT_EQ(MOJO_RESULT_OK, |
| 334 mp2->WriteMessage(0, | 320 mp2->WriteMessage(0, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 char buffer[100] = {0}; | 440 char buffer[100] = {0}; |
| 455 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); | 441 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
| 456 Waiter waiter; | 442 Waiter waiter; |
| 457 HandleSignalsState hss; | 443 HandleSignalsState hss; |
| 458 uint32_t context = 0; | 444 uint32_t context = 0; |
| 459 | 445 |
| 460 // Connect message pipes. MP 0, port 1 will be attached to channel 0 and | 446 // Connect message pipes. MP 0, port 1 will be attached to channel 0 and |
| 461 // connected to MP 1, port 0, which will be attached to channel 1. This leaves | 447 // connected to MP 1, port 0, which will be attached to channel 1. This leaves |
| 462 // MP 0, port 0 and MP 1, port 1 as the "user-facing" endpoints. | 448 // MP 0, port 0 and MP 1, port 1 as the "user-facing" endpoints. |
| 463 | 449 |
| 464 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 450 scoped_refptr<MessagePipe> mp0(new MessagePipe(MessagePipe::LocalProxy())); |
| 465 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | |
| 466 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 467 | 451 |
| 468 // Write to MP 0, port 0. | 452 // Write to MP 0, port 0. |
| 469 EXPECT_EQ(MOJO_RESULT_OK, | 453 EXPECT_EQ(MOJO_RESULT_OK, |
| 470 mp0->WriteMessage(0, | 454 mp0->WriteMessage(0, |
| 471 UserPointer<const void>(kHello), | 455 UserPointer<const void>(kHello), |
| 472 sizeof(kHello), | 456 sizeof(kHello), |
| 473 NULL, | 457 NULL, |
| 474 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 458 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 475 | 459 |
| 476 BootstrapMessagePipeNoWait(0, mp0); | 460 BootstrapMessagePipeNoWait(0, mp0); |
| 477 | 461 |
| 478 // Close MP 0, port 0 before channel 1 is even connected. | 462 // Close MP 0, port 0 before channel 1 is even connected. |
| 479 mp0->Close(0); | 463 mp0->Close(0); |
| 480 | 464 |
| 481 scoped_refptr<MessagePipe> mp1(new MessagePipe( | 465 scoped_refptr<MessagePipe> mp1(new MessagePipe(MessagePipe::ProxyLocal())); |
| 482 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 483 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 484 | 466 |
| 485 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do | 467 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do |
| 486 // it later, it might already be readable.) | 468 // it later, it might already be readable.) |
| 487 waiter.Init(); | 469 waiter.Init(); |
| 488 ASSERT_EQ(MOJO_RESULT_OK, | 470 ASSERT_EQ(MOJO_RESULT_OK, |
| 489 mp1->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, NULL)); | 471 mp1->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, NULL)); |
| 490 | 472 |
| 491 BootstrapMessagePipeNoWait(1, mp1); | 473 BootstrapMessagePipeNoWait(1, mp1); |
| 492 | 474 |
| 493 // Wait. | 475 // Wait. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 516 // And MP 1, port 1. | 498 // And MP 1, port 1. |
| 517 mp1->Close(1); | 499 mp1->Close(1); |
| 518 } | 500 } |
| 519 | 501 |
| 520 TEST_F(RemoteMessagePipeTest, HandlePassing) { | 502 TEST_F(RemoteMessagePipeTest, HandlePassing) { |
| 521 static const char kHello[] = "hello"; | 503 static const char kHello[] = "hello"; |
| 522 Waiter waiter; | 504 Waiter waiter; |
| 523 HandleSignalsState hss; | 505 HandleSignalsState hss; |
| 524 uint32_t context = 0; | 506 uint32_t context = 0; |
| 525 | 507 |
| 526 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 508 scoped_refptr<MessagePipe> mp0(new MessagePipe(MessagePipe::LocalProxy())); |
|
darin (slow to review)
2014/08/25 21:56:58
Had you considered a static constructor like Messa
| |
| 527 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 509 scoped_refptr<MessagePipe> mp1(new MessagePipe(MessagePipe::ProxyLocal())); |
| 528 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 529 scoped_refptr<MessagePipe> mp1(new MessagePipe( | |
| 530 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 531 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 532 ConnectMessagePipes(mp0, mp1); | 510 ConnectMessagePipes(mp0, mp1); |
| 533 | 511 |
| 534 // We'll try to pass this dispatcher. | 512 // We'll try to pass this dispatcher. |
| 535 scoped_refptr<MessagePipeDispatcher> dispatcher( | 513 scoped_refptr<MessagePipeDispatcher> dispatcher( |
| 536 new MessagePipeDispatcher(MessagePipeDispatcher::kDefaultCreateOptions)); | 514 new MessagePipeDispatcher(MessagePipeDispatcher::kDefaultCreateOptions)); |
| 537 scoped_refptr<MessagePipe> local_mp(new MessagePipe()); | 515 scoped_refptr<MessagePipe> local_mp( |
| 516 new MessagePipe(MessagePipe::LocalLocal())); | |
| 538 dispatcher->Init(local_mp, 0); | 517 dispatcher->Init(local_mp, 0); |
| 539 | 518 |
| 540 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do | 519 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do |
| 541 // it later, it might already be readable.) | 520 // it later, it might already be readable.) |
| 542 waiter.Init(); | 521 waiter.Init(); |
| 543 ASSERT_EQ(MOJO_RESULT_OK, | 522 ASSERT_EQ(MOJO_RESULT_OK, |
| 544 mp1->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, NULL)); | 523 mp1->AddWaiter(1, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, NULL)); |
| 545 | 524 |
| 546 // Write to MP 0, port 0. | 525 // Write to MP 0, port 0. |
| 547 { | 526 { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 #else | 667 #else |
| 689 // Not yet implemented (on Windows). | 668 // Not yet implemented (on Windows). |
| 690 #define MAYBE_SharedBufferPassing DISABLED_SharedBufferPassing | 669 #define MAYBE_SharedBufferPassing DISABLED_SharedBufferPassing |
| 691 #endif | 670 #endif |
| 692 TEST_F(RemoteMessagePipeTest, MAYBE_SharedBufferPassing) { | 671 TEST_F(RemoteMessagePipeTest, MAYBE_SharedBufferPassing) { |
| 693 static const char kHello[] = "hello"; | 672 static const char kHello[] = "hello"; |
| 694 Waiter waiter; | 673 Waiter waiter; |
| 695 HandleSignalsState hss; | 674 HandleSignalsState hss; |
| 696 uint32_t context = 0; | 675 uint32_t context = 0; |
| 697 | 676 |
| 698 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 677 scoped_refptr<MessagePipe> mp0(new MessagePipe(MessagePipe::LocalProxy())); |
| 699 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 678 scoped_refptr<MessagePipe> mp1(new MessagePipe(MessagePipe::ProxyLocal())); |
| 700 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 701 scoped_refptr<MessagePipe> mp1(new MessagePipe( | |
| 702 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 703 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 704 ConnectMessagePipes(mp0, mp1); | 679 ConnectMessagePipes(mp0, mp1); |
| 705 | 680 |
| 706 // We'll try to pass this dispatcher. | 681 // We'll try to pass this dispatcher. |
| 707 scoped_refptr<SharedBufferDispatcher> dispatcher; | 682 scoped_refptr<SharedBufferDispatcher> dispatcher; |
| 708 EXPECT_EQ(MOJO_RESULT_OK, | 683 EXPECT_EQ(MOJO_RESULT_OK, |
| 709 SharedBufferDispatcher::Create( | 684 SharedBufferDispatcher::Create( |
| 710 platform_support(), | 685 platform_support(), |
| 711 SharedBufferDispatcher::kDefaultCreateOptions, | 686 SharedBufferDispatcher::kDefaultCreateOptions, |
| 712 100, | 687 100, |
| 713 &dispatcher)); | 688 &dispatcher)); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 TEST_F(RemoteMessagePipeTest, MAYBE_PlatformHandlePassing) { | 801 TEST_F(RemoteMessagePipeTest, MAYBE_PlatformHandlePassing) { |
| 827 base::ScopedTempDir temp_dir; | 802 base::ScopedTempDir temp_dir; |
| 828 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 803 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 829 | 804 |
| 830 static const char kHello[] = "hello"; | 805 static const char kHello[] = "hello"; |
| 831 static const char kWorld[] = "world"; | 806 static const char kWorld[] = "world"; |
| 832 Waiter waiter; | 807 Waiter waiter; |
| 833 uint32_t context = 0; | 808 uint32_t context = 0; |
| 834 HandleSignalsState hss; | 809 HandleSignalsState hss; |
| 835 | 810 |
| 836 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 811 scoped_refptr<MessagePipe> mp0(new MessagePipe(MessagePipe::LocalProxy())); |
| 837 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 812 scoped_refptr<MessagePipe> mp1(new MessagePipe(MessagePipe::ProxyLocal())); |
| 838 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 839 scoped_refptr<MessagePipe> mp1(new MessagePipe( | |
| 840 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 841 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 842 ConnectMessagePipes(mp0, mp1); | 813 ConnectMessagePipes(mp0, mp1); |
| 843 | 814 |
| 844 base::FilePath unused; | 815 base::FilePath unused; |
| 845 base::ScopedFILE fp( | 816 base::ScopedFILE fp( |
| 846 CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused)); | 817 CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused)); |
| 847 EXPECT_EQ(sizeof(kHello), fwrite(kHello, 1, sizeof(kHello), fp.get())); | 818 EXPECT_EQ(sizeof(kHello), fwrite(kHello, 1, sizeof(kHello), fp.get())); |
| 848 // We'll try to pass this dispatcher, which will cause a |PlatformHandle| to | 819 // We'll try to pass this dispatcher, which will cause a |PlatformHandle| to |
| 849 // be passed. | 820 // be passed. |
| 850 scoped_refptr<PlatformHandleDispatcher> dispatcher( | 821 scoped_refptr<PlatformHandleDispatcher> dispatcher( |
| 851 new PlatformHandleDispatcher( | 822 new PlatformHandleDispatcher( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 | 904 |
| 934 // Test racing closes (on each end). | 905 // Test racing closes (on each end). |
| 935 // Note: A flaky failure would almost certainly indicate a problem in the code | 906 // Note: A flaky failure would almost certainly indicate a problem in the code |
| 936 // itself (not in the test). Also, any logged warnings/errors would also | 907 // itself (not in the test). Also, any logged warnings/errors would also |
| 937 // probably be indicative of bugs. | 908 // probably be indicative of bugs. |
| 938 TEST_F(RemoteMessagePipeTest, RacingClosesStress) { | 909 TEST_F(RemoteMessagePipeTest, RacingClosesStress) { |
| 939 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(5); | 910 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(5); |
| 940 | 911 |
| 941 for (unsigned i = 0; i < 256; i++) { | 912 for (unsigned i = 0; i < 256; i++) { |
| 942 DVLOG(2) << "---------------------------------------- " << i; | 913 DVLOG(2) << "---------------------------------------- " << i; |
| 943 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 914 scoped_refptr<MessagePipe> mp0(new MessagePipe(MessagePipe::LocalProxy())); |
| 944 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | |
| 945 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | |
| 946 BootstrapMessagePipeNoWait(0, mp0); | 915 BootstrapMessagePipeNoWait(0, mp0); |
| 947 | 916 |
| 948 scoped_refptr<MessagePipe> mp1(new MessagePipe( | 917 scoped_refptr<MessagePipe> mp1(new MessagePipe(MessagePipe::ProxyLocal())); |
| 949 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | |
| 950 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | |
| 951 BootstrapMessagePipeNoWait(1, mp1); | 918 BootstrapMessagePipeNoWait(1, mp1); |
| 952 | 919 |
| 953 if (i & 1u) { | 920 if (i & 1u) { |
| 954 io_thread()->task_runner()->PostTask( | 921 io_thread()->task_runner()->PostTask( |
| 955 FROM_HERE, base::Bind(&base::PlatformThread::Sleep, delay)); | 922 FROM_HERE, base::Bind(&base::PlatformThread::Sleep, delay)); |
| 956 } | 923 } |
| 957 if (i & 2u) | 924 if (i & 2u) |
| 958 base::PlatformThread::Sleep(delay); | 925 base::PlatformThread::Sleep(delay); |
| 959 | 926 |
| 960 mp0->Close(0); | 927 mp0->Close(0); |
| 961 | 928 |
| 962 if (i & 4u) { | 929 if (i & 4u) { |
| 963 io_thread()->task_runner()->PostTask( | 930 io_thread()->task_runner()->PostTask( |
| 964 FROM_HERE, base::Bind(&base::PlatformThread::Sleep, delay)); | 931 FROM_HERE, base::Bind(&base::PlatformThread::Sleep, delay)); |
| 965 } | 932 } |
| 966 if (i & 8u) | 933 if (i & 8u) |
| 967 base::PlatformThread::Sleep(delay); | 934 base::PlatformThread::Sleep(delay); |
| 968 | 935 |
| 969 mp1->Close(1); | 936 mp1->Close(1); |
| 970 | 937 |
| 971 RestoreInitialState(); | 938 RestoreInitialState(); |
| 972 } | 939 } |
| 973 } | 940 } |
| 974 | 941 |
| 975 } // namespace | 942 } // namespace |
| 976 } // namespace system | 943 } // namespace system |
| 977 } // namespace mojo | 944 } // namespace mojo |
| OLD | NEW |