diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 19:36:50 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 19:36:50 +0000 |
commit | c0e895e2961bd05570b0d7660016914601bf8c7d (patch) | |
tree | 3104b59d5f4d22ad60a35a3bcefdb7caff27d3c0 /net/test | |
parent | 5fcc99e7cf20aa9d0c44e2fdaef207d9e45f907a (diff) | |
download | chromium_src-c0e895e2961bd05570b0d7660016914601bf8c7d.zip chromium_src-c0e895e2961bd05570b0d7660016914601bf8c7d.tar.gz chromium_src-c0e895e2961bd05570b0d7660016914601bf8c7d.tar.bz2 |
Implement ScopedFD in terms of ScopedGeneric.
Move to a new file base/files/scoped_file.h. I will also add ScopedFILE to here (currently in file_util.h) later.
I think there is a crash in the old code in content/browser/zygote_host/zygote_host_impl_linux.cc that this patch should fix. The old ScopedFD took the address of something in a vector that is being modified.
I removed SafeScopedFD from content/common/sandbox_linux/sandbox_linux.cc since base's ScopedFD not CHECKs on close failure (this is a more recent addition).
BUG=
R=agl@chromium.org, viettrungluu@chromium.org
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=257001
Review URL: https://codereview.chromium.org/191673003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-rw-r--r-- | net/test/spawned_test_server/local_test_server.h | 4 | ||||
-rw-r--r-- | net/test/spawned_test_server/local_test_server_posix.cc | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/net/test/spawned_test_server/local_test_server.h b/net/test/spawned_test_server/local_test_server.h index cfd2eb3..d916835 100644 --- a/net/test/spawned_test_server/local_test_server.h +++ b/net/test/spawned_test_server/local_test_server.h @@ -8,6 +8,7 @@ #include <string> #include "base/file_util.h" +#include "base/files/scoped_file.h" #include "base/process/process_handle.h" #include "net/test/spawned_test_server/base_test_server.h" @@ -105,8 +106,7 @@ class LocalTestServer : public BaseTestServer { #if defined(OS_POSIX) // The file descriptor the child writes to when it starts. - int child_fd_; - file_util::ScopedFD child_fd_closer_; + base::ScopedFD child_fd_; #endif DISALLOW_COPY_AND_ASSIGN(LocalTestServer); diff --git a/net/test/spawned_test_server/local_test_server_posix.cc b/net/test/spawned_test_server/local_test_server_posix.cc index 10c2d0f..ea9cab6 100644 --- a/net/test/spawned_test_server/local_test_server_posix.cc +++ b/net/test/spawned_test_server/local_test_server_posix.cc @@ -10,6 +10,7 @@ #include "base/command_line.h" #include "base/file_util.h" +#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/process/kill.h" #include "base/process/launch.h" @@ -120,9 +121,8 @@ bool LocalTestServer::LaunchPython(const base::FilePath& testserver_path) { } // Save the read half. The write half is sent to the child. - child_fd_ = pipefd[0]; - child_fd_closer_.reset(&child_fd_); - file_util::ScopedFD write_closer(&pipefd[1]); + child_fd_.reset(pipefd[0]); + base::ScopedFD write_closer(pipefd[1]); base::FileHandleMappingVector map_write_fd; map_write_fd.push_back(std::make_pair(pipefd[1], pipefd[1])); @@ -148,19 +148,19 @@ bool LocalTestServer::LaunchPython(const base::FilePath& testserver_path) { } bool LocalTestServer::WaitToStart() { - file_util::ScopedFD child_fd_closer(child_fd_closer_.release()); + base::ScopedFD our_fd(child_fd_.release()); base::TimeDelta remaining_time = TestTimeouts::action_timeout(); uint32 server_data_len = 0; - if (!ReadData(child_fd_, sizeof(server_data_len), + if (!ReadData(our_fd.get(), sizeof(server_data_len), reinterpret_cast<uint8*>(&server_data_len), &remaining_time)) { LOG(ERROR) << "Could not read server_data_len"; return false; } std::string server_data(server_data_len, '\0'); - if (!ReadData(child_fd_, server_data_len, + if (!ReadData(our_fd.get(), server_data_len, reinterpret_cast<uint8*>(&server_data[0]), &remaining_time)) { LOG(ERROR) << "Could not read server_data (" << server_data_len |