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 #include "content/browser/renderer_host/p2p/socket_host_udp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_udp.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | |
9 #include <deque> | 8 #include <deque> |
| 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/sys_byteorder.h" | 13 #include "base/sys_byteorder.h" |
14 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" | 14 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" |
15 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" | 15 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" |
16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
17 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 #include "net/udp/datagram_server_socket.h" | 19 #include "net/udp/datagram_server_socket.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 socket_ = new FakeDatagramServerSocket(&sent_packets_); | 181 socket_ = new FakeDatagramServerSocket(&sent_packets_); |
182 socket_host_->socket_.reset(socket_); | 182 socket_host_->socket_.reset(socket_); |
183 | 183 |
184 local_address_ = ParseAddress(kTestLocalIpAddress, kTestPort1); | 184 local_address_ = ParseAddress(kTestLocalIpAddress, kTestPort1); |
185 socket_host_->Init(local_address_, P2PHostAndIPEndPoint()); | 185 socket_host_->Init(local_address_, P2PHostAndIPEndPoint()); |
186 | 186 |
187 dest1_ = ParseAddress(kTestIpAddress1, kTestPort1); | 187 dest1_ = ParseAddress(kTestIpAddress1, kTestPort1); |
188 dest2_ = ParseAddress(kTestIpAddress2, kTestPort2); | 188 dest2_ = ParseAddress(kTestIpAddress2, kTestPort2); |
189 | 189 |
190 scoped_ptr<rtc::Timing> timing(new FakeTiming()); | 190 scoped_ptr<rtc::Timing> timing(new FakeTiming()); |
191 throttler_.SetTiming(timing.Pass()); | 191 throttler_.SetTiming(std::move(timing)); |
192 } | 192 } |
193 | 193 |
194 P2PMessageThrottler throttler_; | 194 P2PMessageThrottler throttler_; |
195 std::deque<FakeDatagramServerSocket::UDPPacket> sent_packets_; | 195 std::deque<FakeDatagramServerSocket::UDPPacket> sent_packets_; |
196 FakeDatagramServerSocket* socket_; // Owned by |socket_host_|. | 196 FakeDatagramServerSocket* socket_; // Owned by |socket_host_|. |
197 scoped_ptr<P2PSocketHostUdp> socket_host_; | 197 scoped_ptr<P2PSocketHostUdp> socket_host_; |
198 MockIPCSender sender_; | 198 MockIPCSender sender_; |
199 | 199 |
200 net::IPEndPoint local_address_; | 200 net::IPEndPoint local_address_; |
201 | 201 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 socket_host_->Send(dest3, packet1, options, 0); | 375 socket_host_->Send(dest3, packet1, options, 0); |
376 net::IPEndPoint dest4 = ParseAddress(kTestIpAddress1, 2224); | 376 net::IPEndPoint dest4 = ParseAddress(kTestIpAddress1, 2224); |
377 // This packet should also be dropped. | 377 // This packet should also be dropped. |
378 socket_host_->Send(dest4, packet1, options, 0); | 378 socket_host_->Send(dest4, packet1, options, 0); |
379 // |dest1| is known, we can send as many packets to it. | 379 // |dest1| is known, we can send as many packets to it. |
380 socket_host_->Send(dest1_, packet1, options, 0); | 380 socket_host_->Send(dest1_, packet1, options, 0); |
381 ASSERT_EQ(sent_packets_.size(), 4U); | 381 ASSERT_EQ(sent_packets_.size(), 4U); |
382 } | 382 } |
383 | 383 |
384 } // namespace content | 384 } // namespace content |
OLD | NEW |