| 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 NetLog::TYPE_UDP_BYTES_SENT, | 623 NetLog::TYPE_UDP_BYTES_SENT, |
| 624 CreateNetLogUDPDataTranferCallback(result, bytes, address)); | 624 CreateNetLogUDPDataTranferCallback(result, bytes, address)); |
| 625 } | 625 } |
| 626 | 626 |
| 627 base::StatsCounter write_bytes("udp.write_bytes"); | 627 base::StatsCounter write_bytes("udp.write_bytes"); |
| 628 write_bytes.Add(result); | 628 write_bytes.Add(result); |
| 629 } | 629 } |
| 630 | 630 |
| 631 int UDPSocketWin::InternalRecvFrom(IOBuffer* buf, int buf_len, | 631 int UDPSocketWin::InternalRecvFrom(IOBuffer* buf, int buf_len, |
| 632 IPEndPoint* address) { | 632 IPEndPoint* address) { |
| 633 DCHECK(!core_->read_iobuffer_); | 633 DCHECK(!core_->read_iobuffer_.get()); |
| 634 SockaddrStorage& storage = core_->recv_addr_storage_; | 634 SockaddrStorage& storage = core_->recv_addr_storage_; |
| 635 storage.addr_len = sizeof(storage.addr_storage); | 635 storage.addr_len = sizeof(storage.addr_storage); |
| 636 | 636 |
| 637 WSABUF read_buffer; | 637 WSABUF read_buffer; |
| 638 read_buffer.buf = buf->data(); | 638 read_buffer.buf = buf->data(); |
| 639 read_buffer.len = buf_len; | 639 read_buffer.len = buf_len; |
| 640 | 640 |
| 641 DWORD flags = 0; | 641 DWORD flags = 0; |
| 642 DWORD num; | 642 DWORD num; |
| 643 CHECK_NE(INVALID_SOCKET, socket_); | 643 CHECK_NE(INVALID_SOCKET, socket_); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 663 return result; | 663 return result; |
| 664 } | 664 } |
| 665 } | 665 } |
| 666 core_->WatchForRead(); | 666 core_->WatchForRead(); |
| 667 core_->read_iobuffer_ = buf; | 667 core_->read_iobuffer_ = buf; |
| 668 return ERR_IO_PENDING; | 668 return ERR_IO_PENDING; |
| 669 } | 669 } |
| 670 | 670 |
| 671 int UDPSocketWin::InternalSendTo(IOBuffer* buf, int buf_len, | 671 int UDPSocketWin::InternalSendTo(IOBuffer* buf, int buf_len, |
| 672 const IPEndPoint* address) { | 672 const IPEndPoint* address) { |
| 673 DCHECK(!core_->write_iobuffer_); | 673 DCHECK(!core_->write_iobuffer_.get()); |
| 674 SockaddrStorage storage; | 674 SockaddrStorage storage; |
| 675 struct sockaddr* addr = storage.addr; | 675 struct sockaddr* addr = storage.addr; |
| 676 // Convert address. | 676 // Convert address. |
| 677 if (!address) { | 677 if (!address) { |
| 678 addr = NULL; | 678 addr = NULL; |
| 679 storage.addr_len = 0; | 679 storage.addr_len = 0; |
| 680 } else { | 680 } else { |
| 681 if (!address->ToSockAddr(addr, &storage.addr_len)) { | 681 if (!address->ToSockAddr(addr, &storage.addr_len)) { |
| 682 int result = ERR_ADDRESS_INVALID; | 682 int result = ERR_ADDRESS_INVALID; |
| 683 LogWrite(result, NULL, NULL); | 683 LogWrite(result, NULL, NULL); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 NULL); | 1016 NULL); |
| 1017 | 1017 |
| 1018 return OK; | 1018 return OK; |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 void UDPSocketWin::DetachFromThread() { | 1021 void UDPSocketWin::DetachFromThread() { |
| 1022 base::NonThreadSafe::DetachFromThread(); | 1022 base::NonThreadSafe::DetachFromThread(); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 } // namespace net | 1025 } // namespace net |
| OLD | NEW |