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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" |
11 #include "content/common/p2p_messages.h" | 11 #include "content/common/p2p_messages.h" |
12 #include "ipc/ipc_sender.h" | 12 #include "ipc/ipc_sender.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // UDP packets cannot be bigger than 64k. | 20 // UDP packets cannot be bigger than 64k. |
20 const int kReadBufferSize = 65536; | 21 const int kReadBufferSize = 65536; |
21 // Socket receive buffer size. | 22 // Socket receive buffer size. |
22 const int kRecvSocketBufferSize = 65536; // 64K | 23 const int kRecvSocketBufferSize = 65536; // 64K |
23 | 24 |
24 // Defines set of transient errors. These errors are ignored when we get them | 25 // Defines set of transient errors. These errors are ignored when we get them |
25 // from sendto() or recvfrom() calls. | 26 // from sendto() or recvfrom() calls. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 int result = socket_->SetDiffServCodePoint(packet.dscp); | 221 int result = socket_->SetDiffServCodePoint(packet.dscp); |
221 if (result == net::OK) { | 222 if (result == net::OK) { |
222 last_dscp_ = packet.dscp; | 223 last_dscp_ = packet.dscp; |
223 } else if (!IsTransientError(result) && last_dscp_ != net::DSCP_CS0) { | 224 } else if (!IsTransientError(result) && last_dscp_ != net::DSCP_CS0) { |
224 // We receieved a non-transient error, and it seems we have | 225 // We receieved a non-transient error, and it seems we have |
225 // not changed the DSCP in the past, disable DSCP as it unlikely | 226 // not changed the DSCP in the past, disable DSCP as it unlikely |
226 // to work in the future. | 227 // to work in the future. |
227 last_dscp_ = net::DSCP_NO_CHANGE; | 228 last_dscp_ = net::DSCP_NO_CHANGE; |
228 } | 229 } |
229 } | 230 } |
| 231 talk_base::PacketOptions options; |
| 232 packet_processing_helpers::MaybeUpdatePacketAbsSendTimeExtn( |
| 233 packet.data->data(), packet.size, options); |
230 int result = socket_->SendTo( | 234 int result = socket_->SendTo( |
231 packet.data.get(), | 235 packet.data.get(), |
232 packet.size, | 236 packet.size, |
233 packet.to, | 237 packet.to, |
234 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this), packet.id)); | 238 base::Bind(&P2PSocketHostUdp::OnSend, base::Unretained(this), packet.id)); |
235 | 239 |
236 // sendto() may return an error, e.g. if we've received an ICMP Destination | 240 // sendto() may return an error, e.g. if we've received an ICMP Destination |
237 // Unreachable message. When this happens try sending the same packet again, | 241 // Unreachable message. When this happens try sending the same packet again, |
238 // and just drop it if it fails again. | 242 // and just drop it if it fails again. |
239 if (IsTransientError(result)) { | 243 if (IsTransientError(result)) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 case P2P_SOCKET_OPT_DSCP: | 302 case P2P_SOCKET_OPT_DSCP: |
299 return (net::OK == socket_->SetDiffServCodePoint( | 303 return (net::OK == socket_->SetDiffServCodePoint( |
300 static_cast<net::DiffServCodePoint>(value))) ? true : false; | 304 static_cast<net::DiffServCodePoint>(value))) ? true : false; |
301 default: | 305 default: |
302 NOTREACHED(); | 306 NOTREACHED(); |
303 return false; | 307 return false; |
304 } | 308 } |
305 } | 309 } |
306 | 310 |
307 } // namespace content | 311 } // namespace content |
OLD | NEW |