Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: net/udp/udp_socket_libevent.cc

Issue 1059843002: Refactor NetLog::LogLevel --> NetLogCaptureMode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again to fix a merge conflict Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/udp/udp_net_log_parameters.cc ('k') | net/udp/udp_socket_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_.IsLogging()) { 499 if (net_log_.GetCaptureMode().enabled()) {
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
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_.IsLogging()) { 536 if (net_log_.GetCaptureMode().enabled()) {
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
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
OLDNEW
« no previous file with comments | « net/udp/udp_net_log_parameters.cc ('k') | net/udp/udp_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698