| 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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 415 |
| 416 std::unique_ptr<P2PSocketHost> P2PSocketHostUdp::AcceptIncomingTcpConnection( | 416 std::unique_ptr<P2PSocketHost> P2PSocketHostUdp::AcceptIncomingTcpConnection( |
| 417 const net::IPEndPoint& remote_address, | 417 const net::IPEndPoint& remote_address, |
| 418 int id) { | 418 int id) { |
| 419 NOTREACHED(); | 419 NOTREACHED(); |
| 420 OnError(); | 420 OnError(); |
| 421 return nullptr; | 421 return nullptr; |
| 422 } | 422 } |
| 423 | 423 |
| 424 bool P2PSocketHostUdp::SetOption(P2PSocketOption option, int value) { | 424 bool P2PSocketHostUdp::SetOption(P2PSocketOption option, int value) { |
| 425 DCHECK_EQ(STATE_OPEN, state_); | 425 if (state_ != STATE_OPEN) { |
| 426 DCHECK_EQ(state_, STATE_ERROR); |
| 427 return false; |
| 428 } |
| 429 |
| 426 switch (option) { | 430 switch (option) { |
| 427 case P2P_SOCKET_OPT_RCVBUF: | 431 case P2P_SOCKET_OPT_RCVBUF: |
| 428 return socket_->SetReceiveBufferSize(value) == net::OK; | 432 return socket_->SetReceiveBufferSize(value) == net::OK; |
| 429 case P2P_SOCKET_OPT_SNDBUF: | 433 case P2P_SOCKET_OPT_SNDBUF: |
| 430 // Ignore any following call to set the send buffer size if we're under | 434 // Ignore any following call to set the send buffer size if we're under |
| 431 // experiment. | 435 // experiment. |
| 432 if (send_buffer_size_ > 0) { | 436 if (send_buffer_size_ > 0) { |
| 433 return true; | 437 return true; |
| 434 } | 438 } |
| 435 return socket_->SetSendBufferSize(value) == net::OK; | 439 return socket_->SetSendBufferSize(value) == net::OK; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 448 net::UDPServerSocket* socket = new net::UDPServerSocket( | 452 net::UDPServerSocket* socket = new net::UDPServerSocket( |
| 449 GetContentClient()->browser()->GetNetLog(), net::NetLogSource()); | 453 GetContentClient()->browser()->GetNetLog(), net::NetLogSource()); |
| 450 #if defined(OS_WIN) | 454 #if defined(OS_WIN) |
| 451 socket->UseNonBlockingIO(); | 455 socket->UseNonBlockingIO(); |
| 452 #endif | 456 #endif |
| 453 | 457 |
| 454 return base::WrapUnique(socket); | 458 return base::WrapUnique(socket); |
| 455 } | 459 } |
| 456 | 460 |
| 457 } // namespace content | 461 } // namespace content |
| OLD | NEW |