Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Side by Side Diff: mojo/system/remote_message_pipe_unittest.cc

Issue 240133005: Mojo: Make some attempts towards fixing remote message pipe closure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 }
darin (slow to review) 2014/04/16 21:33:43 nit: no brackets here for consistency in this file
viettrungluu 2014/04/16 22:25:01 Done.
147
148 CHECK_EQ(endpoint_id, Channel::kBootstrapEndpointId);
145 CHECK(channels_[channel_index]->RunMessagePipeEndpoint( 149 CHECK(channels_[channel_index]->RunMessagePipeEndpoint(
146 Channel::kBootstrapEndpointId, Channel::kBootstrapEndpointId)); 150 Channel::kBootstrapEndpointId, Channel::kBootstrapEndpointId));
147 } 151 }
148 152
149 void RestoreInitialStateOnIOThread() { 153 void RestoreInitialStateOnIOThread() {
150 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); 154 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop());
151 155
152 TearDownOnIOThread(); 156 TearDownOnIOThread();
153 SetUpOnIOThread(); 157 SetUpOnIOThread();
154 } 158 }
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 local_mp->Close(1); 558 local_mp->Close(1);
555 } 559 }
556 560
557 // Test racing closes (on each end). 561 // Test racing closes (on each end).
558 // Note: A flaky failure would almost certainly indicate a problem in the code 562 // 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 563 // itself (not in the test). Also, any logged warnings/errors would also
560 // probably be indicative of bugs. 564 // probably be indicative of bugs.
561 TEST_F(RemoteMessagePipeTest, RacingClosesStress) { 565 TEST_F(RemoteMessagePipeTest, RacingClosesStress) {
562 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(5); 566 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(5);
563 567
564 for (unsigned i = 0u; i < 256u; i++) { 568 for (unsigned i = 0; i < 256; i++) {
569 DVLOG(2) << "---------------------------------------- " << i;
565 scoped_refptr<MessagePipe> mp0(new MessagePipe( 570 scoped_refptr<MessagePipe> mp0(new MessagePipe(
566 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()), 571 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()),
567 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()))); 572 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint())));
568 BootstrapMessagePipeNoWait(0, mp0); 573 BootstrapMessagePipeNoWait(0, mp0);
569 574
570 scoped_refptr<MessagePipe> mp1(new MessagePipe( 575 scoped_refptr<MessagePipe> mp1(new MessagePipe(
571 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()), 576 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint()),
572 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint()))); 577 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint())));
573 BootstrapMessagePipeNoWait(1, mp1); 578 BootstrapMessagePipeNoWait(1, mp1);
574 579
(...skipping 15 matching lines...) Expand all
590 595
591 mp1->Close(1); 596 mp1->Close(1);
592 597
593 RestoreInitialState(); 598 RestoreInitialState();
594 } 599 }
595 } 600 }
596 601
597 } // namespace 602 } // namespace
598 } // namespace system 603 } // namespace system
599 } // namespace mojo 604 } // namespace mojo
OLDNEW
« mojo/system/channel.cc ('K') | « mojo/system/proxy_message_pipe_endpoint.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698