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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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_socket_libevent.cc ('k') | net/url_request/url_fetcher_core.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_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/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/metrics/sparse_histogram.h" 15 #include "base/metrics/sparse_histogram.h"
16 #include "base/metrics/stats_counters.h"
17 #include "base/profiler/scoped_tracker.h" 16 #include "base/profiler/scoped_tracker.h"
18 #include "base/rand_util.h" 17 #include "base/rand_util.h"
19 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
20 #include "net/base/ip_endpoint.h" 19 #include "net/base/ip_endpoint.h"
21 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
22 #include "net/base/net_log.h" 21 #include "net/base/net_log.h"
23 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
24 #include "net/base/network_activity_monitor.h" 23 #include "net/base/network_activity_monitor.h"
25 #include "net/base/winsock_init.h" 24 #include "net/base/winsock_init.h"
26 #include "net/base/winsock_util.h" 25 #include "net/base/winsock_util.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_RECEIVE_ERROR, result); 691 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_RECEIVE_ERROR, result);
693 return; 692 return;
694 } 693 }
695 694
696 if (net_log_.IsLogging()) { 695 if (net_log_.IsLogging()) {
697 net_log_.AddEvent( 696 net_log_.AddEvent(
698 NetLog::TYPE_UDP_BYTES_RECEIVED, 697 NetLog::TYPE_UDP_BYTES_RECEIVED,
699 CreateNetLogUDPDataTranferCallback(result, bytes, address)); 698 CreateNetLogUDPDataTranferCallback(result, bytes, address));
700 } 699 }
701 700
702 base::StatsCounter read_bytes("udp.read_bytes");
703 read_bytes.Add(result);
704 NetworkActivityMonitor::GetInstance()->IncrementBytesReceived(result); 701 NetworkActivityMonitor::GetInstance()->IncrementBytesReceived(result);
705 } 702 }
706 703
707 void UDPSocketWin::LogWrite(int result, 704 void UDPSocketWin::LogWrite(int result,
708 const char* bytes, 705 const char* bytes,
709 const IPEndPoint* address) const { 706 const IPEndPoint* address) const {
710 if (result < 0) { 707 if (result < 0) {
711 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_SEND_ERROR, result); 708 net_log_.AddEventWithNetErrorCode(NetLog::TYPE_UDP_SEND_ERROR, result);
712 return; 709 return;
713 } 710 }
714 711
715 if (net_log_.IsLogging()) { 712 if (net_log_.IsLogging()) {
716 net_log_.AddEvent( 713 net_log_.AddEvent(
717 NetLog::TYPE_UDP_BYTES_SENT, 714 NetLog::TYPE_UDP_BYTES_SENT,
718 CreateNetLogUDPDataTranferCallback(result, bytes, address)); 715 CreateNetLogUDPDataTranferCallback(result, bytes, address));
719 } 716 }
720 717
721 base::StatsCounter write_bytes("udp.write_bytes");
722 write_bytes.Add(result);
723 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(result); 718 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(result);
724 } 719 }
725 720
726 int UDPSocketWin::InternalRecvFromOverlapped(IOBuffer* buf, 721 int UDPSocketWin::InternalRecvFromOverlapped(IOBuffer* buf,
727 int buf_len, 722 int buf_len,
728 IPEndPoint* address) { 723 IPEndPoint* address) {
729 DCHECK(!core_->read_iobuffer_.get()); 724 DCHECK(!core_->read_iobuffer_.get());
730 SockaddrStorage& storage = core_->recv_addr_storage_; 725 SockaddrStorage& storage = core_->recv_addr_storage_;
731 storage.addr_len = sizeof(storage.addr_storage); 726 storage.addr_len = sizeof(storage.addr_storage);
732 727
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 void UDPSocketWin::DetachFromThread() { 1173 void UDPSocketWin::DetachFromThread() {
1179 base::NonThreadSafe::DetachFromThread(); 1174 base::NonThreadSafe::DetachFromThread();
1180 } 1175 }
1181 1176
1182 void UDPSocketWin::UseNonBlockingIO() { 1177 void UDPSocketWin::UseNonBlockingIO() {
1183 DCHECK(!core_); 1178 DCHECK(!core_);
1184 use_non_blocking_io_ = true; 1179 use_non_blocking_io_ = true;
1185 } 1180 }
1186 1181
1187 } // namespace net 1182 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_libevent.cc ('k') | net/url_request/url_fetcher_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698