| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/posix/eintr_wrapper.h" | 16 #include "base/posix/eintr_wrapper.h" |
| 17 #include "base/task_scheduler/post_task.h" | 17 #include "base/task_runner_util.h" |
| 18 #include "base/threading/worker_pool.h" |
| 18 #include "base/time/default_tick_clock.h" | 19 #include "base/time/default_tick_clock.h" |
| 19 #include "net/base/address_list.h" | 20 #include "net/base/address_list.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/network_activity_monitor.h" | 24 #include "net/base/network_activity_monitor.h" |
| 24 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
| 25 #include "net/base/sockaddr_storage.h" | 26 #include "net/base/sockaddr_storage.h" |
| 26 #include "net/log/net_log.h" | 27 #include "net/log/net_log.h" |
| 27 #include "net/log/net_log_event_type.h" | 28 #include "net/log/net_log_event_type.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 125 } |
| 125 | 126 |
| 126 bool IsTCPFastOpenUserEnabled() { | 127 bool IsTCPFastOpenUserEnabled() { |
| 127 return g_tcp_fastopen_user_enabled; | 128 return g_tcp_fastopen_user_enabled; |
| 128 } | 129 } |
| 129 | 130 |
| 130 // This is asynchronous because it needs to do file IO, and it isn't allowed to | 131 // This is asynchronous because it needs to do file IO, and it isn't allowed to |
| 131 // do that on the IO thread. | 132 // do that on the IO thread. |
| 132 void CheckSupportAndMaybeEnableTCPFastOpen(bool user_enabled) { | 133 void CheckSupportAndMaybeEnableTCPFastOpen(bool user_enabled) { |
| 133 #if defined(OS_LINUX) || defined(OS_ANDROID) | 134 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 134 base::PostTaskWithTraitsAndReplyWithResult( | 135 base::PostTaskAndReplyWithResult( |
| 135 FROM_HERE, base::TaskTraits().MayBlock().WithShutdownBehavior( | 136 base::WorkerPool::GetTaskRunner(/*task_is_slow=*/false).get(), |
| 136 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | 137 FROM_HERE, |
| 137 base::Bind(SystemSupportsTCPFastOpen), | 138 base::Bind(SystemSupportsTCPFastOpen), |
| 138 base::Bind(RegisterTCPFastOpenIntentAndSupport, user_enabled)); | 139 base::Bind(RegisterTCPFastOpenIntentAndSupport, user_enabled)); |
| 139 #endif | 140 #endif |
| 140 } | 141 } |
| 141 | 142 |
| 142 TCPSocketPosix::TCPSocketPosix( | 143 TCPSocketPosix::TCPSocketPosix( |
| 143 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, | 144 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
| 144 NetLog* net_log, | 145 NetLog* net_log, |
| 145 const NetLogSource& source) | 146 const NetLogSource& source) |
| 146 : socket_performance_watcher_(std::move(socket_performance_watcher)), | 147 : socket_performance_watcher_(std::move(socket_performance_watcher)), |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 if (info.tcpi_rtt > 0) { | 810 if (info.tcpi_rtt > 0) { |
| 810 *out_rtt = base::TimeDelta::FromMicroseconds(info.tcpi_rtt); | 811 *out_rtt = base::TimeDelta::FromMicroseconds(info.tcpi_rtt); |
| 811 return true; | 812 return true; |
| 812 } | 813 } |
| 813 } | 814 } |
| 814 #endif // defined(TCP_INFO) | 815 #endif // defined(TCP_INFO) |
| 815 return false; | 816 return false; |
| 816 } | 817 } |
| 817 | 818 |
| 818 } // namespace net | 819 } // namespace net |
| OLD | NEW |