Chromium Code Reviews| 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 "net/udp/udp_socket_win.h" | 5 #include "net/udp/udp_socket_win.h" |
| 6 | 6 |
| 7 #include <mstcpip.h> | 7 #include <mstcpip.h> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 socket_ = CreatePlatformSocket(addr_family_, SOCK_DGRAM, IPPROTO_UDP); | 384 socket_ = CreatePlatformSocket(addr_family_, SOCK_DGRAM, IPPROTO_UDP); |
| 385 if (socket_ == INVALID_SOCKET) | 385 if (socket_ == INVALID_SOCKET) |
| 386 return MapSystemError(WSAGetLastError()); | 386 return MapSystemError(WSAGetLastError()); |
| 387 core_ = new Core(this); | 387 core_ = new Core(this); |
| 388 return OK; | 388 return OK; |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool UDPSocketWin::SetReceiveBufferSize(int32 size) { | 391 bool UDPSocketWin::SetReceiveBufferSize(int32 size) { |
| 392 DCHECK(CalledOnValidThread()); | 392 DCHECK(CalledOnValidThread()); |
| 393 setsockopt(socket_, SOL_SOCKET, SO_RCVBUF, | 393 setsockopt(socket_, SOL_SOCKET, SO_RCVBUF, |
| 394 reinterpret_cast<const char*>(&size), sizeof(size)); | 394 reinterpret_cast<const char*>(&size), sizeof(size)); |
|
wtc
2014/03/25 17:27:47
The indentation of this should wait until the othe
| |
| 395 // If the setsockopt fails, but the buffer is big enough, we will return | 395 // If the setsockopt fails, but the buffer is big enough, we will return |
| 396 // success. It is not worth testing the return value as we still need to check | 396 // success. It is not worth testing the return value as we still need to check |
| 397 // via getsockopt anyway according to Windows documentation. | 397 // via getsockopt anyway according to Windows documentation. |
| 398 int32 actual_size = 0; | 398 int32 actual_size = 0; |
| 399 int option_size = sizeof(actual_size); | 399 int option_size = sizeof(actual_size); |
| 400 int rv = getsockopt(socket_, SOL_SOCKET, SO_RCVBUF, | 400 int rv = getsockopt(socket_, SOL_SOCKET, SO_RCVBUF, |
| 401 reinterpret_cast<char*>(&actual_size), &option_size); | 401 reinterpret_cast<char*>(&actual_size), &option_size); |
| 402 if (rv != 0) | 402 if (rv != 0) |
| 403 return false; | 403 return false; |
| 404 if (actual_size < size) { | 404 if (actual_size < size) { |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 // Note: setsockopt(IP_TOS) does not work on windows XP and later. | 832 // Note: setsockopt(IP_TOS) does not work on windows XP and later. |
| 833 int UDPSocketWin::SetDiffServCodePoint(DiffServCodePoint dscp) { | 833 int UDPSocketWin::SetDiffServCodePoint(DiffServCodePoint dscp) { |
| 834 return ERR_NOT_IMPLEMENTED; | 834 return ERR_NOT_IMPLEMENTED; |
| 835 } | 835 } |
| 836 | 836 |
| 837 void UDPSocketWin::DetachFromThread() { | 837 void UDPSocketWin::DetachFromThread() { |
| 838 base::NonThreadSafe::DetachFromThread(); | 838 base::NonThreadSafe::DetachFromThread(); |
| 839 } | 839 } |
| 840 | 840 |
| 841 } // namespace net | 841 } // namespace net |
| OLD | NEW |