From 826000b5280e3c8527a09965d638962fc3ed5cc3 Mon Sep 17 00:00:00 2001 From: Hidehiko Abe Date: Wed, 13 Dec 2017 18:58:58 +0900 Subject: libbrillo: Update libchrome APIS to r456626. The new libchrome has been ported from Chromium and some APIs have changed. Make necessary changes at call sites. Notable changes from libchrome: - FOR_EACH_OBSERVER macro removed (replaced by use of C++ 11 range-base for loop) - base::Values no more FundamentalValue - stl_util moved to base namespace - some scoped pointers removed in crypto/ in favor of BoringSSL UniquePtr. - path() accessor renamed to GetPath() in ScopedTempDir (and other classes) BUG: 37434548 Test: All tests in libbrillo_test pass on aosp_arm-eng build Change-Id: Iaaba63d824ecb37a5e5bc9e174b8c57e8f8c9ab2 Merged-In: I2379bb5bcea54b8343936aecd4f8a4da06f99f5a --- brillo/dbus/data_serialization.cc | 10 ++++------ brillo/dbus/data_serialization.h | 15 ++++++++------- brillo/dbus/data_serialization_unittest.cc | 13 +++++++------ brillo/dbus/dbus_method_invoker.h | 26 ++------------------------ brillo/dbus/dbus_method_invoker_unittest.cc | 13 +++++++------ brillo/file_utils_unittest.cc | 6 +++--- brillo/http/http_form_data_unittest.cc | 10 +++++----- brillo/http/http_transport_curl.cc | 11 +++++++---- brillo/http/http_transport_curl_unittest.cc | 5 +++-- brillo/key_value_store_unittest.cc | 4 ++-- brillo/location_logging.h | 2 +- brillo/message_loops/base_message_loop.cc | 3 ++- brillo/minijail/minijail.cc | 5 ++--- brillo/minijail/minijail.h | 6 ++---- brillo/osrelease_reader_unittest.cc | 12 ++++++------ brillo/process_unittest.cc | 4 ++-- brillo/streams/file_stream_unittest.cc | 20 ++++++++++---------- brillo/value_conversion.cc | 10 +++++----- 18 files changed, 78 insertions(+), 97 deletions(-) diff --git a/brillo/dbus/data_serialization.cc b/brillo/dbus/data_serialization.cc index 86d1c63..746b241 100644 --- a/brillo/dbus/data_serialization.cc +++ b/brillo/dbus/data_serialization.cc @@ -62,8 +62,8 @@ void AppendValueToWriter(dbus::MessageWriter* writer, } void AppendValueToWriter(dbus::MessageWriter* writer, - const dbus::FileDescriptor& value) { - writer->AppendFileDescriptor(value); + const base::ScopedFD& value) { + writer->AppendFileDescriptor(value.get()); } void AppendValueToWriter(dbus::MessageWriter* writer, @@ -140,12 +140,10 @@ bool PopValueFromReader(dbus::MessageReader* reader, dbus::ObjectPath* value) { } bool PopValueFromReader(dbus::MessageReader* reader, - dbus::FileDescriptor* value) { + base::ScopedFD* value) { dbus::MessageReader variant_reader(nullptr); bool ok = details::DescendIntoVariantIfPresent(&reader, &variant_reader) && reader->PopFileDescriptor(value); - if (ok) - value->CheckValidity(); return ok; } @@ -309,7 +307,7 @@ bool PopValueFromReader(dbus::MessageReader* reader, brillo::Any* value) { return false; case dbus::Message::UNIX_FD: CHECK(dbus::IsDBusTypeUnixFdSupported()) << "UNIX_FD data not supported"; - // dbus::FileDescriptor is not a copyable type. Cannot be returned via + // base::ScopedFD is not a copyable type. Cannot be returned via // brillo::Any. Fail here. LOG(ERROR) << "Cannot return FileDescriptor via Any"; return false; diff --git a/brillo/dbus/data_serialization.h b/brillo/dbus/data_serialization.h index 46da165..6919b19 100644 --- a/brillo/dbus/data_serialization.h +++ b/brillo/dbus/data_serialization.h @@ -36,7 +36,7 @@ // | (UVW...) | std::tuple // DICT | a{KV} | std::map // VARIANT | v | brillo::Any -// UNIX_FD | h | dbus::FileDescriptor +// UNIX_FD | h | base::ScopedFD // SIGNATURE | g | (unsupported) // // Additional overloads/specialization can be provided for custom types. @@ -58,6 +58,7 @@ #include #include +#include #include #include #include @@ -411,23 +412,23 @@ struct DBusType { } }; -// dbus::FileDescriptor ------------------------------------------------------- +// base::ScopedFD ------------------------------------------------------------- BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, - const dbus::FileDescriptor& value); + const base::ScopedFD& value); BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, - dbus::FileDescriptor* value); + base::ScopedFD* value); template<> -struct DBusType { +struct DBusType { inline static std::string GetSignature() { return DBUS_TYPE_UNIX_FD_AS_STRING; } inline static void Write(dbus::MessageWriter* writer, - const dbus::FileDescriptor& value) { + const base::ScopedFD& value) { AppendValueToWriter(writer, value); } inline static bool Read(dbus::MessageReader* reader, - dbus::FileDescriptor* value) { + base::ScopedFD* value) { return PopValueFromReader(reader, value); } }; diff --git a/brillo/dbus/data_serialization_unittest.cc b/brillo/dbus/data_serialization_unittest.cc index 585f20b..8771fe9 100644 --- a/brillo/dbus/data_serialization_unittest.cc +++ b/brillo/dbus/data_serialization_unittest.cc @@ -6,12 +6,13 @@ #include +#include #include #include #include "brillo/dbus/test.pb.h" -using dbus::FileDescriptor; +using base::ScopedFD; using dbus::Message; using dbus::MessageReader; using dbus::MessageWriter; @@ -33,7 +34,7 @@ TEST(DBusUtils, Supported_BasicTypes) { EXPECT_TRUE(IsTypeSupported::value); EXPECT_TRUE(IsTypeSupported::value); EXPECT_TRUE(IsTypeSupported::value); - EXPECT_TRUE(IsTypeSupported::value); + EXPECT_TRUE(IsTypeSupported::value); EXPECT_TRUE(IsTypeSupported::value); EXPECT_TRUE(IsTypeSupported::value); EXPECT_TRUE(IsTypeSupported::value); @@ -89,7 +90,7 @@ TEST(DBusUtils, Signatures_BasicTypes) { EXPECT_EQ("d", GetDBusSignature()); EXPECT_EQ("s", GetDBusSignature()); EXPECT_EQ("o", GetDBusSignature()); - EXPECT_EQ("h", GetDBusSignature()); + EXPECT_EQ("h", GetDBusSignature()); EXPECT_EQ("v", GetDBusSignature()); } @@ -105,7 +106,7 @@ TEST(DBusUtils, Signatures_Arrays) { EXPECT_EQ("ad", GetDBusSignature>()); EXPECT_EQ("as", GetDBusSignature>()); EXPECT_EQ("ao", GetDBusSignature>()); - EXPECT_EQ("ah", GetDBusSignature>()); + EXPECT_EQ("ah", GetDBusSignature>()); EXPECT_EQ("av", GetDBusSignature>()); EXPECT_EQ("a(is)", (GetDBusSignature>>())); @@ -238,7 +239,7 @@ TEST(DBusUtils, AppendAndPopFileDescriptor) { MessageWriter writer(message.get()); // Append stdout. - FileDescriptor temp(1); + ScopedFD temp(1); // Descriptor should not be valid until checked. EXPECT_FALSE(temp.is_valid()); // NB: thread IO requirements not relevant for unit tests. @@ -248,7 +249,7 @@ TEST(DBusUtils, AppendAndPopFileDescriptor) { EXPECT_EQ("h", message->GetSignature()); - FileDescriptor fd_value; + ScopedFD fd_value; MessageReader reader(message.get()); EXPECT_TRUE(reader.HasMoreData()); diff --git a/brillo/dbus/dbus_method_invoker.h b/brillo/dbus/dbus_method_invoker.h index f3d0e6b..2a8708b 100644 --- a/brillo/dbus/dbus_method_invoker.h +++ b/brillo/dbus/dbus_method_invoker.h @@ -73,7 +73,6 @@ #include #include #include -#include #include #include @@ -141,27 +140,6 @@ inline std::unique_ptr CallMethodAndBlock( args...); } -namespace internal { -// In order to support non-copyable dbus::FileDescriptor, we have this -// internal::HackMove() helper function that does really nothing for normal -// types but uses Pass() for file descriptors so we can move them out from -// the temporaries created inside DBusParamReader<...>::Invoke(). -// If only libchrome supported real rvalues so we can just do std::move() and -// be done with it. -template -inline const T& HackMove(const T& val) { - return val; -} - -// Even though |val| here is passed as const&, the actual value is created -// inside DBusParamReader<...>::Invoke() and is temporary in nature, so it is -// safe to move the file descriptor out of |val|. That's why we are doing -// const_cast here. It is a bit hacky, but there is no negative side effects. -inline dbus::FileDescriptor HackMove(const dbus::FileDescriptor& val) { - return std::move(const_cast(val)); -} -} // namespace internal - // Extracts the parameters of |ResultTypes...| types from the message reader // and puts the values in the resulting |tuple|. Returns false on error and // provides additional error details in |error| object. @@ -171,7 +149,7 @@ inline bool ExtractMessageParametersAsTuple( ErrorPtr* error, std::tuple* val_tuple) { auto callback = [val_tuple](const ResultTypes&... params) { - *val_tuple = std::forward_as_tuple(internal::HackMove(params)...); + *val_tuple = std::forward_as_tuple(params...); }; return DBusParamReader::Invoke( callback, reader, error); @@ -184,7 +162,7 @@ inline bool ExtractMessageParametersAsTuple( ErrorPtr* error, std::tuple* ref_tuple) { auto callback = [ref_tuple](const ResultTypes&... params) { - *ref_tuple = std::forward_as_tuple(internal::HackMove(params)...); + *ref_tuple = std::forward_as_tuple(params...); }; return DBusParamReader::Invoke( callback, reader, error); diff --git a/brillo/dbus/dbus_method_invoker_unittest.cc b/brillo/dbus/dbus_method_invoker_unittest.cc index f24f03e..dfd10c4 100644 --- a/brillo/dbus/dbus_method_invoker_unittest.cc +++ b/brillo/dbus/dbus_method_invoker_unittest.cc @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -90,7 +91,7 @@ class DBusMethodInvokerTest : public testing::Test { } else if (method_call->GetMember() == kTestMethod4) { method_call->SetSerial(123); MessageReader reader(method_call); - dbus::FileDescriptor fd; + base::ScopedFD fd; if (reader.PopFileDescriptor(&fd)) { auto response = Response::CreateEmpty(); MessageWriter writer(response.get()); @@ -131,13 +132,13 @@ class DBusMethodInvokerTest : public testing::Test { } // Sends a file descriptor received over D-Bus back to the caller. - dbus::FileDescriptor EchoFD(const dbus::FileDescriptor& fd_in) { + base::ScopedFD EchoFD(const base::ScopedFD& fd_in) { std::unique_ptr response = brillo::dbus_utils::CallMethodAndBlock(mock_object_proxy_.get(), kTestInterface, kTestMethod4, nullptr, fd_in); EXPECT_NE(nullptr, response.get()); - dbus::FileDescriptor fd_out; + base::ScopedFD fd_out; using brillo::dbus_utils::ExtractMethodCallResults; EXPECT_TRUE(ExtractMethodCallResults(response.get(), nullptr, &fd_out)); return fd_out; @@ -179,13 +180,13 @@ TEST_F(DBusMethodInvokerTest, TestFileDescriptors) { // Passing a file descriptor over D-Bus would effectively duplicate the fd. // So the resulting file descriptor value would be different but it still // should be valid. - dbus::FileDescriptor fd_stdin(0); + base::ScopedFD fd_stdin(0); fd_stdin.CheckValidity(); EXPECT_NE(fd_stdin.value(), EchoFD(fd_stdin).value()); - dbus::FileDescriptor fd_stdout(1); + base::ScopedFD fd_stdout(1); fd_stdout.CheckValidity(); EXPECT_NE(fd_stdout.value(), EchoFD(fd_stdout).value()); - dbus::FileDescriptor fd_stderr(2); + base::ScopedFD fd_stderr(2); fd_stderr.CheckValidity(); EXPECT_NE(fd_stderr.value(), EchoFD(fd_stderr).value()); } diff --git a/brillo/file_utils_unittest.cc b/brillo/file_utils_unittest.cc index f8898a0..e906db7 100644 --- a/brillo/file_utils_unittest.cc +++ b/brillo/file_utils_unittest.cc @@ -19,7 +19,7 @@ class FileUtilsTest : public testing::Test { public: FileUtilsTest() { CHECK(temp_dir_.CreateUniqueTempDir()); - file_path_ = temp_dir_.path().Append("test.temp"); + file_path_ = temp_dir_.GetPath().Append("test.temp"); } protected: @@ -75,7 +75,7 @@ TEST_F(FileUtilsTest, TouchFileCreateThroughUmask) { } 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(""); } @@ -94,7 +94,7 @@ TEST_F(FileUtilsTest, TouchFileReplaceDirectory) { } 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 @@ TEST(HttpFormData, FileFormField) { 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(base::WriteFile( file_name, file_content.data(), file_content.size()))); @@ -70,12 +70,12 @@ TEST(HttpFormData, MultiPartFormField) { 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( 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( base::WriteFile(filename2, file2.data(), file2.size()))); @@ -145,12 +145,12 @@ TEST(HttpFormData, FormData) { 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( 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( base::WriteFile(filename2, file2.data(), file2.size()))); diff --git a/brillo/http/http_transport_curl.cc b/brillo/http/http_transport_curl.cc index f7e3b71..109d2c1 100644 --- a/brillo/http/http_transport_curl.cc +++ b/brillo/http/http_transport_curl.cc @@ -40,7 +40,8 @@ class Transport::SocketPollData : public base::MessageLoopForIO::Watcher { : curl_interface_(curl_interface), curl_multi_handle_(curl_multi_handle), transport_(transport), - socket_fd_(socket_fd) {} + socket_fd_(socket_fd), + file_descriptor_watcher_(FROM_HERE) {} // Returns the pointer for the socket-specific file descriptor watcher. base::MessageLoopForIO::FileDescriptorWatcher* GetWatcher() { @@ -203,7 +204,8 @@ std::shared_ptr Transport::CreateConnection( void Transport::RunCallbackAsync(const tracked_objects::Location& from_here, const base::Closure& callback) { - base::MessageLoopForIO::current()->PostTask(from_here, callback); + base::MessageLoopForIO::current()->task_runner()->PostTask( + from_here, callback); } RequestID Transport::StartAsyncTransfer(http::Connection* connection, @@ -352,7 +354,8 @@ int Transport::MultiSocketCallback(CURL* easy, poll_data->GetWatcher()->StopWatchingFileDescriptor(); // This method can be called indirectly from SocketPollData::OnSocketReady, // so delay destruction of SocketPollData object till the next loop cycle. - base::MessageLoopForIO::current()->DeleteSoon(FROM_HERE, poll_data); + base::MessageLoopForIO::current()->task_runner()-> + DeleteSoon(FROM_HERE, poll_data); return 0; } @@ -395,7 +398,7 @@ int Transport::MultiTimerCallback(CURLM* /* multi */, // Cancel any previous timer callbacks. transport->weak_ptr_factory_for_timer_.InvalidateWeakPtrs(); if (timeout_ms >= 0) { - base::MessageLoopForIO::current()->PostDelayedTask( + base::MessageLoopForIO::current()->task_runner()->PostDelayedTask( FROM_HERE, base::Bind(&Transport::OnTimer, transport->weak_ptr_factory_for_timer_.GetWeakPtr()), diff --git a/brillo/http/http_transport_curl_unittest.cc b/brillo/http/http_transport_curl_unittest.cc index 702c9d9..1937e73 100644 --- a/brillo/http/http_transport_curl_unittest.cc +++ b/brillo/http/http_transport_curl_unittest.cc @@ -209,7 +209,8 @@ TEST_F(HttpCurlTransportAsyncTest, StartAsyncTransfer) { base::RunLoop* run_loop, RequestID /* request_id */, std::unique_ptr /* resp */) { - base::MessageLoop::current()->PostTask(FROM_HERE, run_loop->QuitClosure()); + base::MessageLoop::current()->task_runner()->PostTask( + FROM_HERE, run_loop->QuitClosure()); (*success_call_count)++; }; @@ -277,7 +278,7 @@ TEST_F(HttpCurlTransportAsyncTest, StartAsyncTransfer) { // Just in case something goes wrong and |success_callback| isn't called, // post a time-out quit closure to abort the message loop after 1 second. - message_loop.PostDelayedTask( + message_loop.task_runner()->PostDelayedTask( FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(1)); run_loop.Run(); EXPECT_EQ(1, success_call_count); diff --git a/brillo/key_value_store_unittest.cc b/brillo/key_value_store_unittest.cc index cd18e89..04af5fd 100644 --- a/brillo/key_value_store_unittest.cc +++ b/brillo/key_value_store_unittest.cc @@ -40,8 +40,8 @@ class KeyValueStoreTest : public ::testing::Test { 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/location_logging.h b/brillo/location_logging.h index 8e18c05..9fb3716 100644 --- a/brillo/location_logging.h +++ b/brillo/location_logging.h @@ -19,6 +19,6 @@ #define DVLOG_LOC(from_here, verbose_level) \ LAZY_STREAM(VLOG_LOC_STREAM(from_here, verbose_level), \ - ::logging::DEBUG_MODE && VLOG_IS_ON(verbose_level)) + DCHECK_IS_ON() && VLOG_IS_ON(verbose_level)) #endif // LIBBRILLO_BRILLO_LOCATION_LOGGING_H_ diff --git a/brillo/message_loops/base_message_loop.cc b/brillo/message_loops/base_message_loop.cc index ac57cb3..500c29b 100644 --- a/brillo/message_loops/base_message_loop.cc +++ b/brillo/message_loops/base_message_loop.cc @@ -315,7 +315,8 @@ BaseMessageLoop::IOTask::IOTask(const tracked_objects::Location& location, bool persistent, const Closure& task) : location_(location), loop_(loop), task_id_(task_id), - fd_(fd), base_mode_(base_mode), persistent_(persistent), closure_(task) {} + fd_(fd), base_mode_(base_mode), persistent_(persistent), closure_(task), + fd_watcher_(FROM_HERE) {} bool BaseMessageLoop::IOTask::StartWatching() { return loop_->base_loop_->WatchFileDescriptor( diff --git a/brillo/minijail/minijail.cc b/brillo/minijail/minijail.cc index 4d47c05..305f073 100644 --- a/brillo/minijail/minijail.cc +++ b/brillo/minijail/minijail.cc @@ -11,15 +11,14 @@ using std::vector; namespace brillo { -static base::LazyInstance g_minijail = LAZY_INSTANCE_INITIALIZER; - Minijail::Minijail() {} Minijail::~Minijail() {} // static Minijail* Minijail::GetInstance() { - return g_minijail.Pointer(); + static Minijail* minijail = new Minijail(); + return minijail; } struct minijail* Minijail::New() { diff --git a/brillo/minijail/minijail.h b/brillo/minijail/minijail.h index 4c1431d..15167cf 100644 --- a/brillo/minijail/minijail.h +++ b/brillo/minijail/minijail.h @@ -12,10 +12,10 @@ extern "C" { #include } -#include - #include +#include "base/macros.h" + namespace brillo { // A Minijail abstraction allowing Minijail mocking in tests. @@ -108,8 +108,6 @@ class Minijail { Minijail(); private: - friend struct base::DefaultLazyInstanceTraits; - DISALLOW_COPY_AND_ASSIGN(Minijail); }; 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 @@ class OsReleaseReaderTest : public ::testing::Test { 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 @@ class OsReleaseReaderTest : public ::testing::Test { }; 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 @@ TEST_F(OsReleaseReaderTest, CompleteTest) { 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 @@ TEST_F(OsReleaseReaderTest, NoNewLine) { 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 d2c92e6..20ccf2e 100644 --- a/brillo/process_unittest.cc +++ b/brillo/process_unittest.cc @@ -107,7 +107,7 @@ class ProcessTest : public ::testing::Test { 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(); } @@ -324,7 +324,7 @@ TEST_F(ProcessTest, ProcessExists) { } 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 4554ede..aa1ce43 100644 --- a/brillo/streams/file_stream_unittest.cc +++ b/brillo/streams/file_stream_unittest.cc @@ -715,7 +715,7 @@ TEST_F(FileStreamTest, CreateTemporary) { 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 buffer(1024 * 1024); base::RandBytes(buffer.data(), buffer.size()); int file_size = buffer.size(); // Stupid base::WriteFile taking "int" size. @@ -743,7 +743,7 @@ TEST_F(FileStreamTest, OpenRead) { 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 buffer(1024 * 1024); base::RandBytes(buffer.data(), buffer.size()); @@ -772,7 +772,7 @@ TEST_F(FileStreamTest, OpenWrite) { 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)); @@ -794,7 +794,7 @@ TEST_F(FileStreamTest, Open_OpenExisting) { 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, @@ -809,7 +809,7 @@ TEST_F(FileStreamTest, Open_OpenExisting_Fail) { 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, @@ -828,7 +828,7 @@ TEST_F(FileStreamTest, Open_CreateAlways_New) { 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)); @@ -850,7 +850,7 @@ TEST_F(FileStreamTest, Open_CreateAlways_Existing) { 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, @@ -869,7 +869,7 @@ TEST_F(FileStreamTest, Open_CreateNewOnly_New) { 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)); @@ -887,7 +887,7 @@ TEST_F(FileStreamTest, Open_CreateNewOnly_Existing) { 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( @@ -903,7 +903,7 @@ TEST_F(FileStreamTest, Open_TruncateExisting_New) { 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)); diff --git a/brillo/value_conversion.cc b/brillo/value_conversion.cc index aa5135b..8aab94c 100644 --- a/brillo/value_conversion.cc +++ b/brillo/value_conversion.cc @@ -38,23 +38,23 @@ bool FromValue(const base::Value& in_value, } std::unique_ptr ToValue(int value) { - return std::unique_ptr{new base::FundamentalValue{value}}; + return std::unique_ptr(new base::Value(value)); } std::unique_ptr ToValue(bool value) { - return std::unique_ptr{new base::FundamentalValue{value}}; + return std::unique_ptr(new base::Value(value)); } std::unique_ptr ToValue(double value) { - return std::unique_ptr{new base::FundamentalValue{value}}; + return std::unique_ptr(new base::Value(value)); } std::unique_ptr ToValue(const char* value) { - return std::unique_ptr{new base::StringValue{value}}; + return std::unique_ptr(new base::Value(value)); } std::unique_ptr ToValue(const std::string& value) { - return std::unique_ptr{new base::StringValue{value}}; + return std::unique_ptr(new base::Value(value)); } } // namespace brillo -- cgit v1.2.3