libbrillo: use ScopedTempDir::GetPath

Upstream versions of libchrome have gotten rid of ScopedTempDir's
inline path method because they wanted to introduce a DCHECK that
helps make sure people create the temp directory before using it.
To avoid introducing a header dependency on the logging header
they took this method out of the header so it wouldn't be inlined.

BUG=b:37434548
TEST=unit tests

Change-Id: Ic83227a7ddbbad32a1df1f9554d29470c1a2dd42
Reviewed-on: https://chromium-review.googlesource.com/905784
Commit-Ready: Eric Caruso <ejcaruso@chromium.org>
Tested-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>
diff --git a/brillo/file_utils_unittest.cc b/brillo/file_utils_unittest.cc
index 96c1fd7..7a730f0 100644
--- a/brillo/file_utils_unittest.cc
+++ b/brillo/file_utils_unittest.cc
@@ -37,7 +37,7 @@
  public:
   FileUtilsTest() {
     CHECK(temp_dir_.CreateUniqueTempDir());
-    file_path_ = temp_dir_.path().Append("test.temp");
+    file_path_ = temp_dir_.GetPath().Append("test.temp");
   }
 
  protected:
@@ -68,7 +68,7 @@
 
   // Creates a file with a random name in the temporary directory.
   base::FilePath GetTempName() {
-    return temp_dir_.path().Append(GetRandomSuffix());
+    return temp_dir_.GetPath().Append(GetRandomSuffix());
   }
 };
 
@@ -87,7 +87,7 @@
 }
 
 TEST_F(FileUtilsTest, TouchFileCreateDirectoryStructure) {
-  file_path_ = temp_dir_.path().Append("foo/bar/baz/test.temp");
+  file_path_ = temp_dir_.GetPath().Append("foo/bar/baz/test.temp");
   EXPECT_TRUE(TouchFile(file_path_));
   ExpectFileContains("");
 }
@@ -106,7 +106,7 @@
 }
 
 TEST_F(FileUtilsTest, TouchFileReplaceSymlink) {
-  base::FilePath symlink_target = temp_dir_.path().Append("target.temp");
+  base::FilePath symlink_target = temp_dir_.GetPath().Append("target.temp");
   EXPECT_TRUE(base::CreateSymbolicLink(symlink_target, file_path_));
   EXPECT_TRUE(TouchFile(file_path_));
   EXPECT_FALSE(base::IsLink(file_path_));
diff --git a/brillo/http/http_form_data_unittest.cc b/brillo/http/http_form_data_unittest.cc
index 842225d..34288d0 100644
--- a/brillo/http/http_form_data_unittest.cc
+++ b/brillo/http/http_form_data_unittest.cc
@@ -42,7 +42,7 @@
   base::ScopedTempDir dir;
   ASSERT_TRUE(dir.CreateUniqueTempDir());
   std::string file_content{"text line1\ntext line2\n"};
-  base::FilePath file_name = dir.path().Append("sample.txt");
+  base::FilePath file_name = dir.GetPath().Append("sample.txt");
   ASSERT_EQ(file_content.size(),
             static_cast<size_t>(base::WriteFile(
                 file_name, file_content.data(), file_content.size())));
@@ -70,12 +70,12 @@
   base::ScopedTempDir dir;
   ASSERT_TRUE(dir.CreateUniqueTempDir());
   std::string file1{"text line1\ntext line2\n"};
-  base::FilePath filename1 = dir.path().Append("sample.txt");
+  base::FilePath filename1 = dir.GetPath().Append("sample.txt");
   ASSERT_EQ(file1.size(),
             static_cast<size_t>(
                 base::WriteFile(filename1, file1.data(), file1.size())));
   std::string file2{"\x01\x02\x03\x04\x05"};
-  base::FilePath filename2 = dir.path().Append("test.bin");
+  base::FilePath filename2 = dir.GetPath().Append("test.bin");
   ASSERT_EQ(file2.size(),
             static_cast<size_t>(
                 base::WriteFile(filename2, file2.data(), file2.size())));
@@ -145,12 +145,12 @@
   base::ScopedTempDir dir;
   ASSERT_TRUE(dir.CreateUniqueTempDir());
   std::string file1{"text line1\ntext line2\n"};
-  base::FilePath filename1 = dir.path().Append("sample.txt");
+  base::FilePath filename1 = dir.GetPath().Append("sample.txt");
   ASSERT_EQ(file1.size(),
             static_cast<size_t>(
                 base::WriteFile(filename1, file1.data(), file1.size())));
   std::string file2{"\x01\x02\x03\x04\x05"};
-  base::FilePath filename2 = dir.path().Append("test.bin");
+  base::FilePath filename2 = dir.GetPath().Append("test.bin");
   ASSERT_EQ(file2.size(),
             static_cast<size_t>(
                 base::WriteFile(filename2, file2.data(), file2.size())));
diff --git a/brillo/key_value_store_unittest.cc b/brillo/key_value_store_unittest.cc
index cd18e89..68875ef 100644
--- a/brillo/key_value_store_unittest.cc
+++ b/brillo/key_value_store_unittest.cc
@@ -40,8 +40,9 @@
 TEST_F(KeyValueStoreTest, LoadAndSaveFromFile) {
   base::ScopedTempDir temp_dir_;
   CHECK(temp_dir_.CreateUniqueTempDir());
-  base::FilePath temp_file_ = temp_dir_.path().Append("temp.conf");
-  base::FilePath saved_temp_file_ = temp_dir_.path().Append("saved_temp.conf");
+  base::FilePath temp_file_ = temp_dir_.GetPath().Append("temp.conf");
+  base::FilePath saved_temp_file_ =
+      temp_dir_.GetPath().Append("saved_temp.conf");
 
   string blob = "A=B\n# Comment\n";
   ASSERT_EQ(blob.size(), base::WriteFile(temp_file_, blob.data(), blob.size()));
diff --git a/brillo/osrelease_reader_unittest.cc b/brillo/osrelease_reader_unittest.cc
index 88185a0..9381367 100644
--- a/brillo/osrelease_reader_unittest.cc
+++ b/brillo/osrelease_reader_unittest.cc
@@ -16,8 +16,8 @@
  public:
   void SetUp() override {
     CHECK(temp_dir_.CreateUniqueTempDir());
-    osreleased_ = temp_dir_.path().Append("etc").Append("os-release.d");
-    osrelease_ = temp_dir_.path().Append("etc").Append("os-release");
+    osreleased_ = temp_dir_.GetPath().Append("etc").Append("os-release.d");
+    osrelease_ = temp_dir_.GetPath().Append("etc").Append("os-release");
     base::CreateDirectory(osreleased_);
   }
 
@@ -28,12 +28,12 @@
 };
 
 TEST_F(OsReleaseReaderTest, MissingOsReleaseTest) {
-  store_.LoadTestingOnly(temp_dir_.path());
+  store_.LoadTestingOnly(temp_dir_.GetPath());
 }
 
 TEST_F(OsReleaseReaderTest, MissingOsReleaseDTest) {
   base::DeleteFile(osreleased_, true);
-  store_.LoadTestingOnly(temp_dir_.path());
+  store_.LoadTestingOnly(temp_dir_.GetPath());
 }
 
 TEST_F(OsReleaseReaderTest, CompleteTest) {
@@ -46,7 +46,7 @@
   base::WriteFile(osreleased_.Append("GREETINGS"), ola.data(), ola.size());
   base::WriteFile(osrelease_, osreleasecontent.data(), osreleasecontent.size());
 
-  store_.LoadTestingOnly(temp_dir_.path());
+  store_.LoadTestingOnly(temp_dir_.GetPath());
 
   string test_key_value;
   ASSERT_TRUE(store_.GetString("TEST_KEY", &test_key_value));
@@ -80,7 +80,7 @@
   base::WriteFile(
       osreleased_.Append("BONJOUR"), bonjour.data(), bonjour.size());
 
-  store_.LoadTestingOnly(temp_dir_.path());
+  store_.LoadTestingOnly(temp_dir_.GetPath());
 
   string hello_value;
   string bonjour_value;
diff --git a/brillo/process_unittest.cc b/brillo/process_unittest.cc
index 2416e76..d980e2b 100644
--- a/brillo/process_unittest.cc
+++ b/brillo/process_unittest.cc
@@ -107,7 +107,7 @@
  public:
   void SetUp() {
     CHECK(temp_dir_.CreateUniqueTempDir());
-    output_file_ = temp_dir_.path().Append("fork_out").value();
+    output_file_ = temp_dir_.GetPath().Append("fork_out").value();
     process_.RedirectOutput(output_file_);
     ClearLog();
   }
@@ -336,7 +336,7 @@
 }
 
 TEST_F(ProcessTest, ResetPidByFile) {
-  FilePath pid_path = temp_dir_.path().Append("pid");
+  FilePath pid_path = temp_dir_.GetPath().Append("pid");
   EXPECT_FALSE(process_.ResetPidByFile(pid_path.value()));
   EXPECT_TRUE(base::WriteFile(pid_path, "456\n", 4));
   EXPECT_TRUE(process_.ResetPidByFile(pid_path.value()));
diff --git a/brillo/streams/file_stream_unittest.cc b/brillo/streams/file_stream_unittest.cc
index 830d31c..ebbe551 100644
--- a/brillo/streams/file_stream_unittest.cc
+++ b/brillo/streams/file_stream_unittest.cc
@@ -703,7 +703,7 @@
 TEST_F(FileStreamTest, OpenRead) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
   std::vector<char> buffer(1024 * 1024);
   base::RandBytes(buffer.data(), buffer.size());
   int file_size = buffer.size();  // Stupid base::WriteFile taking "int" size.
@@ -731,7 +731,7 @@
 TEST_F(FileStreamTest, OpenWrite) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
   std::vector<char> buffer(1024 * 1024);
   base::RandBytes(buffer.data(), buffer.size());
 
@@ -760,7 +760,7 @@
 TEST_F(FileStreamTest, Open_OpenExisting) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
   std::string data{"Lorem ipsum dolor sit amet ..."};
   int data_size = data.size();  // I hate ints for data size...
   ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));
@@ -782,7 +782,7 @@
 TEST_F(FileStreamTest, Open_OpenExisting_Fail) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
 
   ErrorPtr error;
   StreamPtr stream = FileStream::Open(path,
@@ -797,7 +797,7 @@
 TEST_F(FileStreamTest, Open_CreateAlways_New) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
 
   StreamPtr stream = FileStream::Open(path,
                                       Stream::AccessMode::READ_WRITE,
@@ -816,7 +816,7 @@
 TEST_F(FileStreamTest, Open_CreateAlways_Existing) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
   std::string data{"Lorem ipsum dolor sit amet ..."};
   int data_size = data.size();  // I hate ints for data size...
   ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));
@@ -838,7 +838,7 @@
 TEST_F(FileStreamTest, Open_CreateNewOnly_New) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
 
   StreamPtr stream = FileStream::Open(path,
                                       Stream::AccessMode::READ_WRITE,
@@ -857,7 +857,7 @@
 TEST_F(FileStreamTest, Open_CreateNewOnly_Existing) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
   std::string data{"Lorem ipsum dolor sit amet ..."};
   int data_size = data.size();  // I hate ints for data size...
   ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));
@@ -875,7 +875,7 @@
 TEST_F(FileStreamTest, Open_TruncateExisting_New) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
 
   ErrorPtr error;
   StreamPtr stream = FileStream::Open(
@@ -891,7 +891,7 @@
 TEST_F(FileStreamTest, Open_TruncateExisting_Existing) {
   base::ScopedTempDir temp_dir;
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-  base::FilePath path = temp_dir.path().Append(base::FilePath{"test.dat"});
+  base::FilePath path = temp_dir.GetPath().Append(base::FilePath{"test.dat"});
   std::string data{"Lorem ipsum dolor sit amet ..."};
   int data_size = data.size();  // I hate ints for data size...
   ASSERT_EQ(data_size, base::WriteFile(path, data.data(), data_size));