| 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 "mojo/edk/system/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 // The start of the received data should always be on a message boundary. | 185 // The start of the received data should always be on a message boundary. |
| 186 std::vector<unsigned char> bytes_; | 186 std::vector<unsigned char> bytes_; |
| 187 | 187 |
| 188 MOJO_DISALLOW_COPY_AND_ASSIGN(TestMessageReaderAndChecker); | 188 MOJO_DISALLOW_COPY_AND_ASSIGN(TestMessageReaderAndChecker); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 // Tests writing (and verifies reading using our own custom reader). | 191 // Tests writing (and verifies reading using our own custom reader). |
| 192 TEST_F(RawChannelTest, WriteMessage) { | 192 TEST_F(RawChannelTest, WriteMessage) { |
| 193 WriteOnlyRawChannelDelegate delegate; | 193 WriteOnlyRawChannelDelegate delegate; |
| 194 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 194 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 195 TestMessageReaderAndChecker checker(handles[1].get()); | 195 TestMessageReaderAndChecker checker(handles[1].get()); |
| 196 io_thread()->PostTaskAndWait( | 196 io_thread()->PostTaskAndWait( |
| 197 FROM_HERE, | 197 FROM_HERE, |
| 198 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 198 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 199 | 199 |
| 200 // Write and read, for a variety of sizes. | 200 // Write and read, for a variety of sizes. |
| 201 for (uint32_t size = 1; size < 5 * 1000 * 1000; size += size / 2 + 1) { | 201 for (uint32_t size = 1; size < 5 * 1000 * 1000; size += size / 2 + 1) { |
| 202 EXPECT_TRUE(rc->WriteMessage(MakeTestMessage(size))); | 202 EXPECT_TRUE(rc->WriteMessage(MakeTestMessage(size))); |
| 203 EXPECT_TRUE(checker.ReadAndCheckNextMessage(size)) << size; | 203 EXPECT_TRUE(checker.ReadAndCheckNextMessage(size)) << size; |
| 204 } | 204 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 Mutex mutex_; | 270 Mutex mutex_; |
| 271 std::vector<uint32_t> expected_sizes_ MOJO_GUARDED_BY(mutex_); | 271 std::vector<uint32_t> expected_sizes_ MOJO_GUARDED_BY(mutex_); |
| 272 size_t position_ MOJO_GUARDED_BY(mutex_); | 272 size_t position_ MOJO_GUARDED_BY(mutex_); |
| 273 | 273 |
| 274 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadCheckerRawChannelDelegate); | 274 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadCheckerRawChannelDelegate); |
| 275 }; | 275 }; |
| 276 | 276 |
| 277 // Tests reading (writing using our own custom writer). | 277 // Tests reading (writing using our own custom writer). |
| 278 TEST_F(RawChannelTest, OnReadMessage) { | 278 TEST_F(RawChannelTest, OnReadMessage) { |
| 279 ReadCheckerRawChannelDelegate delegate; | 279 ReadCheckerRawChannelDelegate delegate; |
| 280 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 280 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 281 io_thread()->PostTaskAndWait( | 281 io_thread()->PostTaskAndWait( |
| 282 FROM_HERE, | 282 FROM_HERE, |
| 283 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 283 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 284 | 284 |
| 285 // Write and read, for a variety of sizes. | 285 // Write and read, for a variety of sizes. |
| 286 for (uint32_t size = 1; size < 5 * 1000 * 1000; size += size / 2 + 1) { | 286 for (uint32_t size = 1; size < 5 * 1000 * 1000; size += size / 2 + 1) { |
| 287 delegate.SetExpectedSizes(std::vector<uint32_t>(1, size)); | 287 delegate.SetExpectedSizes(std::vector<uint32_t>(1, size)); |
| 288 | 288 |
| 289 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), size)); | 289 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), size)); |
| 290 | 290 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 size_t count_; | 367 size_t count_; |
| 368 | 368 |
| 369 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadCountdownRawChannelDelegate); | 369 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadCountdownRawChannelDelegate); |
| 370 }; | 370 }; |
| 371 | 371 |
| 372 TEST_F(RawChannelTest, WriteMessageAndOnReadMessage) { | 372 TEST_F(RawChannelTest, WriteMessageAndOnReadMessage) { |
| 373 static const size_t kNumWriterThreads = 10; | 373 static const size_t kNumWriterThreads = 10; |
| 374 static const size_t kNumWriteMessagesPerThread = 4000; | 374 static const size_t kNumWriteMessagesPerThread = 4000; |
| 375 | 375 |
| 376 WriteOnlyRawChannelDelegate writer_delegate; | 376 WriteOnlyRawChannelDelegate writer_delegate; |
| 377 scoped_ptr<RawChannel> writer_rc(RawChannel::Create(handles[0].Pass())); | 377 std::unique_ptr<RawChannel> writer_rc(RawChannel::Create(handles[0].Pass())); |
| 378 io_thread()->PostTaskAndWait(FROM_HERE, | 378 io_thread()->PostTaskAndWait(FROM_HERE, |
| 379 base::Bind(&InitOnIOThread, writer_rc.get(), | 379 base::Bind(&InitOnIOThread, writer_rc.get(), |
| 380 base::Unretained(&writer_delegate))); | 380 base::Unretained(&writer_delegate))); |
| 381 | 381 |
| 382 ReadCountdownRawChannelDelegate reader_delegate(kNumWriterThreads * | 382 ReadCountdownRawChannelDelegate reader_delegate(kNumWriterThreads * |
| 383 kNumWriteMessagesPerThread); | 383 kNumWriteMessagesPerThread); |
| 384 scoped_ptr<RawChannel> reader_rc(RawChannel::Create(handles[1].Pass())); | 384 std::unique_ptr<RawChannel> reader_rc(RawChannel::Create(handles[1].Pass())); |
| 385 io_thread()->PostTaskAndWait(FROM_HERE, | 385 io_thread()->PostTaskAndWait(FROM_HERE, |
| 386 base::Bind(&InitOnIOThread, reader_rc.get(), | 386 base::Bind(&InitOnIOThread, reader_rc.get(), |
| 387 base::Unretained(&reader_delegate))); | 387 base::Unretained(&reader_delegate))); |
| 388 | 388 |
| 389 { | 389 { |
| 390 ScopedVector<RawChannelWriterThread> writer_threads; | 390 ScopedVector<RawChannelWriterThread> writer_threads; |
| 391 for (size_t i = 0; i < kNumWriterThreads; i++) { | 391 for (size_t i = 0; i < kNumWriterThreads; i++) { |
| 392 writer_threads.push_back(new RawChannelWriterThread( | 392 writer_threads.push_back(new RawChannelWriterThread( |
| 393 writer_rc.get(), kNumWriteMessagesPerThread)); | 393 writer_rc.get(), kNumWriteMessagesPerThread)); |
| 394 } | 394 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 464 |
| 465 bool expecting_read_error_; | 465 bool expecting_read_error_; |
| 466 bool expecting_write_error_; | 466 bool expecting_write_error_; |
| 467 | 467 |
| 468 MOJO_DISALLOW_COPY_AND_ASSIGN(ErrorRecordingRawChannelDelegate); | 468 MOJO_DISALLOW_COPY_AND_ASSIGN(ErrorRecordingRawChannelDelegate); |
| 469 }; | 469 }; |
| 470 | 470 |
| 471 // Tests (fatal) errors. | 471 // Tests (fatal) errors. |
| 472 TEST_F(RawChannelTest, OnError) { | 472 TEST_F(RawChannelTest, OnError) { |
| 473 ErrorRecordingRawChannelDelegate delegate(0, true, true); | 473 ErrorRecordingRawChannelDelegate delegate(0, true, true); |
| 474 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 474 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 475 io_thread()->PostTaskAndWait( | 475 io_thread()->PostTaskAndWait( |
| 476 FROM_HERE, | 476 FROM_HERE, |
| 477 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 477 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 478 | 478 |
| 479 // Close the handle of the other end, which should make writing fail. | 479 // Close the handle of the other end, which should make writing fail. |
| 480 handles[1].reset(); | 480 handles[1].reset(); |
| 481 | 481 |
| 482 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); | 482 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); |
| 483 | 483 |
| 484 // We should get a write error. | 484 // We should get a write error. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 507 for (size_t i = 0; i < kMessageCount; | 507 for (size_t i = 0; i < kMessageCount; |
| 508 i++, message_size += message_size / 2 + 1) | 508 i++, message_size += message_size / 2 + 1) |
| 509 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), message_size)); | 509 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), message_size)); |
| 510 | 510 |
| 511 // Close the other end, which should make writing fail. | 511 // Close the other end, which should make writing fail. |
| 512 handles[1].reset(); | 512 handles[1].reset(); |
| 513 | 513 |
| 514 // Only start up reading here. The system buffer should still contain the | 514 // Only start up reading here. The system buffer should still contain the |
| 515 // messages that were written. | 515 // messages that were written. |
| 516 ErrorRecordingRawChannelDelegate delegate(kMessageCount, true, true); | 516 ErrorRecordingRawChannelDelegate delegate(kMessageCount, true, true); |
| 517 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 517 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 518 io_thread()->PostTaskAndWait( | 518 io_thread()->PostTaskAndWait( |
| 519 FROM_HERE, | 519 FROM_HERE, |
| 520 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 520 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 521 | 521 |
| 522 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); | 522 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); |
| 523 | 523 |
| 524 // We should definitely get a write error. | 524 // We should definitely get a write error. |
| 525 delegate.WaitForWriteError(); | 525 delegate.WaitForWriteError(); |
| 526 | 526 |
| 527 // Wait for reading to finish. A writing failure shouldn't affect reading. | 527 // Wait for reading to finish. A writing failure shouldn't affect reading. |
| 528 delegate.Wait(); | 528 delegate.Wait(); |
| 529 | 529 |
| 530 // And then we should get a read error. | 530 // And then we should get a read error. |
| 531 delegate.WaitForReadError(); | 531 delegate.WaitForReadError(); |
| 532 | 532 |
| 533 io_thread()->PostTaskAndWait( | 533 io_thread()->PostTaskAndWait( |
| 534 FROM_HERE, base::Bind(&RawChannel::Shutdown, base::Unretained(rc.get()))); | 534 FROM_HERE, base::Bind(&RawChannel::Shutdown, base::Unretained(rc.get()))); |
| 535 } | 535 } |
| 536 | 536 |
| 537 // RawChannelTest.WriteMessageAfterShutdown ------------------------------------ | 537 // RawChannelTest.WriteMessageAfterShutdown ------------------------------------ |
| 538 | 538 |
| 539 // Makes sure that calling |WriteMessage()| after |Shutdown()| behaves | 539 // Makes sure that calling |WriteMessage()| after |Shutdown()| behaves |
| 540 // correctly. | 540 // correctly. |
| 541 TEST_F(RawChannelTest, WriteMessageAfterShutdown) { | 541 TEST_F(RawChannelTest, WriteMessageAfterShutdown) { |
| 542 WriteOnlyRawChannelDelegate delegate; | 542 WriteOnlyRawChannelDelegate delegate; |
| 543 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 543 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 544 io_thread()->PostTaskAndWait( | 544 io_thread()->PostTaskAndWait( |
| 545 FROM_HERE, | 545 FROM_HERE, |
| 546 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 546 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 547 io_thread()->PostTaskAndWait( | 547 io_thread()->PostTaskAndWait( |
| 548 FROM_HERE, base::Bind(&RawChannel::Shutdown, base::Unretained(rc.get()))); | 548 FROM_HERE, base::Bind(&RawChannel::Shutdown, base::Unretained(rc.get()))); |
| 549 | 549 |
| 550 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); | 550 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); |
| 551 } | 551 } |
| 552 | 552 |
| 553 // RawChannelTest.{Shutdown, ShutdownAndDestroy}OnReadMessage ------------------ | 553 // RawChannelTest.{Shutdown, ShutdownAndDestroy}OnReadMessage ------------------ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 bool did_shutdown_; | 593 bool did_shutdown_; |
| 594 | 594 |
| 595 MOJO_DISALLOW_COPY_AND_ASSIGN(ShutdownOnReadMessageRawChannelDelegate); | 595 MOJO_DISALLOW_COPY_AND_ASSIGN(ShutdownOnReadMessageRawChannelDelegate); |
| 596 }; | 596 }; |
| 597 | 597 |
| 598 TEST_F(RawChannelTest, ShutdownOnReadMessage) { | 598 TEST_F(RawChannelTest, ShutdownOnReadMessage) { |
| 599 // Write a few messages into the other end. | 599 // Write a few messages into the other end. |
| 600 for (size_t count = 0; count < 5; count++) | 600 for (size_t count = 0; count < 5; count++) |
| 601 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), 10)); | 601 EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), 10)); |
| 602 | 602 |
| 603 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 603 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 604 ShutdownOnReadMessageRawChannelDelegate delegate(rc.get(), false); | 604 ShutdownOnReadMessageRawChannelDelegate delegate(rc.get(), false); |
| 605 io_thread()->PostTaskAndWait( | 605 io_thread()->PostTaskAndWait( |
| 606 FROM_HERE, | 606 FROM_HERE, |
| 607 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 607 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 608 | 608 |
| 609 // Wait for the delegate, which will shut the |RawChannel| down. | 609 // Wait for the delegate, which will shut the |RawChannel| down. |
| 610 delegate.Wait(); | 610 delegate.Wait(); |
| 611 } | 611 } |
| 612 | 612 |
| 613 TEST_F(RawChannelTest, ShutdownAndDestroyOnReadMessage) { | 613 TEST_F(RawChannelTest, ShutdownAndDestroyOnReadMessage) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 RawChannel* const raw_channel_; | 665 RawChannel* const raw_channel_; |
| 666 const bool should_destroy_; | 666 const bool should_destroy_; |
| 667 const Error shutdown_on_error_type_; | 667 const Error shutdown_on_error_type_; |
| 668 base::WaitableEvent done_event_; | 668 base::WaitableEvent done_event_; |
| 669 bool did_shutdown_; | 669 bool did_shutdown_; |
| 670 | 670 |
| 671 MOJO_DISALLOW_COPY_AND_ASSIGN(ShutdownOnErrorRawChannelDelegate); | 671 MOJO_DISALLOW_COPY_AND_ASSIGN(ShutdownOnErrorRawChannelDelegate); |
| 672 }; | 672 }; |
| 673 | 673 |
| 674 TEST_F(RawChannelTest, ShutdownOnErrorRead) { | 674 TEST_F(RawChannelTest, ShutdownOnErrorRead) { |
| 675 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 675 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 676 ShutdownOnErrorRawChannelDelegate delegate( | 676 ShutdownOnErrorRawChannelDelegate delegate( |
| 677 rc.get(), false, RawChannel::Delegate::ERROR_READ_SHUTDOWN); | 677 rc.get(), false, RawChannel::Delegate::ERROR_READ_SHUTDOWN); |
| 678 io_thread()->PostTaskAndWait( | 678 io_thread()->PostTaskAndWait( |
| 679 FROM_HERE, | 679 FROM_HERE, |
| 680 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 680 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 681 | 681 |
| 682 // Close the handle of the other end, which should stuff fail. | 682 // Close the handle of the other end, which should stuff fail. |
| 683 handles[1].reset(); | 683 handles[1].reset(); |
| 684 | 684 |
| 685 // Wait for the delegate, which will shut the |RawChannel| down. | 685 // Wait for the delegate, which will shut the |RawChannel| down. |
| 686 delegate.Wait(); | 686 delegate.Wait(); |
| 687 } | 687 } |
| 688 | 688 |
| 689 TEST_F(RawChannelTest, ShutdownAndDestroyOnErrorRead) { | 689 TEST_F(RawChannelTest, ShutdownAndDestroyOnErrorRead) { |
| 690 RawChannel* rc = RawChannel::Create(handles[0].Pass()).release(); | 690 RawChannel* rc = RawChannel::Create(handles[0].Pass()).release(); |
| 691 ShutdownOnErrorRawChannelDelegate delegate( | 691 ShutdownOnErrorRawChannelDelegate delegate( |
| 692 rc, true, RawChannel::Delegate::ERROR_READ_SHUTDOWN); | 692 rc, true, RawChannel::Delegate::ERROR_READ_SHUTDOWN); |
| 693 io_thread()->PostTaskAndWait( | 693 io_thread()->PostTaskAndWait( |
| 694 FROM_HERE, base::Bind(&InitOnIOThread, rc, base::Unretained(&delegate))); | 694 FROM_HERE, base::Bind(&InitOnIOThread, rc, base::Unretained(&delegate))); |
| 695 | 695 |
| 696 // Close the handle of the other end, which should stuff fail. | 696 // Close the handle of the other end, which should stuff fail. |
| 697 handles[1].reset(); | 697 handles[1].reset(); |
| 698 | 698 |
| 699 // Wait for the delegate, which will shut the |RawChannel| down. | 699 // Wait for the delegate, which will shut the |RawChannel| down. |
| 700 delegate.Wait(); | 700 delegate.Wait(); |
| 701 } | 701 } |
| 702 | 702 |
| 703 TEST_F(RawChannelTest, ShutdownOnErrorWrite) { | 703 TEST_F(RawChannelTest, ShutdownOnErrorWrite) { |
| 704 scoped_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); | 704 std::unique_ptr<RawChannel> rc(RawChannel::Create(handles[0].Pass())); |
| 705 ShutdownOnErrorRawChannelDelegate delegate(rc.get(), false, | 705 ShutdownOnErrorRawChannelDelegate delegate(rc.get(), false, |
| 706 RawChannel::Delegate::ERROR_WRITE); | 706 RawChannel::Delegate::ERROR_WRITE); |
| 707 io_thread()->PostTaskAndWait( | 707 io_thread()->PostTaskAndWait( |
| 708 FROM_HERE, | 708 FROM_HERE, |
| 709 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); | 709 base::Bind(&InitOnIOThread, rc.get(), base::Unretained(&delegate))); |
| 710 | 710 |
| 711 // Close the handle of the other end, which should stuff fail. | 711 // Close the handle of the other end, which should stuff fail. |
| 712 handles[1].reset(); | 712 handles[1].reset(); |
| 713 | 713 |
| 714 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); | 714 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 private: | 789 private: |
| 790 base::WaitableEvent done_event_; | 790 base::WaitableEvent done_event_; |
| 791 | 791 |
| 792 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadPlatformHandlesCheckerRawChannelDelegate); | 792 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadPlatformHandlesCheckerRawChannelDelegate); |
| 793 }; | 793 }; |
| 794 | 794 |
| 795 TEST_F(RawChannelTest, ReadWritePlatformHandles) { | 795 TEST_F(RawChannelTest, ReadWritePlatformHandles) { |
| 796 mojo::test::ScopedTestDir test_dir; | 796 mojo::test::ScopedTestDir test_dir; |
| 797 | 797 |
| 798 WriteOnlyRawChannelDelegate write_delegate; | 798 WriteOnlyRawChannelDelegate write_delegate; |
| 799 scoped_ptr<RawChannel> rc_write(RawChannel::Create(handles[0].Pass())); | 799 std::unique_ptr<RawChannel> rc_write(RawChannel::Create(handles[0].Pass())); |
| 800 io_thread()->PostTaskAndWait(FROM_HERE, | 800 io_thread()->PostTaskAndWait(FROM_HERE, |
| 801 base::Bind(&InitOnIOThread, rc_write.get(), | 801 base::Bind(&InitOnIOThread, rc_write.get(), |
| 802 base::Unretained(&write_delegate))); | 802 base::Unretained(&write_delegate))); |
| 803 | 803 |
| 804 ReadPlatformHandlesCheckerRawChannelDelegate read_delegate; | 804 ReadPlatformHandlesCheckerRawChannelDelegate read_delegate; |
| 805 scoped_ptr<RawChannel> rc_read(RawChannel::Create(handles[1].Pass())); | 805 std::unique_ptr<RawChannel> rc_read(RawChannel::Create(handles[1].Pass())); |
| 806 io_thread()->PostTaskAndWait(FROM_HERE, | 806 io_thread()->PostTaskAndWait(FROM_HERE, |
| 807 base::Bind(&InitOnIOThread, rc_read.get(), | 807 base::Bind(&InitOnIOThread, rc_read.get(), |
| 808 base::Unretained(&read_delegate))); | 808 base::Unretained(&read_delegate))); |
| 809 | 809 |
| 810 util::ScopedFILE fp1(test_dir.CreateFile()); | 810 util::ScopedFILE fp1(test_dir.CreateFile()); |
| 811 EXPECT_EQ(1u, fwrite("1", 1, 1, fp1.get())); | 811 EXPECT_EQ(1u, fwrite("1", 1, 1, fp1.get())); |
| 812 util::ScopedFILE fp2(test_dir.CreateFile()); | 812 util::ScopedFILE fp2(test_dir.CreateFile()); |
| 813 EXPECT_EQ(1u, fwrite("2", 1, 1, fp2.get())); | 813 EXPECT_EQ(1u, fwrite("2", 1, 1, fp2.get())); |
| 814 | 814 |
| 815 { | 815 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 836 FROM_HERE, | 836 FROM_HERE, |
| 837 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_read.get()))); | 837 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_read.get()))); |
| 838 io_thread()->PostTaskAndWait( | 838 io_thread()->PostTaskAndWait( |
| 839 FROM_HERE, | 839 FROM_HERE, |
| 840 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_write.get()))); | 840 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_write.get()))); |
| 841 } | 841 } |
| 842 | 842 |
| 843 } // namespace | 843 } // namespace |
| 844 } // namespace system | 844 } // namespace system |
| 845 } // namespace mojo | 845 } // namespace mojo |
| OLD | NEW |