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

Side by Side Diff: net/socket/tcp_socket_libevent.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/socket/ssl_client_socket_pool.cc ('k') | net/socket/tcp_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/socket/tcp_socket.h" 5 #include "net/socket/tcp_socket.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <netinet/tcp.h> 8 #include <netinet/tcp.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
14 #include "base/metrics/stats_counters.h"
15 #include "base/posix/eintr_wrapper.h" 16 #include "base/posix/eintr_wrapper.h"
16 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
17 #include "base/threading/worker_pool.h" 18 #include "base/threading/worker_pool.h"
18 #include "net/base/address_list.h" 19 #include "net/base/address_list.h"
19 #include "net/base/connection_type_histograms.h" 20 #include "net/base/connection_type_histograms.h"
20 #include "net/base/io_buffer.h" 21 #include "net/base/io_buffer.h"
21 #include "net/base/ip_endpoint.h" 22 #include "net/base/ip_endpoint.h"
22 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
23 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
24 #include "net/base/network_activity_monitor.h" 25 #include "net/base/network_activity_monitor.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 if (rv == ERR_ADDRESS_UNREACHABLE && NetworkChangeNotifier::IsOffline()) 532 if (rv == ERR_ADDRESS_UNREACHABLE && NetworkChangeNotifier::IsOffline())
532 rv = ERR_INTERNET_DISCONNECTED; 533 rv = ERR_INTERNET_DISCONNECTED;
533 534
534 if (!logging_multiple_connect_attempts_) 535 if (!logging_multiple_connect_attempts_)
535 LogConnectEnd(rv); 536 LogConnectEnd(rv);
536 537
537 return rv; 538 return rv;
538 } 539 }
539 540
540 void TCPSocketLibevent::LogConnectBegin(const AddressList& addresses) const { 541 void TCPSocketLibevent::LogConnectBegin(const AddressList& addresses) const {
541 base::StatsCounter connects("tcp.connect");
542 connects.Increment();
543
544 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT, 542 net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT,
545 addresses.CreateNetLogCallback()); 543 addresses.CreateNetLogCallback());
546 } 544 }
547 545
548 void TCPSocketLibevent::LogConnectEnd(int net_error) const { 546 void TCPSocketLibevent::LogConnectEnd(int net_error) const {
549 if (net_error != OK) { 547 if (net_error != OK) {
550 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_CONNECT, net_error); 548 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_CONNECT, net_error);
551 return; 549 return;
552 } 550 }
553 551
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 else 588 else
591 g_tcp_fastopen_has_failed = true; 589 g_tcp_fastopen_has_failed = true;
592 UpdateTCPFastOpenStatusAfterRead(); 590 UpdateTCPFastOpenStatusAfterRead();
593 } 591 }
594 592
595 if (rv < 0) { 593 if (rv < 0) {
596 net_log_.AddEvent(NetLog::TYPE_SOCKET_READ_ERROR, 594 net_log_.AddEvent(NetLog::TYPE_SOCKET_READ_ERROR,
597 CreateNetLogSocketErrorCallback(rv, errno)); 595 CreateNetLogSocketErrorCallback(rv, errno));
598 return rv; 596 return rv;
599 } 597 }
600
601 base::StatsCounter read_bytes("tcp.read_bytes");
602 read_bytes.Add(rv);
603 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, rv, 598 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, rv,
604 buf->data()); 599 buf->data());
605 NetworkActivityMonitor::GetInstance()->IncrementBytesReceived(rv); 600 NetworkActivityMonitor::GetInstance()->IncrementBytesReceived(rv);
606 601
607 return rv; 602 return rv;
608 } 603 }
609 604
610 void TCPSocketLibevent::WriteCompleted(const scoped_refptr<IOBuffer>& buf, 605 void TCPSocketLibevent::WriteCompleted(const scoped_refptr<IOBuffer>& buf,
611 const CompletionCallback& callback, 606 const CompletionCallback& callback,
612 int rv) { 607 int rv) {
(...skipping 11 matching lines...) Expand all
624 // FastOpen is turned off on _any_ error. Implement optimizations, 619 // FastOpen is turned off on _any_ error. Implement optimizations,
625 // such as turning off TCP FastOpen on more specific errors, and 620 // such as turning off TCP FastOpen on more specific errors, and
626 // re-attempting TCP FastOpen after a certain amount of time has passed. 621 // re-attempting TCP FastOpen after a certain amount of time has passed.
627 tcp_fastopen_status_ = TCP_FASTOPEN_ERROR; 622 tcp_fastopen_status_ = TCP_FASTOPEN_ERROR;
628 g_tcp_fastopen_has_failed = true; 623 g_tcp_fastopen_has_failed = true;
629 } 624 }
630 net_log_.AddEvent(NetLog::TYPE_SOCKET_WRITE_ERROR, 625 net_log_.AddEvent(NetLog::TYPE_SOCKET_WRITE_ERROR,
631 CreateNetLogSocketErrorCallback(rv, errno)); 626 CreateNetLogSocketErrorCallback(rv, errno));
632 return rv; 627 return rv;
633 } 628 }
634
635 base::StatsCounter write_bytes("tcp.write_bytes");
636 write_bytes.Add(rv);
637 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, rv, 629 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, rv,
638 buf->data()); 630 buf->data());
639 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(rv); 631 NetworkActivityMonitor::GetInstance()->IncrementBytesSent(rv);
640 return rv; 632 return rv;
641 } 633 }
642 634
643 int TCPSocketLibevent::TcpFastOpenWrite( 635 int TCPSocketLibevent::TcpFastOpenWrite(
644 IOBuffer* buf, 636 IOBuffer* buf,
645 int buf_len, 637 int buf_len,
646 const CompletionCallback& callback) { 638 const CompletionCallback& callback) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } 732 }
741 } else { 733 } else {
742 tcp_fastopen_status_ = 734 tcp_fastopen_status_ =
743 (tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN ? 735 (tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN ?
744 TCP_FASTOPEN_SYN_DATA_GETSOCKOPT_FAILED : 736 TCP_FASTOPEN_SYN_DATA_GETSOCKOPT_FAILED :
745 TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED); 737 TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED);
746 } 738 }
747 } 739 }
748 740
749 } // namespace net 741 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_pool.cc ('k') | net/socket/tcp_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698