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}


CrOS-Libchrome-Original-Commit: 75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e
diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc
index b3e345c..bd4839a 100644
--- a/base/files/file_util_unittest.cc
+++ b/base/files/file_util_unittest.cc
@@ -1977,11 +1977,10 @@
   FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt")));
 
   std::string data("hello");
-  EXPECT_EQ(-1, AppendToFile(foobar, data.c_str(), data.length()));
+  EXPECT_FALSE(AppendToFile(foobar, data.c_str(), data.size()));
   EXPECT_EQ(static_cast<int>(data.length()),
             WriteFile(foobar, data.c_str(), data.length()));
-  EXPECT_EQ(static_cast<int>(data.length()),
-            AppendToFile(foobar, data.c_str(), data.length()));
+  EXPECT_TRUE(AppendToFile(foobar, data.c_str(), data.size()));
 
   const std::wstring read_content = ReadTextFile(foobar);
   EXPECT_EQ(L"hellohello", read_content);