diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-30 18:23:50 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-30 18:23:50 +0000 |
commit | 82f84b91a10f513cd59b8382a7ab00ed0f179bd5 (patch) | |
tree | 125081aff715fbe6815e8bb81889d4d49f887cf3 /net | |
parent | 88a8115978d75161674d97cde0761cbdba73daed (diff) | |
download | chromium_src-82f84b91a10f513cd59b8382a7ab00ed0f179bd5.zip chromium_src-82f84b91a10f513cd59b8382a7ab00ed0f179bd5.tar.gz chromium_src-82f84b91a10f513cd59b8382a7ab00ed0f179bd5.tar.bz2 |
Move ReadFileToString to the base namespace.
BUG=
Review URL: https://codereview.chromium.org/19579005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
24 files changed, 33 insertions, 34 deletions
diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc index 4be58b7..a091e7a 100644 --- a/net/base/file_stream_unittest.cc +++ b/net/base/file_stream_unittest.cc @@ -1017,7 +1017,7 @@ TEST_F(FileStreamTest, Truncate) { // Read in the contents and make sure we get back what we expected. std::string read_contents; - EXPECT_TRUE(file_util::ReadFileToString(temp_file_path(), &read_contents)); + EXPECT_TRUE(base::ReadFileToString(temp_file_path(), &read_contents)); EXPECT_EQ("01230123", read_contents); } diff --git a/net/base/gzip_filter_unittest.cc b/net/base/gzip_filter_unittest.cc index be98bae..2ac4a3f 100644 --- a/net/base/gzip_filter_unittest.cc +++ b/net/base/gzip_filter_unittest.cc @@ -69,7 +69,7 @@ class GZipUnitTest : public PlatformTest { file_path = file_path.AppendASCII("google.txt"); // Read data from the file into buffer. - ASSERT_TRUE(file_util::ReadFileToString(file_path, &source_buffer_)); + ASSERT_TRUE(base::ReadFileToString(file_path, &source_buffer_)); // Encode the data with deflate deflate_encode_buffer_ = new char[kDefaultBufferSize]; diff --git a/net/base/net_log_logger_unittest.cc b/net/base/net_log_logger_unittest.cc index c4ee98a..3dd6915 100644 --- a/net/base/net_log_logger_unittest.cc +++ b/net/base/net_log_logger_unittest.cc @@ -35,7 +35,7 @@ TEST_F(NetLogLoggerTest, GeneratesValidJSONForNoEvents) { } std::string input; - ASSERT_TRUE(file_util::ReadFileToString(log_path_, &input)); + ASSERT_TRUE(base::ReadFileToString(log_path_, &input)); base::JSONReader reader; scoped_ptr<base::Value> root(reader.ReadToValue(input)); @@ -67,7 +67,7 @@ TEST_F(NetLogLoggerTest, GeneratesValidJSONWithOneEvent) { } std::string input; - ASSERT_TRUE(file_util::ReadFileToString(log_path_, &input)); + ASSERT_TRUE(base::ReadFileToString(log_path_, &input)); base::JSONReader reader; scoped_ptr<base::Value> root(reader.ReadToValue(input)); @@ -102,7 +102,7 @@ TEST_F(NetLogLoggerTest, GeneratesValidJSONWithMultipleEvents) { } std::string input; - ASSERT_TRUE(file_util::ReadFileToString(log_path_, &input)); + ASSERT_TRUE(base::ReadFileToString(log_path_, &input)); base::JSONReader reader; scoped_ptr<base::Value> root(reader.ReadToValue(input)); diff --git a/net/cert/nss_cert_database_unittest.cc b/net/cert/nss_cert_database_unittest.cc index 2e712bb..4ad1192 100644 --- a/net/cert/nss_cert_database_unittest.cc +++ b/net/cert/nss_cert_database_unittest.cc @@ -68,7 +68,7 @@ class CertDatabaseNSSTest : public testing::Test { static std::string ReadTestFile(const std::string& name) { std::string result; base::FilePath cert_path = GetTestCertsDirectory().AppendASCII(name); - EXPECT_TRUE(file_util::ReadFileToString(cert_path, &result)); + EXPECT_TRUE(base::ReadFileToString(cert_path, &result)); return result; } diff --git a/net/cert/test_root_certs.cc b/net/cert/test_root_certs.cc index 3219f1d..f495890 100644 --- a/net/cert/test_root_certs.cc +++ b/net/cert/test_root_certs.cc @@ -22,7 +22,7 @@ base::LazyInstance<TestRootCerts>::Leaky CertificateList LoadCertificates(const base::FilePath& filename) { std::string raw_cert; - if (!file_util::ReadFileToString(filename, &raw_cert)) { + if (!base::ReadFileToString(filename, &raw_cert)) { LOG(ERROR) << "Can't load certificate " << filename.value(); return CertificateList(); } diff --git a/net/dns/dns_hosts.cc b/net/dns/dns_hosts.cc index 852d35c..3edea2a 100644 --- a/net/dns/dns_hosts.cc +++ b/net/dns/dns_hosts.cc @@ -158,7 +158,7 @@ bool ParseHostsFile(const base::FilePath& path, DnsHosts* dns_hosts) { return false; std::string contents; - if (!file_util::ReadFileToString(path, &contents)) + if (!base::ReadFileToString(path, &contents)) return false; ParseHosts(contents, dns_hosts); diff --git a/net/ftp/ftp_directory_listing_parser_unittest.cc b/net/ftp/ftp_directory_listing_parser_unittest.cc index 4eaf1dd..73d19bc 100644 --- a/net/ftp/ftp_directory_listing_parser_unittest.cc +++ b/net/ftp/ftp_directory_listing_parser_unittest.cc @@ -42,8 +42,8 @@ TEST_P(FtpDirectoryListingParserTest, Parse) { SCOPED_TRACE(base::StringPrintf("Test case: %s", GetParam())); std::string test_listing; - EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(GetParam()), - &test_listing)); + EXPECT_TRUE(base::ReadFileToString(test_dir.AppendASCII(GetParam()), + &test_listing)); std::vector<FtpDirectoryListingEntry> entries; EXPECT_EQ(OK, ParseFtpDirectoryListing(test_listing, @@ -51,7 +51,7 @@ TEST_P(FtpDirectoryListingParserTest, Parse) { &entries)); std::string expected_listing; - ASSERT_TRUE(file_util::ReadFileToString( + ASSERT_TRUE(base::ReadFileToString( test_dir.AppendASCII(std::string(GetParam()) + ".expected"), &expected_listing)); diff --git a/net/ocsp/nss_ocsp_unittest.cc b/net/ocsp/nss_ocsp_unittest.cc index be29d5f..0530282 100644 --- a/net/ocsp/nss_ocsp_unittest.cc +++ b/net/ocsp/nss_ocsp_unittest.cc @@ -78,7 +78,7 @@ class NssHttpTest : public ::testing::Test { virtual void SetUp() { std::string file_contents; - ASSERT_TRUE(file_util::ReadFileToString( + ASSERT_TRUE(base::ReadFileToString( GetTestCertsDirectory().AppendASCII("aia-intermediate.der"), &file_contents)); ASSERT_FALSE(file_contents.empty()); diff --git a/net/proxy/proxy_resolver_perftest.cc b/net/proxy/proxy_resolver_perftest.cc index bb94ff0..1630d9e 100644 --- a/net/proxy/proxy_resolver_perftest.cc +++ b/net/proxy/proxy_resolver_perftest.cc @@ -163,7 +163,7 @@ class PacPerfSuiteRunner { // Try to read the file from disk. std::string file_contents; - bool ok = file_util::ReadFileToString(path, &file_contents); + bool ok = base::ReadFileToString(path, &file_contents); // If we can't load the file from disk, something is misconfigured. LOG_IF(ERROR, !ok) << "Failed to read file: " << path.value(); diff --git a/net/proxy/proxy_resolver_v8_tracing_unittest.cc b/net/proxy/proxy_resolver_v8_tracing_unittest.cc index ff3ffd4a..805a8734 100644 --- a/net/proxy/proxy_resolver_v8_tracing_unittest.cc +++ b/net/proxy/proxy_resolver_v8_tracing_unittest.cc @@ -49,7 +49,7 @@ scoped_refptr<ProxyResolverScriptData> LoadScriptData(const char* filename) { // Try to read the file from disk. std::string file_contents; - bool ok = file_util::ReadFileToString(path, &file_contents); + bool ok = base::ReadFileToString(path, &file_contents); // If we can't load the file from disk, something is misconfigured. EXPECT_TRUE(ok) << "Failed to read file: " << path.value(); diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc index 67e7739..cbbedce 100644 --- a/net/proxy/proxy_resolver_v8_unittest.cc +++ b/net/proxy/proxy_resolver_v8_unittest.cc @@ -117,7 +117,7 @@ class ProxyResolverV8WithMockBindings : public ProxyResolverV8 { // Try to read the file from disk. std::string file_contents; - bool ok = file_util::ReadFileToString(path, &file_contents); + bool ok = base::ReadFileToString(path, &file_contents); // If we can't load the file from disk, something is misconfigured. if (!ok) { diff --git a/net/socket/ssl_client_socket_openssl_unittest.cc b/net/socket/ssl_client_socket_openssl_unittest.cc index 04f8999..24c0605 100644 --- a/net/socket/ssl_client_socket_openssl_unittest.cc +++ b/net/socket/ssl_client_socket_openssl_unittest.cc @@ -67,7 +67,7 @@ bool LoadPrivateKeyOpenSSL( const base::FilePath& filepath, OpenSSLClientKeyStore::ScopedEVP_PKEY* pkey) { std::string data; - if (!file_util::ReadFileToString(filepath, &data)) { + if (!base::ReadFileToString(filepath, &data)) { LOG(ERROR) << "Could not read private key file: " << filepath.value() << ": " << strerror(errno); return false; diff --git a/net/socket/ssl_server_socket_unittest.cc b/net/socket/ssl_server_socket_unittest.cc index 64c8549..e1f7f49 100644 --- a/net/socket/ssl_server_socket_unittest.cc +++ b/net/socket/ssl_server_socket_unittest.cc @@ -314,14 +314,14 @@ class SSLServerSocketTest : public PlatformTest { base::FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); std::string cert_der; - ASSERT_TRUE(file_util::ReadFileToString(cert_path, &cert_der)); + ASSERT_TRUE(base::ReadFileToString(cert_path, &cert_der)); scoped_refptr<net::X509Certificate> cert = X509Certificate::CreateFromBytes(cert_der.data(), cert_der.size()); base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); std::string key_string; - ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); + ASSERT_TRUE(base::ReadFileToString(key_path, &key_string)); std::vector<uint8> key_vector( reinterpret_cast<const uint8*>(key_string.data()), reinterpret_cast<const uint8*>(key_string.data() + diff --git a/net/socket/tcp_client_socket.cc b/net/socket/tcp_client_socket.cc index dbd2105..a91d33d 100644 --- a/net/socket/tcp_client_socket.cc +++ b/net/socket/tcp_client_socket.cc @@ -20,7 +20,7 @@ bool SystemSupportsTCPFastOpen() { static const base::FilePath::CharType kTCPFastOpenProcFilePath[] = "/proc/sys/net/ipv4/tcp_fastopen"; std::string system_enabled_tcp_fastopen; - if (!file_util::ReadFileToString( + if (!base::ReadFileToString( base::FilePath(kTCPFastOpenProcFilePath), &system_enabled_tcp_fastopen)) { return false; diff --git a/net/test/cert_test_util.cc b/net/test/cert_test_util.cc index 085a459..5ec0774 100644 --- a/net/test/cert_test_util.cc +++ b/net/test/cert_test_util.cc @@ -19,7 +19,7 @@ CertificateList CreateCertificateListFromFile( int format) { base::FilePath cert_path = certs_dir.AppendASCII(cert_file); std::string cert_data; - if (!file_util::ReadFileToString(cert_path, &cert_data)) + if (!base::ReadFileToString(cert_path, &cert_data)) return CertificateList(); return X509Certificate::CreateCertificateListFromBytes(cert_data.data(), cert_data.size(), @@ -31,7 +31,7 @@ scoped_refptr<X509Certificate> ImportCertFromFile( const std::string& cert_file) { base::FilePath cert_path = certs_dir.AppendASCII(cert_file); std::string cert_data; - if (!file_util::ReadFileToString(cert_path, &cert_data)) + if (!base::ReadFileToString(cert_path, &cert_data)) return NULL; CertificateList certs_in_file = diff --git a/net/test/embedded_test_server/embedded_test_server.cc b/net/test/embedded_test_server/embedded_test_server.cc index a54ff7e..d9196e1 100644 --- a/net/test/embedded_test_server/embedded_test_server.cc +++ b/net/test/embedded_test_server/embedded_test_server.cc @@ -59,7 +59,7 @@ scoped_ptr<HttpResponse> HandleFileRequest( base::FilePath file_path(server_root.AppendASCII(request_path)); std::string file_contents; - if (!file_util::ReadFileToString(file_path, &file_contents)) + if (!base::ReadFileToString(file_path, &file_contents)) return scoped_ptr<HttpResponse>(); base::FilePath headers_path( @@ -67,7 +67,7 @@ scoped_ptr<HttpResponse> HandleFileRequest( if (base::PathExists(headers_path)) { std::string headers_contents; - if (!file_util::ReadFileToString(headers_path, &headers_contents)) + if (!base::ReadFileToString(headers_path, &headers_contents)) return scoped_ptr<HttpResponse>(); scoped_ptr<CustomHttpResponse> http_response( diff --git a/net/test/spawned_test_server/remote_test_server.cc b/net/test/spawned_test_server/remote_test_server.cc index a3b4ef3..594c5d4 100644 --- a/net/test/spawned_test_server/remote_test_server.cc +++ b/net/test/spawned_test_server/remote_test_server.cc @@ -169,8 +169,7 @@ bool RemoteTestServer::Init(const base::FilePath& document_root) { // Parse file to extract the ports information. std::string port_info; - if (!file_util::ReadFileToString(GetTestServerPortInfoFile(), - &port_info) || + if (!base::ReadFileToString(GetTestServerPortInfoFile(), &port_info) || port_info.empty()) { return false; } diff --git a/net/tools/crl_set_dump/crl_set_dump.cc b/net/tools/crl_set_dump/crl_set_dump.cc index 19184080..6c3bb54 100644 --- a/net/tools/crl_set_dump/crl_set_dump.cc +++ b/net/tools/crl_set_dump/crl_set_dump.cc @@ -38,10 +38,10 @@ int main(int argc, char** argv) { output_filename = base::FilePath::FromUTF8Unsafe(argv[3]); std::string crl_set_bytes, delta_bytes; - if (!file_util::ReadFileToString(crl_set_filename, &crl_set_bytes)) + if (!base::ReadFileToString(crl_set_filename, &crl_set_bytes)) return 1; if (!delta_filename.empty() && - !file_util::ReadFileToString(delta_filename, &delta_bytes)) { + !base::ReadFileToString(delta_filename, &delta_bytes)) { return 1; } diff --git a/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc b/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc index bcdb7b7..f9caa79 100644 --- a/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc +++ b/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc @@ -53,7 +53,7 @@ bool ReadTestCase(const char* filename, base::FilePath filepath = base::FilePath::FromUTF8Unsafe(filename); std::string json; - if (!file_util::ReadFileToString(filepath, &json)) { + if (!base::ReadFileToString(filepath, &json)) { LOG(ERROR) << filename << ": couldn't read file."; return false; } diff --git a/net/tools/gdig/gdig.cc b/net/tools/gdig/gdig.cc index 2764ee5..54f0509 100644 --- a/net/tools/gdig/gdig.cc +++ b/net/tools/gdig/gdig.cc @@ -116,7 +116,7 @@ typedef std::vector<ReplayLogEntry> ReplayLog; // The file should be sorted by timestamp in ascending time. bool LoadReplayLog(const base::FilePath& file_path, ReplayLog* replay_log) { std::string original_replay_log_contents; - if (!file_util::ReadFileToString(file_path, &original_replay_log_contents)) { + if (!base::ReadFileToString(file_path, &original_replay_log_contents)) { fprintf(stderr, "Unable to open replay file %s\n", file_path.MaybeAsASCII().c_str()); return false; diff --git a/net/tools/quic/quic_in_memory_cache.cc b/net/tools/quic/quic_in_memory_cache.cc index b840d79..6ed7dd5 100644 --- a/net/tools/quic/quic_in_memory_cache.cc +++ b/net/tools/quic/quic_in_memory_cache.cc @@ -140,7 +140,7 @@ void QuicInMemoryCache::Initialize() { BalsaHeaders request_headers, response_headers; string file_contents; - file_util::ReadFileToString(file, &file_contents); + base::ReadFileToString(file, &file_contents); // Frame HTTP. CachingBalsaVisitor caching_visitor; diff --git a/net/tools/tld_cleanup/tld_cleanup_util.cc b/net/tools/tld_cleanup/tld_cleanup_util.cc index dfa2620..8e04b55 100644 --- a/net/tools/tld_cleanup/tld_cleanup_util.cc +++ b/net/tools/tld_cleanup/tld_cleanup_util.cc @@ -233,7 +233,7 @@ NormalizeResult NormalizeFile(const base::FilePath& in_filename, const base::FilePath& out_filename) { RuleMap rules; std::string data; - if (!file_util::ReadFileToString(in_filename, &data)) { + if (!base::ReadFileToString(in_filename, &data)) { LOG(ERROR) << "Unable to read file"; // We return success since we've already reported the error. return kSuccess; diff --git a/net/url_request/url_fetcher_impl_unittest.cc b/net/url_request/url_fetcher_impl_unittest.cc index 7cc1674..62f6272 100644 --- a/net/url_request/url_fetcher_impl_unittest.cc +++ b/net/url_request/url_fetcher_impl_unittest.cc @@ -555,7 +555,7 @@ void URLFetcherPostFileTest::CreateFetcher(const GURL& url) { void URLFetcherPostFileTest::OnURLFetchComplete(const URLFetcher* source) { std::string expected; - ASSERT_TRUE(file_util::ReadFileToString(path_, &expected)); + ASSERT_TRUE(base::ReadFileToString(path_, &expected)); ASSERT_LE(range_offset_, expected.size()); uint64 expected_size = std::min(range_length_, expected.size() - range_offset_); diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 1cb5f6f..c1178fe 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -4250,7 +4250,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect) { path = path.Append(FILE_PATH_LITERAL("with-headers.html")); std::string contents; - EXPECT_TRUE(file_util::ReadFileToString(path, &contents)); + EXPECT_TRUE(base::ReadFileToString(path, &contents)); EXPECT_EQ(contents, d.data_received()); } } @@ -4292,7 +4292,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect_GetFullRequestHeaders) { path = path.Append(FILE_PATH_LITERAL("with-headers.html")); std::string contents; - EXPECT_TRUE(file_util::ReadFileToString(path, &contents)); + EXPECT_TRUE(base::ReadFileToString(path, &contents)); EXPECT_EQ(contents, d.data_received()); } } |