Ignore non-active fullscreen windows for shelf state.
[chromium-blink-merge.git] / net / socket / tcp_socket.cc
blobfd72f6b4640e1bd97e8b06cfaa777a31bc1a946d
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
3 // found in the LICENSE file.
5 #include "net/socket/tcp_socket.h"
7 #include "base/file_util.h"
8 #include "base/files/file_path.h"
10 namespace net {
12 namespace {
14 #if defined(OS_LINUX)
16 // Checks to see if the system supports TCP FastOpen. Notably, it requires
17 // kernel support. Additionally, this checks system configuration to ensure that
18 // it's enabled.
19 bool SystemSupportsTCPFastOpen() {
20 static const base::FilePath::CharType kTCPFastOpenProcFilePath[] =
21 "/proc/sys/net/ipv4/tcp_fastopen";
22 std::string system_enabled_tcp_fastopen;
23 if (!base::ReadFileToString(
24 base::FilePath(kTCPFastOpenProcFilePath),
25 &system_enabled_tcp_fastopen)) {
26 return false;
29 // As per http://lxr.linux.no/linux+v3.7.7/include/net/tcp.h#L225
30 // TFO_CLIENT_ENABLE is the LSB
31 if (system_enabled_tcp_fastopen.empty() ||
32 (system_enabled_tcp_fastopen[0] & 0x1) == 0) {
33 return false;
36 return true;
39 #else
41 bool SystemSupportsTCPFastOpen() {
42 return false;
45 #endif
47 bool g_tcp_fastopen_enabled = false;
49 } // namespace
51 void SetTCPFastOpenEnabled(bool value) {
52 g_tcp_fastopen_enabled = value && SystemSupportsTCPFastOpen();
55 bool IsTCPFastOpenEnabled() {
56 return g_tcp_fastopen_enabled;
59 } // namespace net