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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 void UDPSocketLibevent::LogRead(int result, | 408 void UDPSocketLibevent::LogRead(int result, |
409 const char* bytes, | 409 const char* bytes, |
410 socklen_t addr_len, | 410 socklen_t addr_len, |
411 const sockaddr* addr) const { | 411 const sockaddr* addr) const { |
412 if (result < 0) { | 412 if (result < 0) { |
413 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_RECEIVE_ERROR, result); | 413 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_RECEIVE_ERROR, result); |
414 return; | 414 return; |
415 } | 415 } |
416 | 416 |
417 if (net_log_.GetCaptureMode().enabled()) { | 417 if (net_log_.IsCapturing()) { |
418 DCHECK(addr_len > 0); | 418 DCHECK(addr_len > 0); |
419 DCHECK(addr); | 419 DCHECK(addr); |
420 | 420 |
421 IPEndPoint address; | 421 IPEndPoint address; |
422 bool is_address_valid = address.FromSockAddr(addr, addr_len); | 422 bool is_address_valid = address.FromSockAddr(addr, addr_len); |
423 net_log_.AddEvent( | 423 net_log_.AddEvent( |
424 NetLog::TYPE_UDP_BYTES_RECEIVED, | 424 NetLog::TYPE_UDP_BYTES_RECEIVED, |
425 CreateNetLogUDPDataTranferCallback( | 425 CreateNetLogUDPDataTranferCallback( |
426 result, bytes, | 426 result, bytes, |
427 is_address_valid ? &address : NULL)); | 427 is_address_valid ? &address : NULL)); |
(...skipping 16 matching lines...) Expand all Loading... |
444 } | 444 } |
445 | 445 |
446 void UDPSocketLibevent::LogWrite(int result, | 446 void UDPSocketLibevent::LogWrite(int result, |
447 const char* bytes, | 447 const char* bytes, |
448 const IPEndPoint* address) const { | 448 const IPEndPoint* address) const { |
449 if (result < 0) { | 449 if (result < 0) { |
450 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_SEND_ERROR, result); | 450 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_SEND_ERROR, result); |
451 return; | 451 return; |
452 } | 452 } |
453 | 453 |
454 if (net_log_.GetCaptureMode().enabled()) { | 454 if (net_log_.IsCapturing()) { |
455 net_log_.AddEvent( | 455 net_log_.AddEvent( |
456 NetLog::TYPE_UDP_BYTES_SENT, | 456 NetLog::TYPE_UDP_BYTES_SENT, |
457 CreateNetLogUDPDataTranferCallback(result, bytes, address)); | 457 CreateNetLogUDPDataTranferCallback(result, bytes, address)); |
458 } | 458 } |
459 | 459 |
460 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(result); | 460 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(result); |
461 } | 461 } |
462 | 462 |
463 int UDPSocketLibevent::InternalRecvFrom(IOBuffer* buf, int buf_len, | 463 int UDPSocketLibevent::InternalRecvFrom(IOBuffer* buf, int buf_len, |
464 IPEndPoint* address) { | 464 IPEndPoint* address) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 return MapSystemError(errno); | 744 return MapSystemError(errno); |
745 | 745 |
746 return OK; | 746 return OK; |
747 } | 747 } |
748 | 748 |
749 void UDPSocketLibevent::DetachFromThread() { | 749 void UDPSocketLibevent::DetachFromThread() { |
750 base::NonThreadSafe::DetachFromThread(); | 750 base::NonThreadSafe::DetachFromThread(); |
751 } | 751 } |
752 | 752 |
753 } // namespace net | 753 } // namespace net |
OLD | NEW |