This source file includes following definitions.
- SystemSupportsTCPFastOpen
- SystemSupportsTCPFastOpen
- SetTCPFastOpenEnabled
- IsTCPFastOpenEnabled
#include "net/socket/tcp_socket.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
namespace net {
namespace {
#if defined(OS_LINUX)
bool SystemSupportsTCPFastOpen() {
static const base::FilePath::CharType kTCPFastOpenProcFilePath[] =
"/proc/sys/net/ipv4/tcp_fastopen";
std::string system_enabled_tcp_fastopen;
if (!base::ReadFileToString(
base::FilePath(kTCPFastOpenProcFilePath),
&system_enabled_tcp_fastopen)) {
return false;
}
if (system_enabled_tcp_fastopen.empty() ||
(system_enabled_tcp_fastopen[0] & 0x1) == 0) {
return false;
}
return true;
}
#else
bool SystemSupportsTCPFastOpen() {
return false;
}
#endif
bool g_tcp_fastopen_enabled = false;
}
void SetTCPFastOpenEnabled(bool value) {
g_tcp_fastopen_enabled = value && SystemSupportsTCPFastOpen();
}
bool IsTCPFastOpenEnabled() {
return g_tcp_fastopen_enabled;
}
}