summaryrefslogtreecommitdiffstats
path: root/net/test/spawned_test_server
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-17 19:02:35 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-17 19:02:35 +0000
commit42f558fdef03f1ec2261f554151d8a4d168919e4 (patch)
treea2f2403061c945c8983524036bc73550098de6b7 /net/test/spawned_test_server
parentcb8d22b096bf5698bcf58725d6e4d7534e235a0a (diff)
downloadchromium_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 'net/test/spawned_test_server')
-rw-r--r--net/test/spawned_test_server/local_test_server.h4
-rw-r--r--net/test/spawned_test_server/local_test_server_posix.cc12
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