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

Side by Side Diff: ipc/ipc_sync_channel_unittest.cc

Issue 6901146: Switch IPC::ChannelProxy to use MessageLoopProxy instead of MessageLoop. This allows us to remov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
« no previous file with comments | « ipc/ipc_sync_channel.cc ('k') | ipc/ipc_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Unit test for SyncChannel. 5 // Unit test for SyncChannel.
6 6
7 #include "ipc/ipc_sync_channel.h" 7 #include "ipc/ipc_sync_channel.h"
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 const base::Thread& ipc_thread() const { return ipc_thread_; } 161 const base::Thread& ipc_thread() const { return ipc_thread_; }
162 162
163 private: 163 private:
164 // Called on the listener thread to create the sync channel. 164 // Called on the listener thread to create the sync channel.
165 void OnStart() { 165 void OnStart() {
166 // Link ipc_thread_, listener_thread_ and channel_ altogether. 166 // Link ipc_thread_, listener_thread_ and channel_ altogether.
167 StartThread(&ipc_thread_, MessageLoop::TYPE_IO); 167 StartThread(&ipc_thread_, MessageLoop::TYPE_IO);
168 channel_.reset(new SyncChannel( 168 channel_.reset(new SyncChannel(
169 channel_name_, mode_, this, ipc_thread_.message_loop(), true, 169 channel_name_, mode_, this, ipc_thread_.message_loop_proxy(), true,
170 &shutdown_event_)); 170 &shutdown_event_));
171 channel_created_->Signal(); 171 channel_created_->Signal();
172 Run(); 172 Run();
173 } 173 }
174 174
175 void OnListenerThreadShutdown1(WaitableEvent* listener_event, 175 void OnListenerThreadShutdown1(WaitableEvent* listener_event,
176 WaitableEvent* ipc_event) { 176 WaitableEvent* ipc_event) {
177 // SyncChannel needs to be destructed on the thread that it was created on. 177 // SyncChannel needs to be destructed on the thread that it was created on.
178 channel_.reset(); 178 channel_.reset();
179 179
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 NewRunnableMethod(server_, &RestrictedDispatchServer::OnDoPing, 1)); 1243 NewRunnableMethod(server_, &RestrictedDispatchServer::OnDoPing, 1));
1244 sent_ping_event_->Wait(); 1244 sent_ping_event_->Wait();
1245 Send(new SyncChannelTestMsg_NoArgs); 1245 Send(new SyncChannelTestMsg_NoArgs);
1246 if (ping_ == 1) 1246 if (ping_ == 1)
1247 ++*success_; 1247 ++*success_;
1248 else 1248 else
1249 LOG(ERROR) << "Send failed to dispatch incoming message on same channel"; 1249 LOG(ERROR) << "Send failed to dispatch incoming message on same channel";
1250 1250
1251 scoped_ptr<SyncChannel> non_restricted_channel(new SyncChannel( 1251 scoped_ptr<SyncChannel> non_restricted_channel(new SyncChannel(
1252 "non_restricted_channel", Channel::MODE_CLIENT, this, 1252 "non_restricted_channel", Channel::MODE_CLIENT, this,
1253 ipc_thread().message_loop(), true, shutdown_event())); 1253 ipc_thread().message_loop_proxy(), true, shutdown_event()));
1254 1254
1255 server_->ListenerThread()->message_loop()->PostTask(FROM_HERE, 1255 server_->ListenerThread()->message_loop()->PostTask(FROM_HERE,
1256 NewRunnableMethod(server_, &RestrictedDispatchServer::OnDoPing, 2)); 1256 NewRunnableMethod(server_, &RestrictedDispatchServer::OnDoPing, 2));
1257 sent_ping_event_->Wait(); 1257 sent_ping_event_->Wait();
1258 // Check that the incoming message is *not* dispatched when sending on the 1258 // Check that the incoming message is *not* dispatched when sending on the
1259 // non restricted channel. 1259 // non restricted channel.
1260 // TODO(piman): there is a possibility of a false positive race condition 1260 // TODO(piman): there is a possibility of a false positive race condition
1261 // here, if the message that was posted on the server-side end of the pipe 1261 // here, if the message that was posted on the server-side end of the pipe
1262 // is not visible yet on the client side, but I don't know how to solve this 1262 // is not visible yet on the client side, but I don't know how to solve this
1263 // without hooking into the internals of SyncChannel. I haven't seen it in 1263 // without hooking into the internals of SyncChannel. I haven't seen it in
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 new RestrictedDispatchServer(&sent_ping_event); 1308 new RestrictedDispatchServer(&sent_ping_event);
1309 int success = 0; 1309 int success = 0;
1310 std::vector<Worker*> workers; 1310 std::vector<Worker*> workers;
1311 workers.push_back(new NonRestrictedDispatchServer); 1311 workers.push_back(new NonRestrictedDispatchServer);
1312 workers.push_back(server); 1312 workers.push_back(server);
1313 workers.push_back( 1313 workers.push_back(
1314 new RestrictedDispatchClient(&sent_ping_event, server, &success)); 1314 new RestrictedDispatchClient(&sent_ping_event, server, &success));
1315 RunTest(workers); 1315 RunTest(workers);
1316 EXPECT_EQ(3, success); 1316 EXPECT_EQ(3, success);
1317 } 1317 }
OLDNEW
« no previous file with comments | « ipc/ipc_sync_channel.cc ('k') | ipc/ipc_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698