| 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" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 88 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
| 89 | 89 |
| 90 int result = socket_->Listen(local_address); | 90 int result = socket_->Listen(local_address); |
| 91 if (result < 0) { | 91 if (result < 0) { |
| 92 LOG(ERROR) << "bind() failed: " << result; | 92 LOG(ERROR) << "bind() failed: " << result; |
| 93 OnError(); | 93 OnError(); |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Setting recv socket buffer size. | 97 // Setting recv socket buffer size. |
| 98 if (!socket_->SetReceiveBufferSize(kRecvSocketBufferSize)) { | 98 if (socket_->SetReceiveBufferSize(kRecvSocketBufferSize) != net::OK) { |
| 99 LOG(WARNING) << "Failed to set socket receive buffer size to " | 99 LOG(WARNING) << "Failed to set socket receive buffer size to " |
| 100 << kRecvSocketBufferSize; | 100 << kRecvSocketBufferSize; |
| 101 } | 101 } |
| 102 | 102 |
| 103 net::IPEndPoint address; | 103 net::IPEndPoint address; |
| 104 result = socket_->GetLocalAddress(&address); | 104 result = socket_->GetLocalAddress(&address); |
| 105 if (result < 0) { | 105 if (result < 0) { |
| 106 LOG(ERROR) << "P2PSocketHostUdp::Init(): unable to get local address: " | 106 LOG(ERROR) << "P2PSocketHostUdp::Init(): unable to get local address: " |
| 107 << result; | 107 << result; |
| 108 OnError(); | 108 OnError(); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 const net::IPEndPoint& remote_address, int id) { | 295 const net::IPEndPoint& remote_address, int id) { |
| 296 NOTREACHED(); | 296 NOTREACHED(); |
| 297 OnError(); | 297 OnError(); |
| 298 return NULL; | 298 return NULL; |
| 299 } | 299 } |
| 300 | 300 |
| 301 bool P2PSocketHostUdp::SetOption(P2PSocketOption option, int value) { | 301 bool P2PSocketHostUdp::SetOption(P2PSocketOption option, int value) { |
| 302 DCHECK_EQ(STATE_OPEN, state_); | 302 DCHECK_EQ(STATE_OPEN, state_); |
| 303 switch (option) { | 303 switch (option) { |
| 304 case P2P_SOCKET_OPT_RCVBUF: | 304 case P2P_SOCKET_OPT_RCVBUF: |
| 305 return socket_->SetReceiveBufferSize(value); | 305 return socket_->SetReceiveBufferSize(value) == net::OK; |
| 306 case P2P_SOCKET_OPT_SNDBUF: | 306 case P2P_SOCKET_OPT_SNDBUF: |
| 307 return socket_->SetSendBufferSize(value); | 307 return socket_->SetSendBufferSize(value) == net::OK; |
| 308 case P2P_SOCKET_OPT_DSCP: | 308 case P2P_SOCKET_OPT_DSCP: |
| 309 return (net::OK == socket_->SetDiffServCodePoint( | 309 return (net::OK == socket_->SetDiffServCodePoint( |
| 310 static_cast<net::DiffServCodePoint>(value))) ? true : false; | 310 static_cast<net::DiffServCodePoint>(value))) ? true : false; |
| 311 default: | 311 default: |
| 312 NOTREACHED(); | 312 NOTREACHED(); |
| 313 return false; | 313 return false; |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace content | 317 } // namespace content |
| OLD | NEW |