OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 | 1185 |
1186 EXPECT_FALSE(server.send_result()); | 1186 EXPECT_FALSE(server.send_result()); |
1187 } | 1187 } |
1188 | 1188 |
1189 //----------------------------------------------------------------------------- | 1189 //----------------------------------------------------------------------------- |
1190 | 1190 |
1191 namespace { | 1191 namespace { |
1192 | 1192 |
1193 class RestrictedDispatchServer : public Worker { | 1193 class RestrictedDispatchServer : public Worker { |
1194 public: | 1194 public: |
1195 RestrictedDispatchServer(WaitableEvent* sent_ping_event) | 1195 RestrictedDispatchServer(WaitableEvent* sent_ping_event, |
| 1196 WaitableEvent* wait_event) |
1196 : Worker("restricted_channel", Channel::MODE_SERVER), | 1197 : Worker("restricted_channel", Channel::MODE_SERVER), |
1197 sent_ping_event_(sent_ping_event) { } | 1198 sent_ping_event_(sent_ping_event), |
| 1199 wait_event_(wait_event) { } |
1198 | 1200 |
1199 void OnDoPing(int ping) { | 1201 void OnDoPing(int ping) { |
1200 // Send an asynchronous message that unblocks the caller. | 1202 // Send an asynchronous message that unblocks the caller. |
1201 Message* msg = new SyncChannelTestMsg_Ping(ping); | 1203 Message* msg = new SyncChannelTestMsg_Ping(ping); |
1202 msg->set_unblock(true); | 1204 msg->set_unblock(true); |
1203 Send(msg); | 1205 Send(msg); |
1204 // Signal the event after the message has been sent on the channel, on the | 1206 // Signal the event after the message has been sent on the channel, on the |
1205 // IPC thread. | 1207 // IPC thread. |
1206 ipc_thread().message_loop()->PostTask( | 1208 ipc_thread().message_loop()->PostTask( |
1207 FROM_HERE, base::Bind(&RestrictedDispatchServer::OnPingSent, this)); | 1209 FROM_HERE, base::Bind(&RestrictedDispatchServer::OnPingSent, this)); |
1208 } | 1210 } |
1209 | 1211 |
| 1212 void OnPingTTL(int ping, int* out) { |
| 1213 *out = ping; |
| 1214 wait_event_->Wait(); |
| 1215 } |
| 1216 |
1210 base::Thread* ListenerThread() { return Worker::ListenerThread(); } | 1217 base::Thread* ListenerThread() { return Worker::ListenerThread(); } |
1211 | 1218 |
1212 private: | 1219 private: |
1213 bool OnMessageReceived(const Message& message) { | 1220 bool OnMessageReceived(const Message& message) { |
1214 IPC_BEGIN_MESSAGE_MAP(RestrictedDispatchServer, message) | 1221 IPC_BEGIN_MESSAGE_MAP(RestrictedDispatchServer, message) |
1215 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_NoArgs, OnNoArgs) | 1222 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_NoArgs, OnNoArgs) |
| 1223 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_PingTTL, OnPingTTL) |
1216 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Done, Done) | 1224 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Done, Done) |
1217 IPC_END_MESSAGE_MAP() | 1225 IPC_END_MESSAGE_MAP() |
1218 return true; | 1226 return true; |
1219 } | 1227 } |
1220 | 1228 |
1221 void OnPingSent() { | 1229 void OnPingSent() { |
1222 sent_ping_event_->Signal(); | 1230 sent_ping_event_->Signal(); |
1223 } | 1231 } |
1224 | 1232 |
1225 void OnNoArgs() { } | 1233 void OnNoArgs() { } |
1226 WaitableEvent* sent_ping_event_; | 1234 WaitableEvent* sent_ping_event_; |
| 1235 WaitableEvent* wait_event_; |
1227 }; | 1236 }; |
1228 | 1237 |
1229 class NonRestrictedDispatchServer : public Worker { | 1238 class NonRestrictedDispatchServer : public Worker { |
1230 public: | 1239 public: |
1231 NonRestrictedDispatchServer() | 1240 NonRestrictedDispatchServer(WaitableEvent* signal_event) |
1232 : Worker("non_restricted_channel", Channel::MODE_SERVER) {} | 1241 : Worker("non_restricted_channel", Channel::MODE_SERVER), |
| 1242 signal_event_(signal_event) {} |
| 1243 |
| 1244 base::Thread* ListenerThread() { return Worker::ListenerThread(); } |
| 1245 |
| 1246 void OnDoPingTTL(int ping) { |
| 1247 int value = 0; |
| 1248 Send(new SyncChannelTestMsg_PingTTL(ping, &value)); |
| 1249 signal_event_->Signal(); |
| 1250 } |
1233 | 1251 |
1234 private: | 1252 private: |
1235 bool OnMessageReceived(const Message& message) { | 1253 bool OnMessageReceived(const Message& message) { |
1236 IPC_BEGIN_MESSAGE_MAP(NonRestrictedDispatchServer, message) | 1254 IPC_BEGIN_MESSAGE_MAP(NonRestrictedDispatchServer, message) |
1237 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_NoArgs, OnNoArgs) | 1255 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_NoArgs, OnNoArgs) |
1238 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Done, Done) | 1256 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Done, Done) |
1239 IPC_END_MESSAGE_MAP() | 1257 IPC_END_MESSAGE_MAP() |
1240 return true; | 1258 return true; |
1241 } | 1259 } |
1242 | 1260 |
1243 void OnNoArgs() { } | 1261 void OnNoArgs() { } |
| 1262 WaitableEvent* signal_event_; |
1244 }; | 1263 }; |
1245 | 1264 |
1246 class RestrictedDispatchClient : public Worker { | 1265 class RestrictedDispatchClient : public Worker { |
1247 public: | 1266 public: |
1248 RestrictedDispatchClient(WaitableEvent* sent_ping_event, | 1267 RestrictedDispatchClient(WaitableEvent* sent_ping_event, |
1249 RestrictedDispatchServer* server, | 1268 RestrictedDispatchServer* server, |
| 1269 NonRestrictedDispatchServer* server2, |
1250 int* success) | 1270 int* success) |
1251 : Worker("restricted_channel", Channel::MODE_CLIENT), | 1271 : Worker("restricted_channel", Channel::MODE_CLIENT), |
1252 ping_(0), | 1272 ping_(0), |
1253 server_(server), | 1273 server_(server), |
| 1274 server2_(server2), |
1254 success_(success), | 1275 success_(success), |
1255 sent_ping_event_(sent_ping_event) {} | 1276 sent_ping_event_(sent_ping_event) {} |
1256 | 1277 |
1257 void Run() { | 1278 void Run() { |
1258 // Incoming messages from our channel should only be dispatched when we | 1279 // Incoming messages from our channel should only be dispatched when we |
1259 // send a message on that same channel. | 1280 // send a message on that same channel. |
1260 channel()->SetRestrictDispatchToSameChannel(true); | 1281 channel()->SetRestrictDispatchChannelGroup(1); |
1261 | 1282 |
1262 server_->ListenerThread()->message_loop()->PostTask( | 1283 server_->ListenerThread()->message_loop()->PostTask( |
1263 FROM_HERE, base::Bind(&RestrictedDispatchServer::OnDoPing, server_, 1)); | 1284 FROM_HERE, base::Bind(&RestrictedDispatchServer::OnDoPing, server_, 1)); |
1264 sent_ping_event_->Wait(); | 1285 sent_ping_event_->Wait(); |
1265 Send(new SyncChannelTestMsg_NoArgs); | 1286 Send(new SyncChannelTestMsg_NoArgs); |
1266 if (ping_ == 1) | 1287 if (ping_ == 1) |
1267 ++*success_; | 1288 ++*success_; |
1268 else | 1289 else |
1269 LOG(ERROR) << "Send failed to dispatch incoming message on same channel"; | 1290 LOG(ERROR) << "Send failed to dispatch incoming message on same channel"; |
1270 | 1291 |
1271 scoped_ptr<SyncChannel> non_restricted_channel(new SyncChannel( | 1292 non_restricted_channel_.reset(new SyncChannel( |
1272 "non_restricted_channel", Channel::MODE_CLIENT, this, | 1293 "non_restricted_channel", Channel::MODE_CLIENT, this, |
1273 ipc_thread().message_loop_proxy(), true, shutdown_event())); | 1294 ipc_thread().message_loop_proxy(), true, shutdown_event())); |
1274 | 1295 |
1275 server_->ListenerThread()->message_loop()->PostTask( | 1296 server_->ListenerThread()->message_loop()->PostTask( |
1276 FROM_HERE, base::Bind(&RestrictedDispatchServer::OnDoPing, server_, 2)); | 1297 FROM_HERE, base::Bind(&RestrictedDispatchServer::OnDoPing, server_, 2)); |
1277 sent_ping_event_->Wait(); | 1298 sent_ping_event_->Wait(); |
1278 // Check that the incoming message is *not* dispatched when sending on the | 1299 // Check that the incoming message is *not* dispatched when sending on the |
1279 // non restricted channel. | 1300 // non restricted channel. |
1280 // TODO(piman): there is a possibility of a false positive race condition | 1301 // TODO(piman): there is a possibility of a false positive race condition |
1281 // here, if the message that was posted on the server-side end of the pipe | 1302 // here, if the message that was posted on the server-side end of the pipe |
1282 // is not visible yet on the client side, but I don't know how to solve this | 1303 // is not visible yet on the client side, but I don't know how to solve this |
1283 // without hooking into the internals of SyncChannel. I haven't seen it in | 1304 // without hooking into the internals of SyncChannel. I haven't seen it in |
1284 // practice (i.e. not setting SetRestrictDispatchToSameChannel does cause | 1305 // practice (i.e. not setting SetRestrictDispatchToSameChannel does cause |
1285 // the following to fail). | 1306 // the following to fail). |
1286 non_restricted_channel->Send(new SyncChannelTestMsg_NoArgs); | 1307 non_restricted_channel_->Send(new SyncChannelTestMsg_NoArgs); |
1287 if (ping_ == 1) | 1308 if (ping_ == 1) |
1288 ++*success_; | 1309 ++*success_; |
1289 else | 1310 else |
1290 LOG(ERROR) << "Send dispatched message from restricted channel"; | 1311 LOG(ERROR) << "Send dispatched message from restricted channel"; |
1291 | 1312 |
1292 Send(new SyncChannelTestMsg_NoArgs); | 1313 Send(new SyncChannelTestMsg_NoArgs); |
1293 if (ping_ == 2) | 1314 if (ping_ == 2) |
1294 ++*success_; | 1315 ++*success_; |
1295 else | 1316 else |
1296 LOG(ERROR) << "Send failed to dispatch incoming message on same channel"; | 1317 LOG(ERROR) << "Send failed to dispatch incoming message on same channel"; |
1297 | 1318 |
1298 non_restricted_channel->Send(new SyncChannelTestMsg_Done); | 1319 // Check that the incoming message on the non-restricted channel is |
1299 non_restricted_channel.reset(); | 1320 // dispatched when sending on the restricted channel. |
| 1321 server2_->ListenerThread()->message_loop()->PostTask( |
| 1322 FROM_HERE, |
| 1323 base::Bind(&NonRestrictedDispatchServer::OnDoPingTTL, server2_, 3)); |
| 1324 int value = 0; |
| 1325 Send(new SyncChannelTestMsg_PingTTL(4, &value)); |
| 1326 if (ping_ == 3 && value == 4) |
| 1327 ++*success_; |
| 1328 else |
| 1329 LOG(ERROR) << "Send failed to dispatch message from unrestricted channel"; |
| 1330 |
| 1331 non_restricted_channel_->Send(new SyncChannelTestMsg_Done); |
| 1332 non_restricted_channel_.reset(); |
1300 Send(new SyncChannelTestMsg_Done); | 1333 Send(new SyncChannelTestMsg_Done); |
1301 Done(); | 1334 Done(); |
1302 } | 1335 } |
1303 | 1336 |
1304 private: | 1337 private: |
1305 bool OnMessageReceived(const Message& message) { | 1338 bool OnMessageReceived(const Message& message) { |
1306 IPC_BEGIN_MESSAGE_MAP(RestrictedDispatchClient, message) | 1339 IPC_BEGIN_MESSAGE_MAP(RestrictedDispatchClient, message) |
1307 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Ping, OnPing) | 1340 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Ping, OnPing) |
| 1341 IPC_MESSAGE_HANDLER_DELAY_REPLY(SyncChannelTestMsg_PingTTL, OnPingTTL) |
1308 IPC_END_MESSAGE_MAP() | 1342 IPC_END_MESSAGE_MAP() |
1309 return true; | 1343 return true; |
1310 } | 1344 } |
1311 | 1345 |
1312 void OnPing(int ping) { | 1346 void OnPing(int ping) { |
1313 ping_ = ping; | 1347 ping_ = ping; |
1314 } | 1348 } |
1315 | 1349 |
| 1350 void OnPingTTL(int ping, IPC::Message* reply) { |
| 1351 ping_ = ping; |
| 1352 // This message comes from the NonRestrictedDispatchServer, we have to send |
| 1353 // the reply back manually. |
| 1354 SyncChannelTestMsg_PingTTL::WriteReplyParams(reply, ping); |
| 1355 non_restricted_channel_->Send(reply); |
| 1356 } |
| 1357 |
1316 int ping_; | 1358 int ping_; |
1317 RestrictedDispatchServer* server_; | 1359 RestrictedDispatchServer* server_; |
| 1360 NonRestrictedDispatchServer* server2_; |
1318 int* success_; | 1361 int* success_; |
1319 WaitableEvent* sent_ping_event_; | 1362 WaitableEvent* sent_ping_event_; |
| 1363 scoped_ptr<SyncChannel> non_restricted_channel_; |
1320 }; | 1364 }; |
1321 | 1365 |
1322 } // namespace | 1366 } // namespace |
1323 | 1367 |
1324 TEST_F(IPCSyncChannelTest, RestrictedDispatch) { | 1368 TEST_F(IPCSyncChannelTest, RestrictedDispatch) { |
1325 WaitableEvent sent_ping_event(false, false); | 1369 WaitableEvent sent_ping_event(false, false); |
| 1370 WaitableEvent wait_event(false, false); |
| 1371 RestrictedDispatchServer* server = |
| 1372 new RestrictedDispatchServer(&sent_ping_event, &wait_event); |
| 1373 NonRestrictedDispatchServer* server2 = |
| 1374 new NonRestrictedDispatchServer(&wait_event); |
1326 | 1375 |
1327 RestrictedDispatchServer* server = | |
1328 new RestrictedDispatchServer(&sent_ping_event); | |
1329 int success = 0; | 1376 int success = 0; |
1330 std::vector<Worker*> workers; | 1377 std::vector<Worker*> workers; |
1331 workers.push_back(new NonRestrictedDispatchServer); | |
1332 workers.push_back(server); | 1378 workers.push_back(server); |
1333 workers.push_back( | 1379 workers.push_back(server2); |
1334 new RestrictedDispatchClient(&sent_ping_event, server, &success)); | 1380 workers.push_back(new RestrictedDispatchClient( |
| 1381 &sent_ping_event, server, server2, &success)); |
1335 RunTest(workers); | 1382 RunTest(workers); |
1336 EXPECT_EQ(3, success); | 1383 EXPECT_EQ(4, success); |
1337 } | 1384 } |
1338 | 1385 |
1339 //----------------------------------------------------------------------------- | 1386 //----------------------------------------------------------------------------- |
1340 | 1387 |
1341 // This test case inspired by crbug.com/108491 | 1388 // This test case inspired by crbug.com/108491 |
1342 // We create two servers that use the same ListenerThread but have | 1389 // We create two servers that use the same ListenerThread but have |
1343 // SetRestrictDispatchToSameChannel set to true. | 1390 // SetRestrictDispatchToSameChannel set to true. |
1344 // We create clients, then use some specific WaitableEvent wait/signalling to | 1391 // We create clients, then use some specific WaitableEvent wait/signalling to |
1345 // ensure that messages get dispatched in a way that causes a deadlock due to | 1392 // ensure that messages get dispatched in a way that causes a deadlock due to |
1346 // a nested dispatch and an eligible message in a higher-level dispatch's | 1393 // a nested dispatch and an eligible message in a higher-level dispatch's |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 client_kicked_(false) { } | 1428 client_kicked_(false) { } |
1382 | 1429 |
1383 void OnDoServerTask() { | 1430 void OnDoServerTask() { |
1384 events_[3]->Signal(); | 1431 events_[3]->Signal(); |
1385 events_[2]->Wait(); | 1432 events_[2]->Wait(); |
1386 events_[0]->Signal(); | 1433 events_[0]->Signal(); |
1387 SendMessageToClient(); | 1434 SendMessageToClient(); |
1388 } | 1435 } |
1389 | 1436 |
1390 void Run() { | 1437 void Run() { |
1391 channel()->SetRestrictDispatchToSameChannel(true); | 1438 channel()->SetRestrictDispatchChannelGroup(1); |
1392 server_ready_event_->Signal(); | 1439 server_ready_event_->Signal(); |
1393 } | 1440 } |
1394 | 1441 |
1395 base::Thread* ListenerThread() { return Worker::ListenerThread(); } | 1442 base::Thread* ListenerThread() { return Worker::ListenerThread(); } |
1396 | 1443 |
1397 private: | 1444 private: |
1398 bool OnMessageReceived(const Message& message) { | 1445 bool OnMessageReceived(const Message& message) { |
1399 IPC_BEGIN_MESSAGE_MAP(RestrictedDispatchDeadlockServer, message) | 1446 IPC_BEGIN_MESSAGE_MAP(RestrictedDispatchDeadlockServer, message) |
1400 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_NoArgs, OnNoArgs) | 1447 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_NoArgs, OnNoArgs) |
1401 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Done, Done) | 1448 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Done, Done) |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 | 1636 |
1590 client1 = new RestrictedDispatchDeadlockClient1(server1, client2, | 1637 client1 = new RestrictedDispatchDeadlockClient1(server1, client2, |
1591 &server1_ready, events); | 1638 &server1_ready, events); |
1592 workers.push_back(client1); | 1639 workers.push_back(client1); |
1593 | 1640 |
1594 RunTest(workers); | 1641 RunTest(workers); |
1595 } | 1642 } |
1596 | 1643 |
1597 //----------------------------------------------------------------------------- | 1644 //----------------------------------------------------------------------------- |
1598 | 1645 |
| 1646 // This test case inspired by crbug.com/120530 |
| 1647 // We create 4 workers that pipe to each other W1->W2->W3->W4->W1 then we send a |
| 1648 // message that recurses through 3, 4 or 5 steps to make sure, say, W1 can |
| 1649 // re-enter when called from W4 while it's sending a message to W2. |
| 1650 // The first worker drives the whole test so it must be treated specially. |
| 1651 namespace { |
| 1652 |
| 1653 class RestrictedDispatchPipeWorker : public Worker { |
| 1654 public: |
| 1655 RestrictedDispatchPipeWorker( |
| 1656 const std::string &channel1, |
| 1657 WaitableEvent* event1, |
| 1658 const std::string &channel2, |
| 1659 WaitableEvent* event2, |
| 1660 int group, |
| 1661 int* success) |
| 1662 : Worker(channel1, Channel::MODE_SERVER), |
| 1663 event1_(event1), |
| 1664 event2_(event2), |
| 1665 other_channel_name_(channel2), |
| 1666 group_(group), |
| 1667 success_(success) { |
| 1668 } |
| 1669 |
| 1670 void OnPingTTL(int ping, int* ret) { |
| 1671 *ret = 0; |
| 1672 if (!ping) |
| 1673 return; |
| 1674 other_channel_->Send(new SyncChannelTestMsg_PingTTL(ping - 1, ret)); |
| 1675 ++*ret; |
| 1676 } |
| 1677 |
| 1678 void OnDone() { |
| 1679 if (is_first()) |
| 1680 return; |
| 1681 other_channel_->Send(new SyncChannelTestMsg_Done); |
| 1682 other_channel_.reset(); |
| 1683 Done(); |
| 1684 } |
| 1685 |
| 1686 void Run() { |
| 1687 channel()->SetRestrictDispatchChannelGroup(group_); |
| 1688 if (is_first()) |
| 1689 event1_->Signal(); |
| 1690 event2_->Wait(); |
| 1691 other_channel_.reset(new SyncChannel( |
| 1692 other_channel_name_, Channel::MODE_CLIENT, this, |
| 1693 ipc_thread().message_loop_proxy(), true, shutdown_event())); |
| 1694 other_channel_->SetRestrictDispatchChannelGroup(group_); |
| 1695 if (!is_first()) { |
| 1696 event1_->Signal(); |
| 1697 return; |
| 1698 } |
| 1699 *success_ = 0; |
| 1700 int value = 0; |
| 1701 OnPingTTL(3, &value); |
| 1702 *success_ += (value == 3); |
| 1703 OnPingTTL(4, &value); |
| 1704 *success_ += (value == 4); |
| 1705 OnPingTTL(5, &value); |
| 1706 *success_ += (value == 5); |
| 1707 other_channel_->Send(new SyncChannelTestMsg_Done); |
| 1708 other_channel_.reset(); |
| 1709 Done(); |
| 1710 } |
| 1711 |
| 1712 bool is_first() { return !!success_; } |
| 1713 |
| 1714 private: |
| 1715 bool OnMessageReceived(const Message& message) { |
| 1716 IPC_BEGIN_MESSAGE_MAP(RestrictedDispatchPipeWorker, message) |
| 1717 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_PingTTL, OnPingTTL) |
| 1718 IPC_MESSAGE_HANDLER(SyncChannelTestMsg_Done, OnDone) |
| 1719 IPC_END_MESSAGE_MAP() |
| 1720 return true; |
| 1721 } |
| 1722 |
| 1723 scoped_ptr<SyncChannel> other_channel_; |
| 1724 WaitableEvent* event1_; |
| 1725 WaitableEvent* event2_; |
| 1726 std::string other_channel_name_; |
| 1727 int group_; |
| 1728 int* success_; |
| 1729 }; |
| 1730 |
| 1731 } // namespace |
| 1732 |
| 1733 TEST_F(IPCSyncChannelTest, RestrictedDispatch4WayDeadlock) { |
| 1734 int success = 0; |
| 1735 std::vector<Worker*> workers; |
| 1736 WaitableEvent event0(true, false); |
| 1737 WaitableEvent event1(true, false); |
| 1738 WaitableEvent event2(true, false); |
| 1739 WaitableEvent event3(true, false); |
| 1740 workers.push_back(new RestrictedDispatchPipeWorker( |
| 1741 "channel0", &event0, "channel1", &event1, 1, &success)); |
| 1742 workers.push_back(new RestrictedDispatchPipeWorker( |
| 1743 "channel1", &event1, "channel2", &event2, 2, NULL)); |
| 1744 workers.push_back(new RestrictedDispatchPipeWorker( |
| 1745 "channel2", &event2, "channel3", &event3, 3, NULL)); |
| 1746 workers.push_back(new RestrictedDispatchPipeWorker( |
| 1747 "channel3", &event3, "channel0", &event0, 4, NULL)); |
| 1748 RunTest(workers); |
| 1749 EXPECT_EQ(3, success); |
| 1750 } |
| 1751 |
| 1752 //----------------------------------------------------------------------------- |
| 1753 |
1599 // Generate a validated channel ID using Channel::GenerateVerifiedChannelID(). | 1754 // Generate a validated channel ID using Channel::GenerateVerifiedChannelID(). |
1600 namespace { | 1755 namespace { |
1601 | 1756 |
1602 class VerifiedServer : public Worker { | 1757 class VerifiedServer : public Worker { |
1603 public: | 1758 public: |
1604 VerifiedServer(base::Thread* listener_thread, | 1759 VerifiedServer(base::Thread* listener_thread, |
1605 const std::string& channel_name, | 1760 const std::string& channel_name, |
1606 const std::string& reply_text) | 1761 const std::string& reply_text) |
1607 : Worker(channel_name, Channel::MODE_SERVER), | 1762 : Worker(channel_name, Channel::MODE_SERVER), |
1608 reply_text_(reply_text) { | 1763 reply_text_(reply_text) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 | 1832 |
1678 } // namespace | 1833 } // namespace |
1679 | 1834 |
1680 // Windows needs to send an out-of-band secret to verify the client end of the | 1835 // Windows needs to send an out-of-band secret to verify the client end of the |
1681 // channel. Test that we still connect correctly in that case. | 1836 // channel. Test that we still connect correctly in that case. |
1682 TEST_F(IPCSyncChannelTest, Verified) { | 1837 TEST_F(IPCSyncChannelTest, Verified) { |
1683 Verified(); | 1838 Verified(); |
1684 } | 1839 } |
1685 | 1840 |
1686 } // namespace IPC | 1841 } // namespace IPC |
OLD | NEW |