From cfd1fbb90d869daf1bf222db1936b35940cba5e9 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Thu, 19 Jul 2018 13:46:06 -0700 Subject: Uprev libchrome to r576279 (1/many) Test: compilation Change-Id: If75092008dcca5dfbb1683072f03cb1e5fa2e62f Merged-In: If75092008dcca5dfbb1683072f03cb1e5fa2e62f --- brillo/dbus/dbus_method_response.cc | 2 +- brillo/dbus/dbus_method_response.h | 2 +- brillo/errors/error.cc | 31 +++++++++------------- brillo/errors/error.h | 22 ++++++--------- brillo/errors/error_codes.cc | 2 +- brillo/errors/error_codes.h | 2 +- brillo/errors/error_unittest.cc | 20 +++++++------- brillo/http/http_transport.h | 2 +- brillo/http/http_transport_curl.cc | 22 +++++++-------- brillo/http/http_transport_curl.h | 6 ++--- brillo/http/http_transport_fake.cc | 2 +- brillo/http/http_transport_fake.h | 4 +-- brillo/http/mock_transport.h | 2 +- brillo/message_loops/base_message_loop.cc | 31 +++++++++++++--------- brillo/message_loops/base_message_loop.h | 21 ++++++++------- brillo/message_loops/fake_message_loop.cc | 4 +-- brillo/message_loops/fake_message_loop.h | 6 ++--- brillo/message_loops/fake_message_loop_unittest.cc | 7 ++--- brillo/message_loops/message_loop.h | 10 +++---- brillo/message_loops/message_loop_unittest.cc | 3 ++- brillo/message_loops/mock_message_loop.h | 8 +++--- brillo/process_reaper.cc | 2 +- brillo/process_reaper.h | 4 +-- brillo/streams/fake_stream.cc | 1 - brillo/streams/memory_containers.cc | 2 +- brillo/streams/stream_utils.cc | 12 ++++----- brillo/streams/stream_utils.h | 12 ++++----- brillo/streams/tls_stream.cc | 6 ++--- brillo/value_conversion.h | 2 +- 29 files changed, 124 insertions(+), 126 deletions(-) diff --git a/brillo/dbus/dbus_method_response.cc b/brillo/dbus/dbus_method_response.cc index 265f9f3..871c0ed 100644 --- a/brillo/dbus/dbus_method_response.cc +++ b/brillo/dbus/dbus_method_response.cc @@ -28,7 +28,7 @@ void DBusMethodResponseBase::ReplyWithError(const brillo::Error* error) { } void DBusMethodResponseBase::ReplyWithError( - const tracked_objects::Location& location, + const base::Location& location, const std::string& error_domain, const std::string& error_code, const std::string& error_message) { diff --git a/brillo/dbus/dbus_method_response.h b/brillo/dbus/dbus_method_response.h index 0a9ef08..289f11e 100644 --- a/brillo/dbus/dbus_method_response.h +++ b/brillo/dbus/dbus_method_response.h @@ -40,7 +40,7 @@ class BRILLO_EXPORT DBusMethodResponseBase { // Constructs brillo::Error object from the parameters specified and send // the error information over D-Bus using the method above. - void ReplyWithError(const tracked_objects::Location& location, + void ReplyWithError(const base::Location& location, const std::string& error_domain, const std::string& error_code, const std::string& error_message); diff --git a/brillo/errors/error.cc b/brillo/errors/error.cc index 1236220..f229bd7 100644 --- a/brillo/errors/error.cc +++ b/brillo/errors/error.cc @@ -11,7 +11,7 @@ using brillo::Error; using brillo::ErrorPtr; namespace { -inline void LogError(const tracked_objects::Location& location, +inline void LogError(const base::Location& location, const std::string& domain, const std::string& code, const std::string& message) { @@ -19,6 +19,13 @@ inline void LogError(const tracked_objects::Location& location, // the current error location with the location passed in to the Error object. // This way the log will contain the actual location of the error, and not // as if it always comes from brillo/errors/error.cc(22). + if (location.function_name() == nullptr) { + logging::LogMessage(location.file_name(), location.line_number(), + logging::LOG_ERROR) + .stream() + << "Domain=" << domain << ", Code=" << code << ", Message=" << message; + return; + } logging::LogMessage( location.file_name(), location.line_number(), logging::LOG_ERROR).stream() << location.function_name() << "(...): " @@ -26,14 +33,14 @@ inline void LogError(const tracked_objects::Location& location, } } // anonymous namespace -ErrorPtr Error::Create(const tracked_objects::Location& location, +ErrorPtr Error::Create(const base::Location& location, const std::string& domain, const std::string& code, const std::string& message) { return Create(location, domain, code, message, ErrorPtr()); } -ErrorPtr Error::Create(const tracked_objects::Location& location, +ErrorPtr Error::Create(const base::Location& location, const std::string& domain, const std::string& code, const std::string& message, @@ -44,7 +51,7 @@ ErrorPtr Error::Create(const tracked_objects::Location& location, } void Error::AddTo(ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, const std::string& domain, const std::string& code, const std::string& message) { @@ -58,7 +65,7 @@ void Error::AddTo(ErrorPtr* error, } void Error::AddToPrintf(ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, const std::string& domain, const std::string& code, const char* format, @@ -91,19 +98,7 @@ const Error* Error::GetFirstError() const { return err; } -Error::Error(const tracked_objects::Location& location, - const std::string& domain, - const std::string& code, - const std::string& message, - ErrorPtr inner_error) - : Error{tracked_objects::LocationSnapshot{location}, - domain, - code, - message, - std::move(inner_error)} { -} - -Error::Error(const tracked_objects::LocationSnapshot& location, +Error::Error(const base::Location& location, const std::string& domain, const std::string& code, const std::string& message, diff --git a/brillo/errors/error.h b/brillo/errors/error.h index 4cf60f5..d08f0e7 100644 --- a/brillo/errors/error.h +++ b/brillo/errors/error.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace brillo { @@ -23,11 +23,11 @@ class BRILLO_EXPORT Error { virtual ~Error() = default; // Creates an instance of Error class. - static ErrorPtr Create(const tracked_objects::Location& location, + static ErrorPtr Create(const base::Location& location, const std::string& domain, const std::string& code, const std::string& message); - static ErrorPtr Create(const tracked_objects::Location& location, + static ErrorPtr Create(const base::Location& location, const std::string& domain, const std::string& code, const std::string& message, @@ -36,14 +36,14 @@ class BRILLO_EXPORT Error { // initializes it with specified arguments and adds it to the head of // the error chain pointed to by |error|. static void AddTo(ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, const std::string& domain, const std::string& code, const std::string& message); // Same as the Error::AddTo above, but allows to pass in a printf-like // format string and optional parameters to format the error message. static void AddToPrintf(ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, const std::string& domain, const std::string& code, const char* format, @@ -58,7 +58,7 @@ class BRILLO_EXPORT Error { const std::string& GetMessage() const { return message_; } // Returns the location of the error in the source code. - const tracked_objects::LocationSnapshot& GetLocation() const { + const base::Location& GetLocation() const { return location_; } @@ -96,13 +96,7 @@ class BRILLO_EXPORT Error { protected: // Constructor is protected since this object is supposed to be // created via the Create factory methods. - Error(const tracked_objects::Location& location, - const std::string& domain, - const std::string& code, - const std::string& message, - ErrorPtr inner_error); - - Error(const tracked_objects::LocationSnapshot& location, + Error(const base::Location& location, const std::string& domain, const std::string& code, const std::string& message, @@ -116,7 +110,7 @@ class BRILLO_EXPORT Error { // Human-readable error message. std::string message_; // Error origin in the source code. - tracked_objects::LocationSnapshot location_; + base::Location location_; // Pointer to inner error, if any. This forms a chain of errors. ErrorPtr inner_error_; diff --git a/brillo/errors/error_codes.cc b/brillo/errors/error_codes.cc index 4e48b4e..6f60011 100644 --- a/brillo/errors/error_codes.cc +++ b/brillo/errors/error_codes.cc @@ -206,7 +206,7 @@ std::string ErrorCodeFromSystemError(int errnum) { } // anonymous namespace void AddSystemError(ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, int errnum) { std::string message = base::safe_strerror(errnum); std::string code = ErrorCodeFromSystemError(errnum); diff --git a/brillo/errors/error_codes.h b/brillo/errors/error_codes.h index a9964f6..4f1bc09 100644 --- a/brillo/errors/error_codes.h +++ b/brillo/errors/error_codes.h @@ -33,7 +33,7 @@ BRILLO_EXPORT extern const char kDomain[]; // Adds an Error object to the error chain identified by |error|, using // the system error code (see "errno"). BRILLO_EXPORT void AddSystemError(ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, int errnum); } // namespace system diff --git a/brillo/errors/error_unittest.cc b/brillo/errors/error_unittest.cc index 517dab5..93f4372 100644 --- a/brillo/errors/error_unittest.cc +++ b/brillo/errors/error_unittest.cc @@ -11,10 +11,10 @@ using brillo::Error; namespace { brillo::ErrorPtr GenerateNetworkError() { - tracked_objects::Location loc("GenerateNetworkError", + base::Location loc("GenerateNetworkError", "error_unittest.cc", 15, - ::tracked_objects::GetProgramCounter()); + ::base::GetProgramCounter()); return Error::Create(loc, "network", "not_found", "Resource not found"); } @@ -30,9 +30,9 @@ TEST(Error, Single) { EXPECT_EQ("network", err->GetDomain()); EXPECT_EQ("not_found", err->GetCode()); EXPECT_EQ("Resource not found", err->GetMessage()); - EXPECT_EQ("GenerateNetworkError", err->GetLocation().function_name); - EXPECT_EQ("error_unittest.cc", err->GetLocation().file_name); - EXPECT_EQ(15, err->GetLocation().line_number); + EXPECT_EQ("GenerateNetworkError", err->GetLocation().function_name()); + EXPECT_EQ("error_unittest.cc", err->GetLocation().file_name()); + EXPECT_EQ(15, err->GetLocation().line_number()); EXPECT_EQ(nullptr, err->GetInnerError()); EXPECT_TRUE(err->HasDomain("network")); EXPECT_FALSE(err->HasDomain("HTTP")); @@ -71,11 +71,11 @@ TEST(Error, Clone) { EXPECT_EQ(error1->GetDomain(), error2->GetDomain()); EXPECT_EQ(error1->GetCode(), error2->GetCode()); EXPECT_EQ(error1->GetMessage(), error2->GetMessage()); - EXPECT_EQ(error1->GetLocation().function_name, - error2->GetLocation().function_name); - EXPECT_EQ(error1->GetLocation().file_name, error2->GetLocation().file_name); - EXPECT_EQ(error1->GetLocation().line_number, - error2->GetLocation().line_number); + EXPECT_EQ(error1->GetLocation().function_name(), + error2->GetLocation().function_name()); + EXPECT_EQ(error1->GetLocation().file_name(), error2->GetLocation().file_name()); + EXPECT_EQ(error1->GetLocation().line_number(), + error2->GetLocation().line_number()); error1 = error1->GetInnerError(); error2 = error2->GetInnerError(); } diff --git a/brillo/http/http_transport.h b/brillo/http/http_transport.h index 768859e..e00166c 100644 --- a/brillo/http/http_transport.h +++ b/brillo/http/http_transport.h @@ -61,7 +61,7 @@ class BRILLO_EXPORT Transport : public std::enable_shared_from_this { // Runs |callback| on the task runner (message loop) associated with the // transport. For transports that do not contain references to real message // loops (e.g. a fake transport), calls the callback immediately. - virtual void RunCallbackAsync(const tracked_objects::Location& from_here, + virtual void RunCallbackAsync(const base::Location& from_here, const base::Closure& callback) = 0; // Initiates an asynchronous transfer on the given |connection|. diff --git a/brillo/http/http_transport_curl.cc b/brillo/http/http_transport_curl.cc index e0d78d5..9affc2a 100644 --- a/brillo/http/http_transport_curl.cc +++ b/brillo/http/http_transport_curl.cc @@ -31,7 +31,7 @@ namespace curl { // This is a class that stores connection data on particular CURL socket // and provides file descriptor watcher to monitor read and/or write operations // on the socket's file descriptor. -class Transport::SocketPollData : public base::MessageLoopForIO::Watcher { +class Transport::SocketPollData : public base::MessagePumpForIO::FdWatcher { public: SocketPollData(const std::shared_ptr& curl_interface, CURLM* curl_multi_handle, @@ -44,12 +44,12 @@ class Transport::SocketPollData : public base::MessageLoopForIO::Watcher { file_descriptor_watcher_(FROM_HERE) {} // Returns the pointer for the socket-specific file descriptor watcher. - base::MessageLoopForIO::FileDescriptorWatcher* GetWatcher() { + base::MessagePumpForIO::FdWatchController* GetWatcher() { return &file_descriptor_watcher_; } private: - // Overrides from base::MessageLoopForIO::Watcher. + // Overrides from base::MessagePumpForIO::Watcher. void OnFileCanReadWithoutBlocking(int fd) override { OnSocketReady(fd, CURL_CSELECT_IN); } @@ -80,7 +80,7 @@ class Transport::SocketPollData : public base::MessageLoopForIO::Watcher { // The socket file descriptor for the connection. curl_socket_t socket_fd_; // File descriptor watcher to notify us of asynchronous I/O on the FD. - base::MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; + base::MessagePumpForIO::FdWatchController file_descriptor_watcher_; DISALLOW_COPY_AND_ASSIGN(SocketPollData); }; @@ -206,7 +206,7 @@ std::shared_ptr Transport::CreateConnection( return connection; } -void Transport::RunCallbackAsync(const tracked_objects::Location& from_here, +void Transport::RunCallbackAsync(const base::Location& from_here, const base::Closure& callback) { base::MessageLoopForIO::current()->task_runner()->PostTask( from_here, callback); @@ -275,7 +275,7 @@ void Transport::SetLocalIpAddress(const std::string& ip_address) { } void Transport::AddEasyCurlError(brillo::ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, CURLcode code, CurlInterface* curl_interface) { brillo::Error::AddTo(error, location, "curl_easy_error", @@ -284,7 +284,7 @@ void Transport::AddEasyCurlError(brillo::ErrorPtr* error, } void Transport::AddMultiCurlError(brillo::ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, CURLMcode code, CurlInterface* curl_interface) { brillo::Error::AddTo(error, location, "curl_multi_error", @@ -367,16 +367,16 @@ int Transport::MultiSocketCallback(CURL* easy, return 0; } - base::MessageLoopForIO::Mode watch_mode = base::MessageLoopForIO::WATCH_READ; + base::MessagePumpForIO::Mode watch_mode = base::MessagePumpForIO::WATCH_READ; switch (what) { case CURL_POLL_IN: - watch_mode = base::MessageLoopForIO::WATCH_READ; + watch_mode = base::MessagePumpForIO::WATCH_READ; break; case CURL_POLL_OUT: - watch_mode = base::MessageLoopForIO::WATCH_WRITE; + watch_mode = base::MessagePumpForIO::WATCH_WRITE; break; case CURL_POLL_INOUT: - watch_mode = base::MessageLoopForIO::WATCH_READ_WRITE; + watch_mode = base::MessagePumpForIO::WATCH_READ_WRITE; break; default: LOG(FATAL) << "Unknown CURL socket action: " << what; diff --git a/brillo/http/http_transport_curl.h b/brillo/http/http_transport_curl.h index 518ee9d..175a675 100644 --- a/brillo/http/http_transport_curl.h +++ b/brillo/http/http_transport_curl.h @@ -48,7 +48,7 @@ class BRILLO_EXPORT Transport : public http::Transport { const std::string& referer, brillo::ErrorPtr* error) override; - void RunCallbackAsync(const tracked_objects::Location& from_here, + void RunCallbackAsync(const base::Location& from_here, const base::Closure& callback) override; RequestID StartAsyncTransfer(http::Connection* connection, @@ -64,12 +64,12 @@ class BRILLO_EXPORT Transport : public http::Transport { // Helper methods to convert CURL error codes (CURLcode and CURLMcode) // into brillo::Error object. static void AddEasyCurlError(brillo::ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, CURLcode code, CurlInterface* curl_interface); static void AddMultiCurlError(brillo::ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, CURLMcode code, CurlInterface* curl_interface); diff --git a/brillo/http/http_transport_fake.cc b/brillo/http/http_transport_fake.cc index cda885f..224b5de 100644 --- a/brillo/http/http_transport_fake.cc +++ b/brillo/http/http_transport_fake.cc @@ -64,7 +64,7 @@ std::shared_ptr Transport::CreateConnection( } void Transport::RunCallbackAsync( - const tracked_objects::Location& /* from_here */, + const base::Location& /* from_here */, const base::Closure& callback) { if (!async_) { callback.Run(); diff --git a/brillo/http/http_transport_fake.h b/brillo/http/http_transport_fake.h index e894c32..0a2fe90 100644 --- a/brillo/http/http_transport_fake.h +++ b/brillo/http/http_transport_fake.h @@ -91,7 +91,7 @@ class Transport : public http::Transport { const std::string& referer, brillo::ErrorPtr* error) override; - void RunCallbackAsync(const tracked_objects::Location& from_here, + void RunCallbackAsync(const base::Location& from_here, const base::Closure& callback) override; RequestID StartAsyncTransfer(http::Connection* connection, @@ -102,7 +102,7 @@ class Transport : public http::Transport { void SetDefaultTimeout(base::TimeDelta timeout) override; - void SetLocalIpAddress(const std::string& ip_address) override {} + void SetLocalIpAddress(const std::string& /* ip_address */) override {} private: // A list of user-supplied request handlers. diff --git a/brillo/http/mock_transport.h b/brillo/http/mock_transport.h index 040d20e..7504266 100644 --- a/brillo/http/mock_transport.h +++ b/brillo/http/mock_transport.h @@ -27,7 +27,7 @@ class MockTransport : public Transport { const std::string&, brillo::ErrorPtr*)); MOCK_METHOD2(RunCallbackAsync, - void(const tracked_objects::Location&, const base::Closure&)); + void(const base::Location&, const base::Closure&)); MOCK_METHOD3(StartAsyncTransfer, RequestID(Connection*, const SuccessCallback&, const ErrorCallback&)); diff --git a/brillo/message_loops/base_message_loop.cc b/brillo/message_loops/base_message_loop.cc index 500c29b..08465d7 100644 --- a/brillo/message_loops/base_message_loop.cc +++ b/brillo/message_loops/base_message_loop.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -81,7 +82,7 @@ BaseMessageLoop::~BaseMessageLoop() { } MessageLoop::TaskId BaseMessageLoop::PostDelayedTask( - const tracked_objects::Location& from_here, + const base::Location& from_here, const Closure &task, base::TimeDelta delay) { TaskId task_id = NextTaskId(); @@ -102,7 +103,7 @@ MessageLoop::TaskId BaseMessageLoop::PostDelayedTask( } MessageLoop::TaskId BaseMessageLoop::WatchFileDescriptor( - const tracked_objects::Location& from_here, + const base::Location& from_here, int fd, WatchMode mode, bool persistent, @@ -111,13 +112,13 @@ MessageLoop::TaskId BaseMessageLoop::WatchFileDescriptor( if (fd < 0) return MessageLoop::kTaskIdNull; - base::MessageLoopForIO::Mode base_mode = base::MessageLoopForIO::WATCH_READ; + base::MessagePumpForIO::Mode base_mode = base::MessagePumpForIO::WATCH_READ; switch (mode) { case MessageLoop::kWatchRead: - base_mode = base::MessageLoopForIO::WATCH_READ; + base_mode = base::MessagePumpForIO::WATCH_READ; break; case MessageLoop::kWatchWrite: - base_mode = base::MessageLoopForIO::WATCH_WRITE; + base_mode = base::MessagePumpForIO::WATCH_WRITE; break; default: return MessageLoop::kTaskIdNull; @@ -227,7 +228,7 @@ void BaseMessageLoop::BreakLoop() { Closure BaseMessageLoop::QuitClosure() const { if (base_run_loop_ == nullptr) - return base::Bind(&base::DoNothing); + return base::DoNothing(); return base_run_loop_->QuitClosure(); } @@ -307,11 +308,11 @@ unsigned int BaseMessageLoop::GetBinderMinor() { return binder_minor_; } -BaseMessageLoop::IOTask::IOTask(const tracked_objects::Location& location, +BaseMessageLoop::IOTask::IOTask(const base::Location& location, BaseMessageLoop* loop, MessageLoop::TaskId task_id, int fd, - base::MessageLoopForIO::Mode base_mode, + base::MessagePumpForIO::Mode base_mode, bool persistent, const Closure& task) : location_(location), loop_(loop), task_id_(task_id), @@ -319,8 +320,14 @@ BaseMessageLoop::IOTask::IOTask(const tracked_objects::Location& location, fd_watcher_(FROM_HERE) {} bool BaseMessageLoop::IOTask::StartWatching() { - return loop_->base_loop_->WatchFileDescriptor( - fd_, persistent_, base_mode_, &fd_watcher_, this); + // Please see MessagePumpLibevent for definition. + static_assert(std::is_same::value, + "MessagePumpForIO::WatchFileDescriptor is not supported " + "when MessagePumpForIO is not a MessagePumpLibevent."); + + return static_cast( + loop_->base_loop_->pump_.get())->WatchFileDescriptor( + fd_, persistent_, base_mode_, &fd_watcher_, this); } void BaseMessageLoop::IOTask::StopWatching() { @@ -362,7 +369,7 @@ void BaseMessageLoop::IOTask::OnFileReady() { if (base_scheduled) { DVLOG_LOC(location_, 1) << "Dispatching task_id " << task_id_ << " for " - << (base_mode_ == base::MessageLoopForIO::WATCH_READ ? + << (base_mode_ == base::MessagePumpForIO::WATCH_READ ? "reading" : "writing") << " file descriptor " << fd_ << ", scheduled from this location."; } else { @@ -390,7 +397,7 @@ void BaseMessageLoop::IOTask::OnFileReadyPostedTask() { DVLOG_LOC(location_, 1) << "Running task_id " << task_id_ << " for " - << (base_mode_ == base::MessageLoopForIO::WATCH_READ ? + << (base_mode_ == base::MessagePumpForIO::WATCH_READ ? "reading" : "writing") << " file descriptor " << fd_ << ", scheduled from this location."; diff --git a/brillo/message_loops/base_message_loop.h b/brillo/message_loops/base_message_loop.h index f615a1b..163ea4f 100644 --- a/brillo/message_loops/base_message_loop.h +++ b/brillo/message_loops/base_message_loop.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -39,11 +40,11 @@ class BRILLO_EXPORT BaseMessageLoop : public MessageLoop { ~BaseMessageLoop() override; // MessageLoop overrides. - TaskId PostDelayedTask(const tracked_objects::Location& from_here, + TaskId PostDelayedTask(const base::Location& from_here, const base::Closure& task, base::TimeDelta delay) override; using MessageLoop::PostDelayedTask; - TaskId WatchFileDescriptor(const tracked_objects::Location& from_here, + TaskId WatchFileDescriptor(const base::Location& from_here, int fd, WatchMode mode, bool persistent, @@ -86,23 +87,23 @@ class BRILLO_EXPORT BaseMessageLoop : public MessageLoop { unsigned int GetBinderMinor(); struct DelayedTask { - tracked_objects::Location location; + base::Location location; MessageLoop::TaskId task_id; base::Closure closure; }; - class IOTask : public base::MessageLoopForIO::Watcher { + class IOTask : public base::MessagePumpForIO::FdWatcher { public: - IOTask(const tracked_objects::Location& location, + IOTask(const base::Location& location, BaseMessageLoop* loop, MessageLoop::TaskId task_id, int fd, - base::MessageLoopForIO::Mode base_mode, + base::MessagePumpForIO::Mode base_mode, bool persistent, const base::Closure& task); - const tracked_objects::Location& location() const { return location_; } + const base::Location& location() const { return location_; } // Used to start/stop watching the file descriptor while keeping the // IOTask entry available. @@ -122,7 +123,7 @@ class BRILLO_EXPORT BaseMessageLoop : public MessageLoop { void RunImmediately() { immediate_run_= true; } private: - tracked_objects::Location location_; + base::Location location_; BaseMessageLoop* loop_; // These are the arguments passed in the constructor, basically forwarding @@ -130,11 +131,11 @@ class BRILLO_EXPORT BaseMessageLoop : public MessageLoop { // TaskId for this task. MessageLoop::TaskId task_id_; int fd_; - base::MessageLoopForIO::Mode base_mode_; + base::MessagePumpForIO::Mode base_mode_; bool persistent_; base::Closure closure_; - base::MessageLoopForIO::FileDescriptorWatcher fd_watcher_; + base::MessagePumpForIO::FdWatchController fd_watcher_; // Tells whether there is a pending call to OnFileReadPostedTask(). bool posted_task_pending_{false}; diff --git a/brillo/message_loops/fake_message_loop.cc b/brillo/message_loops/fake_message_loop.cc index 4d0f157..41f5b51 100644 --- a/brillo/message_loops/fake_message_loop.cc +++ b/brillo/message_loops/fake_message_loop.cc @@ -14,7 +14,7 @@ FakeMessageLoop::FakeMessageLoop(base::SimpleTestClock* clock) } MessageLoop::TaskId FakeMessageLoop::PostDelayedTask( - const tracked_objects::Location& from_here, + const base::Location& from_here, const base::Closure& task, base::TimeDelta delay) { // If no SimpleTestClock was provided, we use the last time we fired a @@ -34,7 +34,7 @@ MessageLoop::TaskId FakeMessageLoop::PostDelayedTask( } MessageLoop::TaskId FakeMessageLoop::WatchFileDescriptor( - const tracked_objects::Location& from_here, + const base::Location& from_here, int fd, WatchMode mode, bool persistent, diff --git a/brillo/message_loops/fake_message_loop.h b/brillo/message_loops/fake_message_loop.h index c8c1313..4b6e8ac 100644 --- a/brillo/message_loops/fake_message_loop.h +++ b/brillo/message_loops/fake_message_loop.h @@ -36,11 +36,11 @@ class BRILLO_EXPORT FakeMessageLoop : public MessageLoop { explicit FakeMessageLoop(base::SimpleTestClock* clock); ~FakeMessageLoop() override = default; - TaskId PostDelayedTask(const tracked_objects::Location& from_here, + TaskId PostDelayedTask(const base::Location& from_here, const base::Closure& task, base::TimeDelta delay) override; using MessageLoop::PostDelayedTask; - TaskId WatchFileDescriptor(const tracked_objects::Location& from_here, + TaskId WatchFileDescriptor(const base::Location& from_here, int fd, WatchMode mode, bool persistent, @@ -63,7 +63,7 @@ class BRILLO_EXPORT FakeMessageLoop : public MessageLoop { private: struct ScheduledTask { - tracked_objects::Location location; + base::Location location; bool persistent; base::Closure callback; }; diff --git a/brillo/message_loops/fake_message_loop_unittest.cc b/brillo/message_loops/fake_message_loop_unittest.cc index 7dc54f7..18f0b4b 100644 --- a/brillo/message_loops/fake_message_loop_unittest.cc +++ b/brillo/message_loops/fake_message_loop_unittest.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -65,8 +66,8 @@ TEST_F(FakeMessageLoopTest, PostDelayedTaskAdvancesTheTime) { Time start = Time::FromInternalValue(1000000); clock_.SetNow(start); loop_.reset(new FakeMessageLoop(&clock_)); - loop_->PostDelayedTask(Bind(&base::DoNothing), TimeDelta::FromSeconds(1)); - loop_->PostDelayedTask(Bind(&base::DoNothing), TimeDelta::FromSeconds(2)); + loop_->PostDelayedTask(base::DoNothing(), TimeDelta::FromSeconds(1)); + loop_->PostDelayedTask(base::DoNothing(), TimeDelta::FromSeconds(2)); EXPECT_FALSE(loop_->RunOnce(false)); // If the callback didn't run, the time shouldn't change. EXPECT_EQ(start, clock_.Now()); @@ -113,7 +114,7 @@ TEST_F(FakeMessageLoopTest, WatchFileDescriptorWaits) { } TEST_F(FakeMessageLoopTest, PendingTasksTest) { - loop_->PostDelayedTask(Bind(&base::DoNothing), TimeDelta::FromSeconds(1)); + loop_->PostDelayedTask(base::DoNothing(), TimeDelta::FromSeconds(1)); EXPECT_TRUE(loop_->PendingTasks()); loop_->Run(); } diff --git a/brillo/message_loops/message_loop.h b/brillo/message_loops/message_loop.h index c7e3586..1f65d96 100644 --- a/brillo/message_loops/message_loop.h +++ b/brillo/message_loops/message_loop.h @@ -49,12 +49,12 @@ class BRILLO_EXPORT MessageLoop { // Note that once the call is executed or canceled, the TaskId could be reused // at a later point. // This methond can only be called from the same thread running the main loop. - virtual TaskId PostDelayedTask(const tracked_objects::Location& from_here, + virtual TaskId PostDelayedTask(const base::Location& from_here, const base::Closure& task, base::TimeDelta delay) = 0; // Variant without the Location for easier usage. TaskId PostDelayedTask(const base::Closure& task, base::TimeDelta delay) { - return PostDelayedTask(tracked_objects::Location(), task, delay); + return PostDelayedTask(base::Location(), task, delay); } // A convenience method to schedule a call with no delay. @@ -62,7 +62,7 @@ class BRILLO_EXPORT MessageLoop { TaskId PostTask(const base::Closure& task) { return PostDelayedTask(task, base::TimeDelta()); } - TaskId PostTask(const tracked_objects::Location& from_here, + TaskId PostTask(const base::Location& from_here, const base::Closure& task) { return PostDelayedTask(from_here, task, base::TimeDelta()); } @@ -80,7 +80,7 @@ class BRILLO_EXPORT MessageLoop { // is canceled with CancelTask(). // Returns the TaskId describing this task. In case of error, returns // kTaskIdNull. - virtual TaskId WatchFileDescriptor(const tracked_objects::Location& from_here, + virtual TaskId WatchFileDescriptor(const base::Location& from_here, int fd, WatchMode mode, bool persistent, @@ -92,7 +92,7 @@ class BRILLO_EXPORT MessageLoop { bool persistent, const base::Closure& task) { return WatchFileDescriptor( - tracked_objects::Location(), fd, mode, persistent, task); + base::Location(), fd, mode, persistent, task); } // Cancel a scheduled task. Returns whether the task was canceled. For diff --git a/brillo/message_loops/message_loop_unittest.cc b/brillo/message_loops/message_loop_unittest.cc index 8024256..bda3336 100644 --- a/brillo/message_loops/message_loop_unittest.cc +++ b/brillo/message_loops/message_loop_unittest.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -117,7 +118,7 @@ TYPED_TEST(MessageLoopTest, PostDelayedTaskRunsEventuallyTest) { // MessageLoop. This is important because only one of the two methods is // virtual, so you need to unhide the other when overriding the virtual one. TYPED_TEST(MessageLoopTest, PostDelayedTaskWithoutLocation) { - this->loop_->PostDelayedTask(Bind(&base::DoNothing), TimeDelta()); + this->loop_->PostDelayedTask(base::DoNothing(), TimeDelta()); EXPECT_EQ(1, MessageLoopRunMaxIterations(this->loop_.get(), 100)); } diff --git a/brillo/message_loops/mock_message_loop.h b/brillo/message_loops/mock_message_loop.h index 71632f2..9f9a1e4 100644 --- a/brillo/message_loops/mock_message_loop.h +++ b/brillo/message_loops/mock_message_loop.h @@ -36,7 +36,7 @@ class BRILLO_EXPORT MockMessageLoop : public MessageLoop { .WillByDefault(::testing::Invoke( &fake_loop_, static_cast( &FakeMessageLoop::PostDelayedTask))); @@ -45,7 +45,7 @@ class BRILLO_EXPORT MockMessageLoop : public MessageLoop { .WillByDefault(::testing::Invoke( &fake_loop_, static_cast( &FakeMessageLoop::WatchFileDescriptor))); ON_CALL(*this, CancelTask(::testing::_)) @@ -58,12 +58,12 @@ class BRILLO_EXPORT MockMessageLoop : public MessageLoop { ~MockMessageLoop() override = default; MOCK_METHOD3(PostDelayedTask, - TaskId(const tracked_objects::Location& from_here, + TaskId(const base::Location& from_here, const base::Closure& task, base::TimeDelta delay)); using MessageLoop::PostDelayedTask; MOCK_METHOD5(WatchFileDescriptor, - TaskId(const tracked_objects::Location& from_here, + TaskId(const base::Location& from_here, int fd, WatchMode mode, bool persistent, diff --git a/brillo/process_reaper.cc b/brillo/process_reaper.cc index 3d311c4..0da3b5d 100644 --- a/brillo/process_reaper.cc +++ b/brillo/process_reaper.cc @@ -35,7 +35,7 @@ void ProcessReaper::Unregister() { async_signal_handler_ = nullptr; } -bool ProcessReaper::WatchForChild(const tracked_objects::Location& from_here, +bool ProcessReaper::WatchForChild(const base::Location& from_here, pid_t pid, const ChildCallback& callback) { if (watched_processes_.find(pid) != watched_processes_.end()) diff --git a/brillo/process_reaper.h b/brillo/process_reaper.h index 41bbe73..7b70a8d 100644 --- a/brillo/process_reaper.h +++ b/brillo/process_reaper.h @@ -39,7 +39,7 @@ class BRILLO_EXPORT ProcessReaper final { // selected process exits or the process terminates for other reason. The // |callback| receives the exit status and exit code of the terminated process // as a siginfo_t. See wait(2) for details about siginfo_t. - bool WatchForChild(const tracked_objects::Location& from_here, + bool WatchForChild(const base::Location& from_here, pid_t pid, const ChildCallback& callback); @@ -56,7 +56,7 @@ class BRILLO_EXPORT ProcessReaper final { bool HandleSIGCHLD(const signalfd_siginfo& sigfd_info); struct WatchedProcess { - tracked_objects::Location location; + base::Location location; ChildCallback callback; }; std::map watched_processes_; diff --git a/brillo/streams/fake_stream.cc b/brillo/streams/fake_stream.cc index 0428935..498b9d4 100644 --- a/brillo/streams/fake_stream.cc +++ b/brillo/streams/fake_stream.cc @@ -381,7 +381,6 @@ bool FakeStream::WaitForDataBlocking(AccessMode in_mode, base::TimeDelta timeout, AccessMode* out_mode, ErrorPtr* error) { - const base::TimeDelta zero_delay; bool read_requested = stream_utils::IsReadAccessMode(in_mode); bool write_requested = stream_utils::IsWriteAccessMode(in_mode); diff --git a/brillo/streams/memory_containers.cc b/brillo/streams/memory_containers.cc index c1b842e..f0608b2 100644 --- a/brillo/streams/memory_containers.cc +++ b/brillo/streams/memory_containers.cc @@ -12,7 +12,7 @@ namespace data_container { namespace { -bool ErrorStreamReadOnly(const tracked_objects::Location& location, +bool ErrorStreamReadOnly(const base::Location& location, ErrorPtr* error) { Error::AddTo(error, location, diff --git a/brillo/streams/stream_utils.cc b/brillo/streams/stream_utils.cc index 5f3be24..3f7a14a 100644 --- a/brillo/streams/stream_utils.cc +++ b/brillo/streams/stream_utils.cc @@ -80,7 +80,7 @@ void PerformRead(const std::shared_ptr& state) { } // anonymous namespace -bool ErrorStreamClosed(const tracked_objects::Location& location, +bool ErrorStreamClosed(const base::Location& location, ErrorPtr* error) { Error::AddTo(error, location, @@ -90,7 +90,7 @@ bool ErrorStreamClosed(const tracked_objects::Location& location, return false; } -bool ErrorOperationNotSupported(const tracked_objects::Location& location, +bool ErrorOperationNotSupported(const base::Location& location, ErrorPtr* error) { Error::AddTo(error, location, @@ -100,7 +100,7 @@ bool ErrorOperationNotSupported(const tracked_objects::Location& location, return false; } -bool ErrorReadPastEndOfStream(const tracked_objects::Location& location, +bool ErrorReadPastEndOfStream(const base::Location& location, ErrorPtr* error) { Error::AddTo(error, location, @@ -110,7 +110,7 @@ bool ErrorReadPastEndOfStream(const tracked_objects::Location& location, return false; } -bool ErrorOperationTimeout(const tracked_objects::Location& location, +bool ErrorOperationTimeout(const base::Location& location, ErrorPtr* error) { Error::AddTo(error, location, @@ -120,7 +120,7 @@ bool ErrorOperationTimeout(const tracked_objects::Location& location, return false; } -bool CheckInt64Overflow(const tracked_objects::Location& location, +bool CheckInt64Overflow(const base::Location& location, uint64_t position, int64_t offset, ErrorPtr* error) { @@ -148,7 +148,7 @@ bool CheckInt64Overflow(const tracked_objects::Location& location, return false; } -bool CalculateStreamPosition(const tracked_objects::Location& location, +bool CalculateStreamPosition(const base::Location& location, int64_t offset, Stream::Whence whence, uint64_t current_position, diff --git a/brillo/streams/stream_utils.h b/brillo/streams/stream_utils.h index 981a6d5..2631978 100644 --- a/brillo/streams/stream_utils.h +++ b/brillo/streams/stream_utils.h @@ -14,19 +14,19 @@ namespace stream_utils { // Generates "Stream closed" error and returns false. BRILLO_EXPORT bool ErrorStreamClosed( - const tracked_objects::Location& location, ErrorPtr* error); + const base::Location& location, ErrorPtr* error); // Generates "Not supported" error and returns false. BRILLO_EXPORT bool ErrorOperationNotSupported( - const tracked_objects::Location& location, ErrorPtr* error); + const base::Location& location, ErrorPtr* error); // Generates "Read past end of stream" error and returns false. BRILLO_EXPORT bool ErrorReadPastEndOfStream( - const tracked_objects::Location& location, ErrorPtr* error); + const base::Location& location, ErrorPtr* error); // Generates "Operation time out" error and returns false. BRILLO_EXPORT bool ErrorOperationTimeout( - const tracked_objects::Location& location, ErrorPtr* error); + const base::Location& location, ErrorPtr* error); // Checks if |position| + |offset| fit within the constraint of positive // signed int64_t type. We use uint64_t for absolute stream pointer positions, @@ -37,7 +37,7 @@ BRILLO_EXPORT bool ErrorOperationTimeout( // The |location| parameter will be used to report the origin of the error // if one is generated/triggered. BRILLO_EXPORT bool CheckInt64Overflow( - const tracked_objects::Location& location, + const base::Location& location, uint64_t position, int64_t offset, ErrorPtr* error); @@ -50,7 +50,7 @@ BRILLO_EXPORT bool CheckInt64Overflow( // The |location| parameter will be used to report the origin of the error // if one is generated/triggered. BRILLO_EXPORT bool CalculateStreamPosition( - const tracked_objects::Location& location, + const base::Location& location, int64_t offset, Stream::Whence whence, uint64_t current_position, diff --git a/brillo/streams/tls_stream.cc b/brillo/streams/tls_stream.cc index ac116a4..fde4193 100644 --- a/brillo/streams/tls_stream.cc +++ b/brillo/streams/tls_stream.cc @@ -104,7 +104,7 @@ class TlsStream::TlsStreamImpl { private: bool ReportError(ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, const std::string& message); void DoHandshake(const base::Closure& success_callback, const Stream::ErrorCallback& error_callback); @@ -283,7 +283,7 @@ void TlsStream::TlsStreamImpl::CancelPendingAsyncOperations() { bool TlsStream::TlsStreamImpl::ReportError( ErrorPtr* error, - const tracked_objects::Location& location, + const base::Location& location, const std::string& message) { const char* file = nullptr; int line = 0; @@ -292,7 +292,7 @@ bool TlsStream::TlsStreamImpl::ReportError( while (auto errnum = ERR_get_error_line_data(&file, &line, &data, &flags)) { char buf[256]; ERR_error_string_n(errnum, buf, sizeof(buf)); - tracked_objects::Location ssl_location{"Unknown", file, line, nullptr}; + base::Location ssl_location{"Unknown", file, line, nullptr}; std::string ssl_message = buf; if (flags & ERR_TXT_STRING) { ssl_message += ": "; diff --git a/brillo/value_conversion.h b/brillo/value_conversion.h index d681f76..b520a77 100644 --- a/brillo/value_conversion.h +++ b/brillo/value_conversion.h @@ -75,7 +75,7 @@ bool FromValue(const base::Value& in_value, std::vector* out_value) { out_value->reserve(list->GetSize()); for (const auto& item : *list) { T value{}; - if (!FromValue(*item, &value)) + if (!FromValue(item, &value)) return false; out_value->push_back(std::move(value)); } -- cgit v1.2.3