| OLD | NEW |
| 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 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 tcp_fastopen_status_ == TCP_FASTOPEN_PREVIOUSLY_FAILED) { | 426 tcp_fastopen_status_ == TCP_FASTOPEN_PREVIOUSLY_FAILED) { |
| 427 UMA_HISTOGRAM_ENUMERATION("Net.TcpFastOpenSocketConnection", | 427 UMA_HISTOGRAM_ENUMERATION("Net.TcpFastOpenSocketConnection", |
| 428 tcp_fastopen_status_, TCP_FASTOPEN_MAX_VALUE); | 428 tcp_fastopen_status_, TCP_FASTOPEN_MAX_VALUE); |
| 429 } | 429 } |
| 430 use_tcp_fastopen_ = false; | 430 use_tcp_fastopen_ = false; |
| 431 tcp_fastopen_connected_ = false; | 431 tcp_fastopen_connected_ = false; |
| 432 tcp_fastopen_write_attempted_ = false; | 432 tcp_fastopen_write_attempted_ = false; |
| 433 tcp_fastopen_status_ = TCP_FASTOPEN_STATUS_UNKNOWN; | 433 tcp_fastopen_status_ = TCP_FASTOPEN_STATUS_UNKNOWN; |
| 434 } | 434 } |
| 435 | 435 |
| 436 bool TCPSocketPosix::UsingTCPFastOpen() const { | |
| 437 return use_tcp_fastopen_; | |
| 438 } | |
| 439 | |
| 440 void TCPSocketPosix::EnableTCPFastOpenIfSupported() { | 436 void TCPSocketPosix::EnableTCPFastOpenIfSupported() { |
| 441 if (!IsTCPFastOpenSupported()) | 437 if (!IsTCPFastOpenSupported()) |
| 442 return; | 438 return; |
| 443 | 439 |
| 444 // Do not enable TCP FastOpen if it had previously failed. | 440 // Do not enable TCP FastOpen if it had previously failed. |
| 445 // This check conservatively avoids middleboxes that may blackhole | 441 // This check conservatively avoids middleboxes that may blackhole |
| 446 // TCP FastOpen SYN+Data packets; on such a failure, subsequent sockets | 442 // TCP FastOpen SYN+Data packets; on such a failure, subsequent sockets |
| 447 // should not use TCP FastOpen. | 443 // should not use TCP FastOpen. |
| 448 if(!g_tcp_fastopen_has_failed) | 444 if (!g_tcp_fastopen_has_failed) |
| 449 use_tcp_fastopen_ = true; | 445 use_tcp_fastopen_ = true; |
| 450 else | 446 else |
| 451 tcp_fastopen_status_ = TCP_FASTOPEN_PREVIOUSLY_FAILED; | 447 tcp_fastopen_status_ = TCP_FASTOPEN_PREVIOUSLY_FAILED; |
| 452 } | 448 } |
| 453 | 449 |
| 454 bool TCPSocketPosix::IsValid() const { | 450 bool TCPSocketPosix::IsValid() const { |
| 455 return socket_ != NULL && socket_->socket_fd() != kInvalidSocket; | 451 return socket_ != NULL && socket_->socket_fd() != kInvalidSocket; |
| 456 } | 452 } |
| 457 | 453 |
| 458 void TCPSocketPosix::DetachFromThread() { | 454 void TCPSocketPosix::DetachFromThread() { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 if (info.tcpi_rtt > 0) { | 749 if (info.tcpi_rtt > 0) { |
| 754 *out_rtt = base::TimeDelta::FromMicroseconds(info.tcpi_rtt); | 750 *out_rtt = base::TimeDelta::FromMicroseconds(info.tcpi_rtt); |
| 755 return true; | 751 return true; |
| 756 } | 752 } |
| 757 } | 753 } |
| 758 #endif // defined(TCP_INFO) | 754 #endif // defined(TCP_INFO) |
| 759 return false; | 755 return false; |
| 760 } | 756 } |
| 761 | 757 |
| 762 } // namespace net | 758 } // namespace net |
| OLD | NEW |