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/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 memcpy(data->data(), &content[0], size); | 65 memcpy(data->data(), &content[0], size); |
66 } | 66 } |
67 | 67 |
68 P2PSocketHostUdp::PendingPacket::~PendingPacket() { | 68 P2PSocketHostUdp::PendingPacket::~PendingPacket() { |
69 } | 69 } |
70 | 70 |
71 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender, | 71 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender, |
72 int socket_id, | 72 int socket_id, |
73 P2PMessageThrottler* throttler) | 73 P2PMessageThrottler* throttler) |
74 : P2PSocketHost(message_sender, socket_id, P2PSocketHost::UDP), | 74 : P2PSocketHost(message_sender, socket_id, P2PSocketHost::UDP), |
75 socket_( | |
76 new net::UDPServerSocket(GetContentClient()->browser()->GetNetLog(), | |
77 net::NetLog::Source())), | |
78 send_pending_(false), | 75 send_pending_(false), |
79 last_dscp_(net::DSCP_CS0), | 76 last_dscp_(net::DSCP_CS0), |
80 throttler_(throttler), | 77 throttler_(throttler), |
81 send_buffer_size_(0) { | 78 send_buffer_size_(0) { |
| 79 net::UDPServerSocket* socket = new net::UDPServerSocket( |
| 80 GetContentClient()->browser()->GetNetLog(), net::NetLog::Source()); |
| 81 #if defined(OS_WIN) |
| 82 // If configured for finch experiment, use nonblocking IO. |
| 83 if (base::FieldTrialList::FindFullName("WebRTC-UDPSocketNonBlockingIO") == |
| 84 "Enabled") { |
| 85 socket->UseNonBlockingIO(); |
| 86 } |
| 87 #endif |
| 88 socket_.reset(socket); |
82 } | 89 } |
83 | 90 |
84 P2PSocketHostUdp::~P2PSocketHostUdp() { | 91 P2PSocketHostUdp::~P2PSocketHostUdp() { |
85 if (state_ == STATE_OPEN) { | 92 if (state_ == STATE_OPEN) { |
86 DCHECK(socket_.get()); | 93 DCHECK(socket_.get()); |
87 socket_.reset(); | 94 socket_.reset(); |
88 } | 95 } |
89 } | 96 } |
90 | 97 |
91 void P2PSocketHostUdp::SetSendBufferSize() { | 98 void P2PSocketHostUdp::SetSendBufferSize() { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 case P2P_SOCKET_OPT_DSCP: | 378 case P2P_SOCKET_OPT_DSCP: |
372 return (net::OK == socket_->SetDiffServCodePoint( | 379 return (net::OK == socket_->SetDiffServCodePoint( |
373 static_cast<net::DiffServCodePoint>(value))) ? true : false; | 380 static_cast<net::DiffServCodePoint>(value))) ? true : false; |
374 default: | 381 default: |
375 NOTREACHED(); | 382 NOTREACHED(); |
376 return false; | 383 return false; |
377 } | 384 } |
378 } | 385 } |
379 | 386 |
380 } // namespace content | 387 } // namespace content |
OLD | NEW |