diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-17 19:02:35 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-17 19:02:35 +0000 |
commit | 42f558fdef03f1ec2261f554151d8a4d168919e4 (patch) | |
tree | a2f2403061c945c8983524036bc73550098de6b7 /base/test | |
parent | cb8d22b096bf5698bcf58725d6e4d7534e235a0a (diff) | |
download | chromium_src-42f558fdef03f1ec2261f554151d8a4d168919e4.zip chromium_src-42f558fdef03f1ec2261f554151d8a4d168919e4.tar.gz chromium_src-42f558fdef03f1ec2261f554151d8a4d168919e4.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).
Reland of https://codereview.chromium.org/191673003/
R=agl, viettrungluu
Review URL: https://codereview.chromium.org/202113004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r-- | base/test/launcher/test_launcher.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index c25b00a..889244d 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc @@ -14,6 +14,7 @@ #include "base/environment.h" #include "base/file_util.h" #include "base/files/file_path.h" +#include "base/files/scoped_file.h" #include "base/format_macros.h" #include "base/lazy_instance.h" #include "base/logging.h" @@ -244,16 +245,14 @@ void DoLaunchChildTestProcess( options.new_process_group = true; base::FileHandleMappingVector fds_mapping; - file_util::ScopedFD output_file_fd_closer; + base::ScopedFD output_file_fd; if (redirect_stdio) { - int output_file_fd = open(output_file.value().c_str(), O_RDWR); - CHECK_GE(output_file_fd, 0); + output_file_fd.reset(open(output_file.value().c_str(), O_RDWR)); + CHECK(output_file_fd.is_valid()); - output_file_fd_closer.reset(&output_file_fd); - - fds_mapping.push_back(std::make_pair(output_file_fd, STDOUT_FILENO)); - fds_mapping.push_back(std::make_pair(output_file_fd, STDERR_FILENO)); + fds_mapping.push_back(std::make_pair(output_file_fd.get(), STDOUT_FILENO)); + fds_mapping.push_back(std::make_pair(output_file_fd.get(), STDERR_FILENO)); options.fds_to_remap = &fds_mapping; } #endif @@ -264,10 +263,10 @@ void DoLaunchChildTestProcess( if (redirect_stdio) { #if defined(OS_WIN) - FlushFileBuffers(handle.Get()); - handle.Close(); + FlushFileBuffers(handle.Get()); + handle.Close(); #elif defined(OS_POSIX) - output_file_fd_closer.reset(); + output_file_fd.reset(); #endif } |