| 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 <deque> | 7 #include <deque> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 class FakeDatagramServerSocket : public net::DatagramServerSocket { | 39 class FakeDatagramServerSocket : public net::DatagramServerSocket { |
| 40 public: | 40 public: |
| 41 typedef std::pair<net::IPEndPoint, std::vector<char> > UDPPacket; | 41 typedef std::pair<net::IPEndPoint, std::vector<char> > UDPPacket; |
| 42 | 42 |
| 43 // P2PSocketHostUdp destroyes a socket on errors so sent packets | 43 // P2PSocketHostUdp destroyes a socket on errors so sent packets |
| 44 // need to be stored outside of this object. | 44 // need to be stored outside of this object. |
| 45 explicit FakeDatagramServerSocket(std::deque<UDPPacket>* sent_packets) | 45 explicit FakeDatagramServerSocket(std::deque<UDPPacket>* sent_packets) |
| 46 : sent_packets_(sent_packets) { | 46 : sent_packets_(sent_packets) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 void Close() override {} | 49 int Close() override { return net::OK; } |
| 50 | 50 |
| 51 int GetPeerAddress(net::IPEndPoint* address) const override { | 51 int GetPeerAddress(net::IPEndPoint* address) const override { |
| 52 NOTREACHED(); | 52 NOTREACHED(); |
| 53 return net::ERR_SOCKET_NOT_CONNECTED; | 53 return net::ERR_SOCKET_NOT_CONNECTED; |
| 54 } | 54 } |
| 55 | 55 |
| 56 int GetLocalAddress(net::IPEndPoint* address) const override { | 56 int GetLocalAddress(net::IPEndPoint* address) const override { |
| 57 *address = address_; | 57 *address = address_; |
| 58 return 0; | 58 return 0; |
| 59 } | 59 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 socket_host_->Send(dest3, packet1, options, 0); | 367 socket_host_->Send(dest3, packet1, options, 0); |
| 368 net::IPEndPoint dest4 = ParseAddress(kTestIpAddress1, 2224); | 368 net::IPEndPoint dest4 = ParseAddress(kTestIpAddress1, 2224); |
| 369 // This packet should also be dropped. | 369 // This packet should also be dropped. |
| 370 socket_host_->Send(dest4, packet1, options, 0); | 370 socket_host_->Send(dest4, packet1, options, 0); |
| 371 // |dest1| is known, we can send as many packets to it. | 371 // |dest1| is known, we can send as many packets to it. |
| 372 socket_host_->Send(dest1_, packet1, options, 0); | 372 socket_host_->Send(dest1_, packet1, options, 0); |
| 373 ASSERT_EQ(sent_packets_.size(), 4U); | 373 ASSERT_EQ(sent_packets_.size(), 4U); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace content | 376 } // namespace content |
| OLD | NEW |