| 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_libevent.h" | 5 #include "net/udp/udp_socket_libevent.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <net/if.h> | 9 #include <net/if.h> |
| 10 #include <netdb.h> | 10 #include <netdb.h> |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 489 |
| 490 void UDPSocketLibevent::LogRead(int result, | 490 void UDPSocketLibevent::LogRead(int result, |
| 491 const char* bytes, | 491 const char* bytes, |
| 492 socklen_t addr_len, | 492 socklen_t addr_len, |
| 493 const sockaddr* addr) const { | 493 const sockaddr* addr) const { |
| 494 if (result < 0) { | 494 if (result < 0) { |
| 495 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_RECEIVE_ERROR, result); | 495 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_RECEIVE_ERROR, result); |
| 496 return; | 496 return; |
| 497 } | 497 } |
| 498 | 498 |
| 499 if (net_log_.GetCaptureMode().enabled()) { | 499 if (net_log_.IsCapturing()) { |
| 500 DCHECK(addr_len > 0); | 500 DCHECK(addr_len > 0); |
| 501 DCHECK(addr); | 501 DCHECK(addr); |
| 502 | 502 |
| 503 IPEndPoint address; | 503 IPEndPoint address; |
| 504 bool is_address_valid = address.FromSockAddr(addr, addr_len); | 504 bool is_address_valid = address.FromSockAddr(addr, addr_len); |
| 505 net_log_.AddEvent( | 505 net_log_.AddEvent( |
| 506 NetLog::TYPE_UDP_BYTES_RECEIVED, | 506 NetLog::TYPE_UDP_BYTES_RECEIVED, |
| 507 CreateNetLogUDPDataTranferCallback( | 507 CreateNetLogUDPDataTranferCallback( |
| 508 result, bytes, | 508 result, bytes, |
| 509 is_address_valid ? &address : NULL)); | 509 is_address_valid ? &address : NULL)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 526 } | 526 } |
| 527 | 527 |
| 528 void UDPSocketLibevent::LogWrite(int result, | 528 void UDPSocketLibevent::LogWrite(int result, |
| 529 const char* bytes, | 529 const char* bytes, |
| 530 const IPEndPoint* address) const { | 530 const IPEndPoint* address) const { |
| 531 if (result < 0) { | 531 if (result < 0) { |
| 532 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_SEND_ERROR, result); | 532 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_SEND_ERROR, result); |
| 533 return; | 533 return; |
| 534 } | 534 } |
| 535 | 535 |
| 536 if (net_log_.GetCaptureMode().enabled()) { | 536 if (net_log_.IsCapturing()) { |
| 537 net_log_.AddEvent( | 537 net_log_.AddEvent( |
| 538 NetLog::TYPE_UDP_BYTES_SENT, | 538 NetLog::TYPE_UDP_BYTES_SENT, |
| 539 CreateNetLogUDPDataTranferCallback(result, bytes, address)); | 539 CreateNetLogUDPDataTranferCallback(result, bytes, address)); |
| 540 } | 540 } |
| 541 | 541 |
| 542 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(result); | 542 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(result); |
| 543 } | 543 } |
| 544 | 544 |
| 545 int UDPSocketLibevent::InternalRecvFrom(IOBuffer* buf, int buf_len, | 545 int UDPSocketLibevent::InternalRecvFrom(IOBuffer* buf, int buf_len, |
| 546 IPEndPoint* address) { | 546 IPEndPoint* address) { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 return MapSystemError(errno); | 826 return MapSystemError(errno); |
| 827 | 827 |
| 828 return OK; | 828 return OK; |
| 829 } | 829 } |
| 830 | 830 |
| 831 void UDPSocketLibevent::DetachFromThread() { | 831 void UDPSocketLibevent::DetachFromThread() { |
| 832 base::NonThreadSafe::DetachFromThread(); | 832 base::NonThreadSafe::DetachFromThread(); |
| 833 } | 833 } |
| 834 | 834 |
| 835 } // namespace net | 835 } // namespace net |
| OLD | NEW |