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