| 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 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 446 |
| 447 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 447 scoped_refptr<MessagePipe> mp0(new MessagePipe( |
| 448 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 448 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), |
| 449 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | 449 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); |
| 450 scoped_refptr<MessagePipe> mp1(new MessagePipe( | 450 scoped_refptr<MessagePipe> mp1(new MessagePipe( |
| 451 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | 451 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), |
| 452 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | 452 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); |
| 453 ConnectMessagePipes(mp0, mp1); | 453 ConnectMessagePipes(mp0, mp1); |
| 454 | 454 |
| 455 // We'll try to pass this dispatcher. | 455 // We'll try to pass this dispatcher. |
| 456 scoped_refptr<MessagePipeDispatcher> dispatcher(new MessagePipeDispatcher()); | 456 scoped_refptr<MessagePipeDispatcher> dispatcher(new MessagePipeDispatcher( |
| 457 MessagePipeDispatcher::kDefaultCreateOptions)); |
| 457 scoped_refptr<MessagePipe> local_mp(new MessagePipe()); | 458 scoped_refptr<MessagePipe> local_mp(new MessagePipe()); |
| 458 dispatcher->Init(local_mp, 0); | 459 dispatcher->Init(local_mp, 0); |
| 459 | 460 |
| 460 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do | 461 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do |
| 461 // it later, it might already be readable.) | 462 // it later, it might already be readable.) |
| 462 waiter.Init(); | 463 waiter.Init(); |
| 463 EXPECT_EQ(MOJO_RESULT_OK, | 464 EXPECT_EQ(MOJO_RESULT_OK, |
| 464 mp1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123)); | 465 mp1->AddWaiter(1, &waiter, MOJO_WAIT_FLAG_READABLE, 123)); |
| 465 | 466 |
| 466 // Write to MP 0, port 0. | 467 // Write to MP 0, port 0. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 577 scoped_refptr<MessagePipe> mp0(new MessagePipe( |
| 577 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 578 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), |
| 578 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | 579 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); |
| 579 scoped_refptr<MessagePipe> mp1(new MessagePipe( | 580 scoped_refptr<MessagePipe> mp1(new MessagePipe( |
| 580 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | 581 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), |
| 581 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | 582 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); |
| 582 ConnectMessagePipes(mp0, mp1); | 583 ConnectMessagePipes(mp0, mp1); |
| 583 | 584 |
| 584 // We'll try to pass this dispatcher. | 585 // We'll try to pass this dispatcher. |
| 585 scoped_refptr<SharedBufferDispatcher> dispatcher; | 586 scoped_refptr<SharedBufferDispatcher> dispatcher; |
| 586 MojoCreateSharedBufferOptions validated_options = {}; | |
| 587 EXPECT_EQ(MOJO_RESULT_OK, | 587 EXPECT_EQ(MOJO_RESULT_OK, |
| 588 SharedBufferDispatcher::ValidateCreateOptions(NULL, | 588 SharedBufferDispatcher::Create( |
| 589 &validated_options)); | 589 SharedBufferDispatcher::kDefaultCreateOptions, 100, |
| 590 EXPECT_EQ(MOJO_RESULT_OK, | 590 &dispatcher)); |
| 591 SharedBufferDispatcher::Create(validated_options, 100, | |
| 592 &dispatcher)); | |
| 593 ASSERT_TRUE(dispatcher); | 591 ASSERT_TRUE(dispatcher); |
| 594 | 592 |
| 595 // Make a mapping. | 593 // Make a mapping. |
| 596 scoped_ptr<RawSharedBufferMapping> mapping0; | 594 scoped_ptr<RawSharedBufferMapping> mapping0; |
| 597 EXPECT_EQ(MOJO_RESULT_OK, | 595 EXPECT_EQ(MOJO_RESULT_OK, |
| 598 dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, | 596 dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, |
| 599 &mapping0)); | 597 &mapping0)); |
| 600 ASSERT_TRUE(mapping0); | 598 ASSERT_TRUE(mapping0); |
| 601 ASSERT_TRUE(mapping0->base()); | 599 ASSERT_TRUE(mapping0->base()); |
| 602 ASSERT_EQ(100u, mapping0->length()); | 600 ASSERT_EQ(100u, mapping0->length()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 816 |
| 819 mp1->Close(1); | 817 mp1->Close(1); |
| 820 | 818 |
| 821 RestoreInitialState(); | 819 RestoreInitialState(); |
| 822 } | 820 } |
| 823 } | 821 } |
| 824 | 822 |
| 825 } // namespace | 823 } // namespace |
| 826 } // namespace system | 824 } // namespace system |
| 827 } // namespace mojo | 825 } // namespace mojo |
| OLD | NEW |