| 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 #include <deque> | 8 #include <deque> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 int SetSendBufferSize(int32_t size) override { return net::OK; } | 114 int SetSendBufferSize(int32_t size) override { return net::OK; } |
| 115 | 115 |
| 116 void ReceivePacket(const net::IPEndPoint& address, std::vector<char> data) { | 116 void ReceivePacket(const net::IPEndPoint& address, std::vector<char> data) { |
| 117 if (!recv_callback_.is_null()) { | 117 if (!recv_callback_.is_null()) { |
| 118 int size = std::min(recv_size_, static_cast<int>(data.size())); | 118 int size = std::min(recv_size_, static_cast<int>(data.size())); |
| 119 memcpy(recv_buffer_->data(), &*data.begin(), size); | 119 memcpy(recv_buffer_->data(), &*data.begin(), size); |
| 120 *recv_address_ = address; | 120 *recv_address_ = address; |
| 121 net::CompletionCallback cb = recv_callback_; | 121 net::CompletionCallback cb = recv_callback_; |
| 122 recv_callback_.Reset(); | 122 recv_callback_.Reset(); |
| 123 recv_buffer_ = NULL; | 123 recv_buffer_ = nullptr; |
| 124 cb.Run(size); | 124 cb.Run(size); |
| 125 } else { | 125 } else { |
| 126 incoming_packets_.push_back(UDPPacket(address, data)); | 126 incoming_packets_.push_back(UDPPacket(address, data)); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 const net::BoundNetLog& NetLog() const override { return net_log_; } | 130 const net::BoundNetLog& NetLog() const override { return net_log_; } |
| 131 | 131 |
| 132 void AllowAddressReuse() override { NOTIMPLEMENTED(); } | 132 void AllowAddressReuse() override { NOTIMPLEMENTED(); } |
| 133 | 133 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 std::unique_ptr<P2PSocketHostUdp> socket_host( | 498 std::unique_ptr<P2PSocketHostUdp> socket_host( |
| 499 new P2PSocketHostUdp(&sender, 0, &throttler, fake_socket_factory)); | 499 new P2PSocketHostUdp(&sender, 0, &throttler, fake_socket_factory)); |
| 500 net::IPEndPoint local_address = | 500 net::IPEndPoint local_address = |
| 501 ParseAddress(kTestLocalIpAddress, invalid_port); | 501 ParseAddress(kTestLocalIpAddress, invalid_port); |
| 502 bool rv = socket_host->Init(local_address, min_port, max_port, | 502 bool rv = socket_host->Init(local_address, min_port, max_port, |
| 503 P2PHostAndIPEndPoint()); | 503 P2PHostAndIPEndPoint()); |
| 504 EXPECT_FALSE(rv); | 504 EXPECT_FALSE(rv); |
| 505 } | 505 } |
| 506 | 506 |
| 507 } // namespace content | 507 } // namespace content |
| OLD | NEW |