Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: net/socket/tcp_client_socket.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_server_socket_unittest.cc ('k') | net/test/cert_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_client_socket.h" 5 #include "net/socket/tcp_client_socket.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 namespace { 12 namespace {
13 13
14 #if defined(OS_LINUX) 14 #if defined(OS_LINUX)
15 15
16 // Checks to see if the system supports TCP FastOpen. Notably, it requires 16 // Checks to see if the system supports TCP FastOpen. Notably, it requires
17 // kernel support. Additionally, this checks system configuration to ensure that 17 // kernel support. Additionally, this checks system configuration to ensure that
18 // it's enabled. 18 // it's enabled.
19 bool SystemSupportsTCPFastOpen() { 19 bool SystemSupportsTCPFastOpen() {
20 static const base::FilePath::CharType kTCPFastOpenProcFilePath[] = 20 static const base::FilePath::CharType kTCPFastOpenProcFilePath[] =
21 "/proc/sys/net/ipv4/tcp_fastopen"; 21 "/proc/sys/net/ipv4/tcp_fastopen";
22 std::string system_enabled_tcp_fastopen; 22 std::string system_enabled_tcp_fastopen;
23 if (!file_util::ReadFileToString( 23 if (!base::ReadFileToString(
24 base::FilePath(kTCPFastOpenProcFilePath), 24 base::FilePath(kTCPFastOpenProcFilePath),
25 &system_enabled_tcp_fastopen)) { 25 &system_enabled_tcp_fastopen)) {
26 return false; 26 return false;
27 } 27 }
28 28
29 // As per http://lxr.linux.no/linux+v3.7.7/include/net/tcp.h#L225 29 // As per http://lxr.linux.no/linux+v3.7.7/include/net/tcp.h#L225
30 // TFO_CLIENT_ENABLE is the LSB 30 // TFO_CLIENT_ENABLE is the LSB
31 if (system_enabled_tcp_fastopen.empty() || 31 if (system_enabled_tcp_fastopen.empty() ||
32 (system_enabled_tcp_fastopen[0] & 0x1) == 0) { 32 (system_enabled_tcp_fastopen[0] & 0x1) == 0) {
33 return false; 33 return false;
(...skipping 16 matching lines...) Expand all
50 50
51 void SetTCPFastOpenEnabled(bool value) { 51 void SetTCPFastOpenEnabled(bool value) {
52 g_tcp_fastopen_enabled = value && SystemSupportsTCPFastOpen(); 52 g_tcp_fastopen_enabled = value && SystemSupportsTCPFastOpen();
53 } 53 }
54 54
55 bool IsTCPFastOpenEnabled() { 55 bool IsTCPFastOpenEnabled() {
56 return g_tcp_fastopen_enabled; 56 return g_tcp_fastopen_enabled;
57 } 57 }
58 58
59 } // namespace net 59 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_server_socket_unittest.cc ('k') | net/test/cert_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698