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 <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 CHECK(channels_[1]->RunMessagePipeEndpoint(local_id1, local_id0)); | 131 CHECK(channels_[1]->RunMessagePipeEndpoint(local_id1, local_id0)); |
132 } | 132 } |
133 | 133 |
134 void BootstrapMessagePipeOnIOThread(unsigned channel_index, | 134 void BootstrapMessagePipeOnIOThread(unsigned channel_index, |
135 scoped_refptr<MessagePipe> mp) { | 135 scoped_refptr<MessagePipe> mp) { |
136 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); | 136 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); |
137 CHECK(channel_index == 0 || channel_index == 1); | 137 CHECK(channel_index == 0 || channel_index == 1); |
138 | 138 |
139 unsigned port = channel_index ^ 1u; | 139 unsigned port = channel_index ^ 1u; |
140 | 140 |
141 // Important: If we don't boot | |
142 CreateAndInitChannel(channel_index); | 141 CreateAndInitChannel(channel_index); |
143 CHECK_EQ(channels_[channel_index]->AttachMessagePipeEndpoint(mp, port), | 142 MessageInTransit::EndpointId endpoint_id = |
144 Channel::kBootstrapEndpointId); | 143 channels_[channel_index]->AttachMessagePipeEndpoint(mp, port); |
| 144 if (endpoint_id == MessageInTransit::kInvalidEndpointId) |
| 145 return; |
| 146 |
| 147 CHECK_EQ(endpoint_id, Channel::kBootstrapEndpointId); |
145 CHECK(channels_[channel_index]->RunMessagePipeEndpoint( | 148 CHECK(channels_[channel_index]->RunMessagePipeEndpoint( |
146 Channel::kBootstrapEndpointId, Channel::kBootstrapEndpointId)); | 149 Channel::kBootstrapEndpointId, Channel::kBootstrapEndpointId)); |
147 } | 150 } |
148 | 151 |
149 void RestoreInitialStateOnIOThread() { | 152 void RestoreInitialStateOnIOThread() { |
150 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); | 153 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); |
151 | 154 |
152 TearDownOnIOThread(); | 155 TearDownOnIOThread(); |
153 SetUpOnIOThread(); | 156 SetUpOnIOThread(); |
154 } | 157 } |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 local_mp->Close(1); | 557 local_mp->Close(1); |
555 } | 558 } |
556 | 559 |
557 // Test racing closes (on each end). | 560 // Test racing closes (on each end). |
558 // Note: A flaky failure would almost certainly indicate a problem in the code | 561 // Note: A flaky failure would almost certainly indicate a problem in the code |
559 // itself (not in the test). Also, any logged warnings/errors would also | 562 // itself (not in the test). Also, any logged warnings/errors would also |
560 // probably be indicative of bugs. | 563 // probably be indicative of bugs. |
561 TEST_F(RemoteMessagePipeTest, RacingClosesStress) { | 564 TEST_F(RemoteMessagePipeTest, RacingClosesStress) { |
562 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(5); | 565 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(5); |
563 | 566 |
564 for (unsigned i = 0u; i < 256u; i++) { | 567 for (unsigned i = 0; i < 256; i++) { |
| 568 DVLOG(2) << "---------------------------------------- " << i; |
565 scoped_refptr<MessagePipe> mp0(new MessagePipe( | 569 scoped_refptr<MessagePipe> mp0(new MessagePipe( |
566 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), | 570 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), |
567 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); | 571 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); |
568 BootstrapMessagePipeNoWait(0, mp0); | 572 BootstrapMessagePipeNoWait(0, mp0); |
569 | 573 |
570 scoped_refptr<MessagePipe> mp1(new MessagePipe( | 574 scoped_refptr<MessagePipe> mp1(new MessagePipe( |
571 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), | 575 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), |
572 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); | 576 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); |
573 BootstrapMessagePipeNoWait(1, mp1); | 577 BootstrapMessagePipeNoWait(1, mp1); |
574 | 578 |
(...skipping 15 matching lines...) Expand all Loading... |
590 | 594 |
591 mp1->Close(1); | 595 mp1->Close(1); |
592 | 596 |
593 RestoreInitialState(); | 597 RestoreInitialState(); |
594 } | 598 } |
595 } | 599 } |
596 | 600 |
597 } // namespace | 601 } // namespace |
598 } // namespace system | 602 } // namespace system |
599 } // namespace mojo | 603 } // namespace mojo |
OLD | NEW |