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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 reinterpret_cast<char*>(&actual_size), &option_size); | 531 reinterpret_cast<char*>(&actual_size), &option_size); |
532 if (rv != 0) | 532 if (rv != 0) |
533 return MapSystemError(WSAGetLastError()); | 533 return MapSystemError(WSAGetLastError()); |
534 if (actual_size >= size) | 534 if (actual_size >= size) |
535 return OK; | 535 return OK; |
536 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketUnchangeableSendBuffer", | 536 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketUnchangeableSendBuffer", |
537 actual_size, 1000, 1000000, 50); | 537 actual_size, 1000, 1000000, 50); |
538 return ERR_SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE; | 538 return ERR_SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE; |
539 } | 539 } |
540 | 540 |
| 541 int UDPSocketWin::SetDoNotFragment() { |
| 542 DCHECK_NE(socket_, INVALID_SOCKET); |
| 543 DCHECK(CalledOnValidThread()); |
| 544 DWORD val = 1; |
| 545 int rv = setsockopt(socket_, IPPROTO_IP, IP_DONTFRAGMENT, |
| 546 reinterpret_cast<const char*>(&val), sizeof(val)); |
| 547 return rv == 0 ? OK : MapSystemError(WSAGetLastError()); |
| 548 } |
| 549 |
541 int UDPSocketWin::AllowAddressReuse() { | 550 int UDPSocketWin::AllowAddressReuse() { |
542 DCHECK_NE(socket_, INVALID_SOCKET); | 551 DCHECK_NE(socket_, INVALID_SOCKET); |
543 DCHECK(CalledOnValidThread()); | 552 DCHECK(CalledOnValidThread()); |
544 DCHECK(!is_connected()); | 553 DCHECK(!is_connected()); |
545 | 554 |
546 BOOL true_value = TRUE; | 555 BOOL true_value = TRUE; |
547 int rv = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, | 556 int rv = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, |
548 reinterpret_cast<const char*>(&true_value), | 557 reinterpret_cast<const char*>(&true_value), |
549 sizeof(true_value)); | 558 sizeof(true_value)); |
550 return rv == 0 ? OK : MapSystemError(WSAGetLastError()); | 559 return rv == 0 ? OK : MapSystemError(WSAGetLastError()); |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 void UDPSocketWin::DetachFromThread() { | 1184 void UDPSocketWin::DetachFromThread() { |
1176 base::NonThreadSafe::DetachFromThread(); | 1185 base::NonThreadSafe::DetachFromThread(); |
1177 } | 1186 } |
1178 | 1187 |
1179 void UDPSocketWin::UseNonBlockingIO() { | 1188 void UDPSocketWin::UseNonBlockingIO() { |
1180 DCHECK(!core_); | 1189 DCHECK(!core_); |
1181 use_non_blocking_io_ = true; | 1190 use_non_blocking_io_ = true; |
1182 } | 1191 } |
1183 | 1192 |
1184 } // namespace net | 1193 } // namespace net |
OLD | NEW |