| OLD | NEW |
| 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 #include "content/renderer/p2p/p2p_transport_impl.h" | 5 #include "content/renderer/p2p/p2p_transport_impl.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 using webkit_glue::P2PTransport; | 27 using webkit_glue::P2PTransport; |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 const char kTestAddress1[] = "192.168.15.12"; | 30 const char kTestAddress1[] = "192.168.15.12"; |
| 31 const char kTestAddress2[] = "192.168.15.33"; | 31 const char kTestAddress2[] = "192.168.15.33"; |
| 32 | 32 |
| 33 const char kTransportName1[] = "tr1"; | 33 const char kTransportName1[] = "tr1"; |
| 34 const char kTransportName2[] = "tr2"; | 34 const char kTransportName2[] = "tr2"; |
| 35 | 35 |
| 36 const char kTestConfig[] = ""; | |
| 37 | |
| 38 // Send 10 packets 10 bytes each. Packets are sent with 10ms delay | 36 // Send 10 packets 10 bytes each. Packets are sent with 10ms delay |
| 39 // between packets (about 100 ms for 10 messages). | 37 // between packets (about 100 ms for 10 messages). |
| 40 const int kMessageSize = 10; | 38 const int kMessageSize = 10; |
| 41 const int kMessages = 10; | 39 const int kMessages = 10; |
| 42 const int kUdpWriteDelayMs = 10; | 40 const int kUdpWriteDelayMs = 10; |
| 43 const int kTcpDataSize = 10 * 1024; | 41 const int kTcpDataSize = 10 * 1024; |
| 44 const int kTcpWriteDelayMs = 1; | 42 const int kTcpWriteDelayMs = 1; |
| 45 | 43 |
| 46 class UdpChannelTester : public base::RefCountedThreadSafe<UdpChannelTester> { | 44 class UdpChannelTester : public base::RefCountedThreadSafe<UdpChannelTester> { |
| 47 public: | 45 public: |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 new jingle_glue::FakeNetworkManager(ip), | 344 new jingle_glue::FakeNetworkManager(ip), |
| 347 new jingle_glue::FakeSocketFactory(socket_manager_, ip))); | 345 new jingle_glue::FakeSocketFactory(socket_manager_, ip))); |
| 348 | 346 |
| 349 ASSERT_TRUE(net::ParseIPLiteralToNumber(kTestAddress2, &ip)); | 347 ASSERT_TRUE(net::ParseIPLiteralToNumber(kTestAddress2, &ip)); |
| 350 transport2_.reset(new P2PTransportImpl( | 348 transport2_.reset(new P2PTransportImpl( |
| 351 new jingle_glue::FakeNetworkManager(ip), | 349 new jingle_glue::FakeNetworkManager(ip), |
| 352 new jingle_glue::FakeSocketFactory(socket_manager_, ip))); | 350 new jingle_glue::FakeSocketFactory(socket_manager_, ip))); |
| 353 } | 351 } |
| 354 | 352 |
| 355 void Init(P2PTransport::Protocol protocol) { | 353 void Init(P2PTransport::Protocol protocol) { |
| 354 P2PTransport::Config config; |
| 356 ASSERT_TRUE(transport1_->Init( | 355 ASSERT_TRUE(transport1_->Init( |
| 357 kTransportName1, protocol, kTestConfig, &event_handler1_)); | 356 kTransportName1, protocol, config, &event_handler1_)); |
| 358 ASSERT_TRUE(transport2_->Init( | 357 ASSERT_TRUE(transport2_->Init( |
| 359 kTransportName2, protocol, kTestConfig, &event_handler2_)); | 358 kTransportName2, protocol, config, &event_handler2_)); |
| 360 } | 359 } |
| 361 | 360 |
| 362 MessageLoop message_loop_; | 361 MessageLoop message_loop_; |
| 363 | 362 |
| 364 scoped_refptr<jingle_glue::FakeSocketManager> socket_manager_; | 363 scoped_refptr<jingle_glue::FakeSocketManager> socket_manager_; |
| 365 scoped_ptr<P2PTransportImpl> transport1_; | 364 scoped_ptr<P2PTransportImpl> transport1_; |
| 366 MockP2PEventHandler event_handler1_; | 365 MockP2PEventHandler event_handler1_; |
| 367 scoped_ptr<P2PTransportImpl> transport2_; | 366 scoped_ptr<P2PTransportImpl> transport2_; |
| 368 MockP2PEventHandler event_handler2_; | 367 MockP2PEventHandler event_handler2_; |
| 369 }; | 368 }; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 480 |
| 482 message_loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), | 481 message_loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), |
| 483 TestTimeouts::action_max_timeout_ms()); | 482 TestTimeouts::action_max_timeout_ms()); |
| 484 | 483 |
| 485 channel_tester->Init(); | 484 channel_tester->Init(); |
| 486 message_loop_.Run(); | 485 message_loop_.Run(); |
| 487 channel_tester->CheckResults(); | 486 channel_tester->CheckResults(); |
| 488 } | 487 } |
| 489 | 488 |
| 490 } // namespace content | 489 } // namespace content |
| OLD | NEW |