diff options
author | chirantan <chirantan@chromium.org> | 2014-10-07 16:15:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-07 23:15:48 +0000 |
commit | 75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e (patch) | |
tree | 45416a4fcb4d264015b23e835e39ee1dab82c722 /chromeos/process_proxy | |
parent | b247579e8a2339c59884aa4b5ef3dcb00d9aa9f8 (diff) | |
download | chromium_src-75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e.zip chromium_src-75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e.tar.gz chromium_src-75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e.tar.bz2 |
Refactor AppendToFile and WriteFileDescriptor
- Unify the behavior of the windows and posix implementations of these
functions.
- Simplify the interface by having them just indicate success or failure
instead of making callers deal with partial writes.
BUG=418837
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Review URL: https://codereview.chromium.org/614893004
Cr-Commit-Position: refs/heads/master@{#298604}
Diffstat (limited to 'chromeos/process_proxy')
-rw-r--r-- | chromeos/process_proxy/process_output_watcher_unittest.cc | 7 | ||||
-rw-r--r-- | chromeos/process_proxy/process_proxy.cc | 6 |
2 files changed, 5 insertions, 8 deletions
diff --git a/chromeos/process_proxy/process_output_watcher_unittest.cc b/chromeos/process_proxy/process_output_watcher_unittest.cc index 0984ee2..f08a852 100644 --- a/chromeos/process_proxy/process_output_watcher_unittest.cc +++ b/chromeos/process_proxy/process_output_watcher_unittest.cc @@ -150,9 +150,8 @@ class ProcessOutputWatcherTest : public testing::Test { ssize_t test_size = test_str.length() * sizeof(*test_str.c_str()); if (test_cases[i].should_send_terminating_null) test_size += sizeof(*test_str.c_str()); - EXPECT_EQ(test_size, - base::WriteFileDescriptor(pt_pipe[1], test_str.c_str(), - test_size)); + EXPECT_TRUE(base::WriteFileDescriptor(pt_pipe[1], test_str.c_str(), + test_size)); run_loop.Run(); EXPECT_TRUE(expectations_.IsDone()); @@ -161,7 +160,7 @@ class ProcessOutputWatcherTest : public testing::Test { } // Send stop signal. It is not important which string we send. - EXPECT_EQ(1, base::WriteFileDescriptor(stop_pipe[1], "q", 1)); + EXPECT_TRUE(base::WriteFileDescriptor(stop_pipe[1], "q", 1)); EXPECT_NE(-1, IGNORE_EINTR(close(stop_pipe[1]))); EXPECT_NE(-1, IGNORE_EINTR(close(pt_pipe[1]))); diff --git a/chromeos/process_proxy/process_proxy.cc b/chromeos/process_proxy/process_proxy.cc index 881ea5a..b1021f4 100644 --- a/chromeos/process_proxy/process_proxy.cc +++ b/chromeos/process_proxy/process_proxy.cc @@ -160,10 +160,8 @@ bool ProcessProxy::Write(const std::string& text) { // We don't want to write '\0' to the pipe. size_t data_size = text.length() * sizeof(*text.c_str()); - int bytes_written = - base::WriteFileDescriptor(pt_pair_[PT_MASTER_FD], - text.c_str(), data_size); - return (bytes_written == static_cast<int>(data_size)); + return base::WriteFileDescriptor( + pt_pair_[PT_MASTER_FD], text.c_str(), data_size); } bool ProcessProxy::OnTerminalResize(int width, int height) { |