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

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

Issue 734063004: Update from https://crrev.com/304418 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/sdch_dictionary_fetcher.h » ('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/callback.h" 9 #include "base/callback.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/metrics/sparse_histogram.h" 14 #include "base/metrics/sparse_histogram.h"
15 #include "base/metrics/stats_counters.h" 15 #include "base/metrics/stats_counters.h"
16 #include "base/profiler/scoped_tracker.h" 16 #include "base/profiler/scoped_tracker.h"
17 #include "base/rand_util.h" 17 #include "base/rand_util.h"
18 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
19 #include "net/base/ip_endpoint.h" 19 #include "net/base/ip_endpoint.h"
20 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
21 #include "net/base/net_log.h" 21 #include "net/base/net_log.h"
22 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
23 #include "net/base/network_activity_monitor.h"
23 #include "net/base/winsock_init.h" 24 #include "net/base/winsock_init.h"
24 #include "net/base/winsock_util.h" 25 #include "net/base/winsock_util.h"
25 #include "net/socket/socket_descriptor.h" 26 #include "net/socket/socket_descriptor.h"
26 #include "net/udp/udp_net_log_parameters.h" 27 #include "net/udp/udp_net_log_parameters.h"
27 28
28 namespace { 29 namespace {
29 30
30 const int kBindRetries = 10; 31 const int kBindRetries = 10;
31 const int kPortStart = 1024; 32 const int kPortStart = 1024;
32 const int kPortEnd = 65535; 33 const int kPortEnd = 65535;
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 bool is_address_valid = ReceiveAddressToIPEndpoint(&address); 589 bool is_address_valid = ReceiveAddressToIPEndpoint(&address);
589 net_log_.AddEvent( 590 net_log_.AddEvent(
590 NetLog::TYPE_UDP_BYTES_RECEIVED, 591 NetLog::TYPE_UDP_BYTES_RECEIVED,
591 CreateNetLogUDPDataTranferCallback( 592 CreateNetLogUDPDataTranferCallback(
592 result, bytes, 593 result, bytes,
593 is_address_valid ? &address : NULL)); 594 is_address_valid ? &address : NULL));
594 } 595 }
595 596
596 base::StatsCounter read_bytes("udp.read_bytes"); 597 base::StatsCounter read_bytes("udp.read_bytes");
597 read_bytes.Add(result); 598 read_bytes.Add(result);
599 NetworkActivityMonitor::GetInstance()->IncrementBytesReceived(result);
598 } 600 }
599 601
600 void UDPSocketWin::DidCompleteWrite() { 602 void UDPSocketWin::DidCompleteWrite() {
601 DWORD num_bytes, flags; 603 DWORD num_bytes, flags;
602 BOOL ok = WSAGetOverlappedResult(socket_, &core_->write_overlapped_, 604 BOOL ok = WSAGetOverlappedResult(socket_, &core_->write_overlapped_,
603 &num_bytes, FALSE, &flags); 605 &num_bytes, FALSE, &flags);
604 WSAResetEvent(core_->write_overlapped_.hEvent); 606 WSAResetEvent(core_->write_overlapped_.hEvent);
605 int result = ok ? num_bytes : MapSystemError(WSAGetLastError()); 607 int result = ok ? num_bytes : MapSystemError(WSAGetLastError());
606 LogWrite(result, core_->write_iobuffer_->data(), send_to_address_.get()); 608 LogWrite(result, core_->write_iobuffer_->data(), send_to_address_.get());
607 609
(...skipping 11 matching lines...) Expand all
619 } 621 }
620 622
621 if (net_log_.IsLogging()) { 623 if (net_log_.IsLogging()) {
622 net_log_.AddEvent( 624 net_log_.AddEvent(
623 NetLog::TYPE_UDP_BYTES_SENT, 625 NetLog::TYPE_UDP_BYTES_SENT,
624 CreateNetLogUDPDataTranferCallback(result, bytes, address)); 626 CreateNetLogUDPDataTranferCallback(result, bytes, address));
625 } 627 }
626 628
627 base::StatsCounter write_bytes("udp.write_bytes"); 629 base::StatsCounter write_bytes("udp.write_bytes");
628 write_bytes.Add(result); 630 write_bytes.Add(result);
631 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(result);
629 } 632 }
630 633
631 int UDPSocketWin::InternalRecvFrom(IOBuffer* buf, int buf_len, 634 int UDPSocketWin::InternalRecvFrom(IOBuffer* buf, int buf_len,
632 IPEndPoint* address) { 635 IPEndPoint* address) {
633 DCHECK(!core_->read_iobuffer_.get()); 636 DCHECK(!core_->read_iobuffer_.get());
634 SockaddrStorage& storage = core_->recv_addr_storage_; 637 SockaddrStorage& storage = core_->recv_addr_storage_;
635 storage.addr_len = sizeof(storage.addr_storage); 638 storage.addr_len = sizeof(storage.addr_storage);
636 639
637 WSABUF read_buffer; 640 WSABUF read_buffer;
638 read_buffer.buf = buf->data(); 641 read_buffer.buf = buf->data();
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 NULL); 1019 NULL);
1017 1020
1018 return OK; 1021 return OK;
1019 } 1022 }
1020 1023
1021 void UDPSocketWin::DetachFromThread() { 1024 void UDPSocketWin::DetachFromThread() {
1022 base::NonThreadSafe::DetachFromThread(); 1025 base::NonThreadSafe::DetachFromThread();
1023 } 1026 }
1024 1027
1025 } // namespace net 1028 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_libevent.cc ('k') | net/url_request/sdch_dictionary_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698