diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-04 14:17:57 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-05 10:05:06 +0000 |
commit | 39d357e3248f80abea0159765ff39554affb40db (patch) | |
tree | aba0e6bfb76de0244bba0f5fdbd64b830dd6e621 /chromium/dbus | |
parent | 87778abf5a1f89266f37d1321b92a21851d8244d (diff) | |
download | qtwebengine-chromium-39d357e3248f80abea0159765ff39554affb40db.tar.gz |
BASELINE: Update Chromium to 55.0.2883.105
And updates ninja to 1.7.2
Change-Id: I20d43c737f82764d857ada9a55586901b18b9243
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/dbus')
26 files changed, 345 insertions, 481 deletions
diff --git a/chromium/dbus/BUILD.gn b/chromium/dbus/BUILD.gn index ed113c85421..c0bd77d8db3 100644 --- a/chromium/dbus/BUILD.gn +++ b/chromium/dbus/BUILD.gn @@ -17,8 +17,6 @@ component("dbus") { "dbus_statistics.h", "exported_object.cc", "exported_object.h", - "file_descriptor.cc", - "file_descriptor.h", "message.cc", "message.h", "object_manager.cc", @@ -59,7 +57,7 @@ proto_library("test_proto") { # This target contains mocks that can be used to write unit tests without # issuing actual D-Bus calls. -source_set("test_support") { +static_library("test_support") { testonly = true sources = [ "mock_bus.cc", diff --git a/chromium/dbus/bus.cc b/chromium/dbus/bus.cc index d6e2c5b6401..186c9380d0f 100644 --- a/chromium/dbus/bus.cc +++ b/chromium/dbus/bus.cc @@ -400,13 +400,6 @@ void Bus::RemoveObjectManagerInternalHelper( callback.Run(); } -void Bus::GetManagedObjects() { - for (ObjectManagerTable::iterator iter = object_manager_table_.begin(); - iter != object_manager_table_.end(); ++iter) { - iter->second->GetManagedObjects(); - } -} - bool Bus::Connect() { // dbus_bus_get_private() and dbus_bus_get() are blocking calls. AssertOnDBusThread(); diff --git a/chromium/dbus/bus.h b/chromium/dbus/bus.h index 7d3915909b9..d66048bba71 100644 --- a/chromium/dbus/bus.h +++ b/chromium/dbus/bus.h @@ -360,12 +360,6 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> { const ObjectPath& object_path, const base::Closure& callback); - // Instructs all registered object managers to retrieve their set of managed - // objects from their respective remote objects. There is no need to call this - // manually, this is called automatically by the D-Bus thread manager once - // implementation classes are registered. - virtual void GetManagedObjects(); - // Shuts down the bus and blocks until it's done. More specifically, this // function does the following: // diff --git a/chromium/dbus/dbus.gyp b/chromium/dbus/dbus.gyp deleted file mode 100644 index 264383ee4ba..00000000000 --- a/chromium/dbus/dbus.gyp +++ /dev/null @@ -1,141 +0,0 @@ -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'variables': { - 'chromium_code': 1, - }, - 'targets': [ - { - 'target_name': 'dbus', - 'type': '<(component)', - 'dependencies': [ - '../base/base.gyp:base', - '../build/linux/system.gyp:dbus', - '../third_party/protobuf/protobuf.gyp:protobuf_lite', - ], - 'export_dependent_settings': [ - '../base/base.gyp:base', - ], - 'defines': [ - 'DBUS_IMPLEMENTATION', - ], - 'sources': [ - 'bus.cc', - 'bus.h', - 'dbus_export.h', - 'dbus_statistics.cc', - 'dbus_statistics.h', - 'exported_object.cc', - 'exported_object.h', - 'file_descriptor.cc', - 'file_descriptor.h', - 'message.cc', - 'message.h', - 'object_manager.cc', - 'object_manager.h', - 'object_path.cc', - 'object_path.h', - 'object_proxy.cc', - 'object_proxy.h', - 'property.cc', - 'property.h', - 'scoped_dbus_error.cc', - 'scoped_dbus_error.h', - 'string_util.cc', - 'string_util.h', - 'util.cc', - 'util.h', - 'values_util.cc', - 'values_util.h', - ], - }, - { - # Protobuf compiler / generator test protocol buffer - 'target_name': 'dbus_test_proto', - 'type': 'static_library', - 'sources': [ 'test_proto.proto' ], - 'variables': { - 'proto_out_dir': 'dbus', - }, - 'includes': [ '../build/protoc.gypi' ], - }, - { - # This target contains mocks that can be used to write unit tests - # without issuing actual D-Bus calls. - 'target_name': 'dbus_test_support', - 'type': 'static_library', - 'dependencies': [ - '../build/linux/system.gyp:dbus', - '../testing/gmock.gyp:gmock', - 'dbus', - ], - 'sources': [ - 'mock_bus.cc', - 'mock_bus.h', - 'mock_exported_object.cc', - 'mock_exported_object.h', - 'mock_object_manager.cc', - 'mock_object_manager.h', - 'mock_object_proxy.cc', - 'mock_object_proxy.h', - ], - 'include_dirs': [ - '..', - ], - }, - { - 'target_name': 'dbus_unittests', - 'type': 'executable', - 'dependencies': [ - '../base/base.gyp:run_all_unittests', - '../base/base.gyp:test_support_base', - '../build/linux/system.gyp:dbus', - '../testing/gmock.gyp:gmock', - '../testing/gtest.gyp:gtest', - 'dbus', - 'dbus_test_proto', - 'dbus_test_support', - ], - 'sources': [ - 'bus_unittest.cc', - 'dbus_statistics_unittest.cc', - 'end_to_end_async_unittest.cc', - 'end_to_end_sync_unittest.cc', - 'message_unittest.cc', - 'mock_unittest.cc', - 'object_manager_unittest.cc', - 'object_proxy_unittest.cc', - 'property_unittest.cc', - 'signal_sender_verification_unittest.cc', - 'string_util_unittest.cc', - 'test_service.cc', - 'test_service.h', - 'util_unittest.cc', - 'values_util_unittest.cc', - ], - 'include_dirs': [ - '..', - ], - }, - { - 'target_name': 'dbus_test_server', - 'type': 'executable', - 'dependencies': [ - '../base/base.gyp:test_support_base', - '../base/base.gyp:base', - '../build/linux/system.gyp:dbus', - 'dbus', - ], - 'sources': [ - 'test_server.cc', - 'test_service.cc', - 'test_service.h', - ], - 'include_dirs': [ - '..', - ], - }, - ], -} diff --git a/chromium/dbus/dbus_statistics.cc b/chromium/dbus/dbus_statistics.cc index e1e0973d5c7..4bcf7fbaa4a 100644 --- a/chromium/dbus/dbus_statistics.cc +++ b/chromium/dbus/dbus_statistics.cc @@ -69,7 +69,7 @@ class DBusStatistics { ~DBusStatistics() { DCHECK_EQ(origin_thread_id_, base::PlatformThread::CurrentId()); - STLDeleteContainerPointers(stats_.begin(), stats_.end()); + base::STLDeleteContainerPointers(stats_.begin(), stats_.end()); } // Enum to specify which field in Stat to increment in AddStat diff --git a/chromium/dbus/end_to_end_async_unittest.cc b/chromium/dbus/end_to_end_async_unittest.cc index b02b0439418..2de55c38f6e 100644 --- a/chromium/dbus/end_to_end_async_unittest.cc +++ b/chromium/dbus/end_to_end_async_unittest.cc @@ -13,6 +13,7 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/test/test_timeouts.h" #include "base/threading/thread.h" @@ -441,9 +442,8 @@ TEST_F(EndToEndAsyncTest, CancelPendingCalls) { // We shouldn't receive any responses. Wait for a while just to make sure. run_loop_.reset(new base::RunLoop); - message_loop_.PostDelayedTask(FROM_HERE, - run_loop_->QuitClosure(), - TestTimeouts::tiny_timeout()); + message_loop_.task_runner()->PostDelayedTask( + FROM_HERE, run_loop_->QuitClosure(), TestTimeouts::tiny_timeout()); run_loop_->Run(); EXPECT_TRUE(response_strings_.empty()); } @@ -565,9 +565,8 @@ TEST_F(EndToEndAsyncTest, EmptyResponseCallback) { ObjectProxy::EmptyResponseCallback()); // Post a delayed task to quit the message loop. run_loop_.reset(new base::RunLoop); - message_loop_.PostDelayedTask(FROM_HERE, - run_loop_->QuitClosure(), - TestTimeouts::tiny_timeout()); + message_loop_.task_runner()->PostDelayedTask( + FROM_HERE, run_loop_->QuitClosure(), TestTimeouts::tiny_timeout()); run_loop_->Run(); // We cannot tell if the empty callback is called, but at least we can // check if the test does not crash. diff --git a/chromium/dbus/file_descriptor.cc b/chromium/dbus/file_descriptor.cc deleted file mode 100644 index b690881749f..00000000000 --- a/chromium/dbus/file_descriptor.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <algorithm> - -#include "base/bind.h" -#include "base/files/file.h" -#include "base/location.h" -#include "base/logging.h" -#include "base/threading/worker_pool.h" -#include "dbus/file_descriptor.h" - -using std::swap; - -namespace dbus { - -void CHROME_DBUS_EXPORT FileDescriptor::Deleter::operator()( - FileDescriptor* fd) { - base::WorkerPool::PostTask( - FROM_HERE, base::Bind(&base::DeletePointer<FileDescriptor>, fd), false); -} - -FileDescriptor::FileDescriptor(FileDescriptor&& other) : FileDescriptor() { - Swap(&other); -} - -FileDescriptor::~FileDescriptor() { - if (owner_) - base::File auto_closer(value_); -} - -FileDescriptor& FileDescriptor::operator=(FileDescriptor&& other) { - Swap(&other); - return *this; -} - -int FileDescriptor::value() const { - CHECK(valid_); - return value_; -} - -int FileDescriptor::TakeValue() { - CHECK(valid_); // NB: check first so owner_ is unchanged if this triggers - owner_ = false; - return value_; -} - -void FileDescriptor::CheckValidity() { - base::File file(value_); - if (!file.IsValid()) { - valid_ = false; - return; - } - - base::File::Info info; - bool ok = file.GetInfo(&info); - file.TakePlatformFile(); // Prevent |value_| from being closed by |file|. - valid_ = (ok && !info.is_directory); -} - -void FileDescriptor::Swap(FileDescriptor* other) { - swap(value_, other->value_); - swap(owner_, other->owner_); - swap(valid_, other->valid_); -} - -} // namespace dbus diff --git a/chromium/dbus/file_descriptor.h b/chromium/dbus/file_descriptor.h deleted file mode 100644 index f8e86777eaf..00000000000 --- a/chromium/dbus/file_descriptor.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef DBUS_FILE_DESCRIPTOR_H_ -#define DBUS_FILE_DESCRIPTOR_H_ - -#include <memory> - -#include "base/macros.h" -#include "dbus/dbus_export.h" - -namespace dbus { - -// FileDescriptor is a type used to encapsulate D-Bus file descriptors -// and to follow the RAII idiom appropiate for use with message operations -// where the descriptor might be easily leaked. To guard against this the -// descriptor is closed when an instance is destroyed if it is owned. -// Ownership is asserted only when PutValue is used and TakeValue can be -// used to take ownership. -// -// For example, in the following -// FileDescriptor fd; -// if (!reader->PopString(&name) || -// !reader->PopFileDescriptor(&fd) || -// !reader->PopUint32(&flags)) { -// the descriptor in fd will be closed if the PopUint32 fails. But -// writer.AppendFileDescriptor(dbus::FileDescriptor(1)); -// will not automatically close "1" because it is not owned. -// -// Descriptors must be validated before marshalling in a D-Bus message -// or using them after unmarshalling. We disallow descriptors to a -// directory to reduce the security risks. Splitting out validation -// also allows the caller to do this work on the File thread to conform -// with i/o restrictions. -class CHROME_DBUS_EXPORT FileDescriptor { - public: - // This provides a simple way to pass around file descriptors since they must - // be closed on a thread that is allowed to perform I/O. - struct Deleter { - void CHROME_DBUS_EXPORT operator()(FileDescriptor* fd); - }; - - // Permits initialization without a value for passing to - // dbus::MessageReader::PopFileDescriptor to fill in and from int values. - FileDescriptor() : value_(-1), owner_(false), valid_(false) {} - explicit FileDescriptor(int value) : value_(value), owner_(false), - valid_(false) {} - - FileDescriptor(FileDescriptor&& other); - - virtual ~FileDescriptor(); - - FileDescriptor& operator=(FileDescriptor&& other); - - // Retrieves value as an int without affecting ownership. - int value() const; - - // Retrieves whether or not the descriptor is ok to send/receive. - int is_valid() const { return valid_; } - - // Sets the value and assign ownership. - void PutValue(int value) { - value_ = value; - owner_ = true; - valid_ = false; - } - - // Takes the value and ownership. - int TakeValue(); - - // Checks (and records) validity of the file descriptor. - // We disallow directories to avoid potential sandbox escapes. - // Note this call must be made on a thread where file i/o is allowed. - void CheckValidity(); - - private: - void Swap(FileDescriptor* other); - - int value_; - bool owner_; - bool valid_; - - DISALLOW_COPY_AND_ASSIGN(FileDescriptor); -}; - -using ScopedFileDescriptor = - std::unique_ptr<FileDescriptor, FileDescriptor::Deleter>; - -} // namespace dbus - -#endif // DBUS_FILE_DESCRIPTOR_H_ diff --git a/chromium/dbus/message.cc b/chromium/dbus/message.cc index 4a84756c41f..c8663f72ad6 100644 --- a/chromium/dbus/message.cc +++ b/chromium/dbus/message.cc @@ -222,11 +222,11 @@ std::string Message::ToStringInternal(const std::string& indent, case UNIX_FD: { CHECK(IsDBusTypeUnixFdSupported()); - FileDescriptor file_descriptor; + base::ScopedFD file_descriptor; if (!reader->PopFileDescriptor(&file_descriptor)) return kBrokenMessage; output += indent + "fd#" + - base::IntToString(file_descriptor.value()) + "\n"; + base::IntToString(file_descriptor.get()) + "\n"; break; } default: @@ -714,15 +714,9 @@ void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) { CloseContainer(&variant_writer); } -void MessageWriter::AppendFileDescriptor(const FileDescriptor& value) { +void MessageWriter::AppendFileDescriptor(int value) { CHECK(IsDBusTypeUnixFdSupported()); - - if (!value.is_valid()) { - // NB: sending a directory potentially enables sandbox escape - LOG(FATAL) << "Attempt to pass invalid file descriptor"; - } - int fd = value.value(); - AppendBasic(DBUS_TYPE_UNIX_FD, &fd); + AppendBasic(DBUS_TYPE_UNIX_FD, &value); // This duplicates the FD. } // @@ -1016,7 +1010,7 @@ bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) { return variant_reader.PopBasic(dbus_type, value); } -bool MessageReader::PopFileDescriptor(FileDescriptor* value) { +bool MessageReader::PopFileDescriptor(base::ScopedFD* value) { CHECK(IsDBusTypeUnixFdSupported()); int fd = -1; @@ -1024,8 +1018,7 @@ bool MessageReader::PopFileDescriptor(FileDescriptor* value) { if (!success) return false; - value->PutValue(fd); - // NB: the caller must check validity before using the value + *value = base::ScopedFD(fd); return true; } diff --git a/chromium/dbus/message.h b/chromium/dbus/message.h index 0aa010ccde0..256a8428c58 100644 --- a/chromium/dbus/message.h +++ b/chromium/dbus/message.h @@ -13,9 +13,9 @@ #include <string> #include <vector> +#include "base/files/scoped_file.h" #include "base/macros.h" #include "dbus/dbus_export.h" -#include "dbus/file_descriptor.h" #include "dbus/object_path.h" namespace google { @@ -285,7 +285,10 @@ class CHROME_DBUS_EXPORT MessageWriter { void AppendDouble(double value); void AppendString(const std::string& value); void AppendObjectPath(const ObjectPath& value); - void AppendFileDescriptor(const FileDescriptor& value); + + // Appends a file descriptor to the message. + // The FD will be duplicated so you still have to close the original FD. + void AppendFileDescriptor(int value); // Opens an array. The array contents can be added to the array with // |sub_writer|. The client code must close the array with @@ -398,7 +401,7 @@ class CHROME_DBUS_EXPORT MessageReader { bool PopDouble(double* value); bool PopString(std::string* value); bool PopObjectPath(ObjectPath* value); - bool PopFileDescriptor(FileDescriptor* value); + bool PopFileDescriptor(base::ScopedFD* value); // Sets up the given message reader to read an array at the current // iterator position. diff --git a/chromium/dbus/message_unittest.cc b/chromium/dbus/message_unittest.cc index a58b36b2dc0..d0acdc313aa 100644 --- a/chromium/dbus/message_unittest.cc +++ b/chromium/dbus/message_unittest.cc @@ -124,35 +124,26 @@ TEST(MessageTest, AppendAndPopFileDescriptor) { MessageWriter writer(message.get()); // Append stdout. - FileDescriptor temp(1); - // Descriptor should not be valid until checked. - ASSERT_FALSE(temp.is_valid()); - // NB: thread IO requirements not relevant for unit tests. - temp.CheckValidity(); - ASSERT_TRUE(temp.is_valid()); - writer.AppendFileDescriptor(temp); + const int fd_in = 1; + writer.AppendFileDescriptor(fd_in); - FileDescriptor fd_value; + base::ScopedFD fd_out; MessageReader reader(message.get()); ASSERT_TRUE(reader.HasMoreData()); ASSERT_EQ(Message::UNIX_FD, reader.GetDataType()); ASSERT_EQ("h", reader.GetDataSignature()); - ASSERT_TRUE(reader.PopFileDescriptor(&fd_value)); + ASSERT_TRUE(reader.PopFileDescriptor(&fd_out)); ASSERT_FALSE(reader.HasMoreData()); - // Descriptor is not valid until explicitly checked. - ASSERT_FALSE(fd_value.is_valid()); - fd_value.CheckValidity(); - ASSERT_TRUE(fd_value.is_valid()); // Stdout should be returned but we cannot check the descriptor // value because stdout will be dup'd. Instead check st_rdev // which should be identical. struct stat sb_stdout; - int status_stdout = HANDLE_EINTR(fstat(1, &sb_stdout)); + int status_stdout = HANDLE_EINTR(fstat(fd_in, &sb_stdout)); ASSERT_GE(status_stdout, 0); struct stat sb_fd; - int status_fd = HANDLE_EINTR(fstat(fd_value.value(), &sb_fd)); + int status_fd = HANDLE_EINTR(fstat(fd_out.get(), &sb_fd)); ASSERT_GE(status_fd, 0); EXPECT_EQ(sb_stdout.st_rdev, sb_fd.st_rdev); } diff --git a/chromium/dbus/mock_object_manager.h b/chromium/dbus/mock_object_manager.h index e4c76ba7114..2318e497ea0 100644 --- a/chromium/dbus/mock_object_manager.h +++ b/chromium/dbus/mock_object_manager.h @@ -31,7 +31,6 @@ class MockObjectManager : public ObjectManager { MOCK_METHOD1(GetObjectProxy, ObjectProxy*(const ObjectPath&)); MOCK_METHOD2(GetProperties, PropertySet*(const ObjectPath&, const std::string&)); - MOCK_METHOD0(GetManagedObjects, void()); protected: virtual ~MockObjectManager(); diff --git a/chromium/dbus/mock_object_proxy.h b/chromium/dbus/mock_object_proxy.h index f27f6f6acce..17d2a9f0f4e 100644 --- a/chromium/dbus/mock_object_proxy.h +++ b/chromium/dbus/mock_object_proxy.h @@ -56,6 +56,10 @@ class MockObjectProxy : public ObjectProxy { const std::string& signal_name, SignalCallback signal_callback, OnConnectedCallback on_connected_callback)); + MOCK_METHOD1(SetNameOwnerChangedCallback, + void(NameOwnerChangedCallback callback)); + MOCK_METHOD1(WaitForServiceToBeAvailable, + void(WaitForServiceToBeAvailableCallback callback)); MOCK_METHOD0(Detach, void()); protected: diff --git a/chromium/dbus/mock_unittest.cc b/chromium/dbus/mock_unittest.cc index ed78e2cb4eb..15bdf2759ad 100644 --- a/chromium/dbus/mock_unittest.cc +++ b/chromium/dbus/mock_unittest.cc @@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "dbus/message.h" #include "dbus/mock_bus.h" #include "dbus/mock_exported_object.h" @@ -121,11 +122,10 @@ class MockTest : public testing::Test { int timeout_ms, ObjectProxy::ResponseCallback response_callback) { Response* response = CreateMockProxyResponse(method_call, timeout_ms); - message_loop_.PostTask(FROM_HERE, - base::Bind(&MockTest::RunResponseCallback, - base::Unretained(this), - response_callback, - response)); + message_loop_.task_runner()->PostTask( + FROM_HERE, + base::Bind(&MockTest::RunResponseCallback, base::Unretained(this), + response_callback, response)); } // Runs the given response callback with the given response. diff --git a/chromium/dbus/object_manager.cc b/chromium/dbus/object_manager.cc index 56143c758b4..3a39cd6fb64 100644 --- a/chromium/dbus/object_manager.cc +++ b/chromium/dbus/object_manager.cc @@ -167,35 +167,6 @@ void ObjectManager::CleanUp() { match_rule_.clear(); } -void ObjectManager::InitializeObjects() { - DCHECK(bus_); - DCHECK(object_proxy_); - DCHECK(setup_success_); - - // |object_proxy_| is no longer valid if the Bus was shut down before this - // call. Don't initiate any other action from the origin thread. - if (cleanup_called_) - return; - - object_proxy_->ConnectToSignal( - kObjectManagerInterface, - kObjectManagerInterfacesAdded, - base::Bind(&ObjectManager::InterfacesAddedReceived, - weak_ptr_factory_.GetWeakPtr()), - base::Bind(&ObjectManager::InterfacesAddedConnected, - weak_ptr_factory_.GetWeakPtr())); - - object_proxy_->ConnectToSignal( - kObjectManagerInterface, - kObjectManagerInterfacesRemoved, - base::Bind(&ObjectManager::InterfacesRemovedReceived, - weak_ptr_factory_.GetWeakPtr()), - base::Bind(&ObjectManager::InterfacesRemovedConnected, - weak_ptr_factory_.GetWeakPtr())); - - GetManagedObjects(); -} - bool ObjectManager::SetupMatchRuleAndFilter() { DCHECK(bus_); DCHECK(!setup_success_); @@ -235,10 +206,39 @@ bool ObjectManager::SetupMatchRuleAndFilter() { } void ObjectManager::OnSetupMatchRuleAndFilterComplete(bool success) { - LOG_IF(WARNING, !success) << service_name_ << " " << object_path_.value() - << ": Failed to set up match rule."; - if (success) - InitializeObjects(); + if (!success) { + LOG(WARNING) << service_name_ << " " << object_path_.value() + << ": Failed to set up match rule."; + return; + } + + DCHECK(bus_); + DCHECK(object_proxy_); + DCHECK(setup_success_); + + // |object_proxy_| is no longer valid if the Bus was shut down before this + // call. Don't initiate any other action from the origin thread. + if (cleanup_called_) + return; + + object_proxy_->ConnectToSignal( + kObjectManagerInterface, + kObjectManagerInterfacesAdded, + base::Bind(&ObjectManager::InterfacesAddedReceived, + weak_ptr_factory_.GetWeakPtr()), + base::Bind(&ObjectManager::InterfacesAddedConnected, + weak_ptr_factory_.GetWeakPtr())); + + object_proxy_->ConnectToSignal( + kObjectManagerInterface, + kObjectManagerInterfacesRemoved, + base::Bind(&ObjectManager::InterfacesRemovedReceived, + weak_ptr_factory_.GetWeakPtr()), + base::Bind(&ObjectManager::InterfacesRemovedConnected, + weak_ptr_factory_.GetWeakPtr())); + + if (!service_name_owner_.empty()) + GetManagedObjects(); } // static diff --git a/chromium/dbus/object_manager.h b/chromium/dbus/object_manager.h index 266b53eb9a0..842a1378a26 100644 --- a/chromium/dbus/object_manager.h +++ b/chromium/dbus/object_manager.h @@ -71,8 +71,9 @@ // object_manager_->UnregisterInterface(kInterface); // } // -// The D-Bus thread manager takes care of issuing the necessary call to -// GetManagedObjects() after the implementation classes have been set up. +// This class calls GetManagedObjects() asynchronously after the remote service +// becomes available and additionally refreshes managed objects after the +// service stops or restarts. // // The object manager interface class has one abstract method that must be // implemented by the class to create Properties structures on demand. As well @@ -238,17 +239,14 @@ public: private: friend class base::RefCountedThreadSafe<ObjectManager>; - // Connects the InterfacesAdded and InterfacesRemoved signals and calls - // GetManagedObjects. Called from OnSetupMatchRuleAndFilterComplete. - void InitializeObjects(); - // Called from the constructor to add a match rule for PropertiesChanged - // signals on the DBus thread and set up a corresponding filter function. + // signals on the D-Bus thread and set up a corresponding filter function. bool SetupMatchRuleAndFilter(); // Called on the origin thread once the match rule and filter have been set - // up. |success| is false, if an error occurred during set up; it's true - // otherwise. + // up. Connects the InterfacesAdded and InterfacesRemoved signals and + // refreshes objects if the service is available. |success| is false if an + // error occurred during setup and true otherwise. void OnSetupMatchRuleAndFilterComplete(bool success); // Called by dbus:: when a message is received. This is used to filter diff --git a/chromium/dbus/object_manager_unittest.cc b/chromium/dbus/object_manager_unittest.cc index ae03776a51d..d28368b35b0 100644 --- a/chromium/dbus/object_manager_unittest.cc +++ b/chromium/dbus/object_manager_unittest.cc @@ -13,6 +13,7 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "dbus/bus.h" @@ -404,10 +405,9 @@ TEST_F(ObjectManagerTest, PropertiesChangedAsObjectsReceived) { // after setting up the match rule for PropertiesChanged. We should process // the PropertiesChanged event right after that. If we don't receive it within // 2 seconds, then fail the test. - message_loop_.PostDelayedTask( - FROM_HERE, - base::Bind(&ObjectManagerTest::PropertiesChangedTestTimeout, - base::Unretained(this)), + message_loop_.task_runner()->PostDelayedTask( + FROM_HERE, base::Bind(&ObjectManagerTest::PropertiesChangedTestTimeout, + base::Unretained(this)), base::TimeDelta::FromSeconds(2)); while (last_name_value_ != "ChangedTestServiceName" && !timeout_expired_) { diff --git a/chromium/dbus/object_proxy.h b/chromium/dbus/object_proxy.h index 033e88608a0..5de390461e6 100644 --- a/chromium/dbus/object_proxy.h +++ b/chromium/dbus/object_proxy.h @@ -137,10 +137,10 @@ class CHROME_DBUS_EXPORT ObjectProxy // from the method (i.e. calling a method that does not return a value), // EmptyResponseCallback() can be passed to the |callback| parameter. // - // If the method call is successful, a pointer to Response object will - // be passed to the callback. If unsuccessful, the error callback will be - // called and a pointer to ErrorResponse object will be passed to the error - // callback if available, otherwise NULL will be passed. + // If the method call is successful, |callback| will be invoked with a + // Response object. If unsuccessful, |error_callback| will be invoked with an + // ErrorResponse object (if the remote object returned an error) or nullptr + // (if a response was not received at all). // // Must be called in the origin thread. virtual void CallMethodWithErrorCallback(MethodCall* method_call, @@ -174,7 +174,11 @@ class CHROME_DBUS_EXPORT ObjectProxy // represented by |service_name_|. virtual void SetNameOwnerChangedCallback(NameOwnerChangedCallback callback); - // Runs the callback as soon as the service becomes available. + // Registers |callback| to run when the service becomes available. If the + // service is already available, or if connecting to the name-owner-changed + // signal fails, |callback| will be run once asynchronously. Otherwise, + // |callback| will be run once in the future after the service becomes + // available. virtual void WaitForServiceToBeAvailable( WaitForServiceToBeAvailableCallback callback); diff --git a/chromium/dbus/object_proxy_unittest.cc b/chromium/dbus/object_proxy_unittest.cc index cc79f849cdc..189ef9074a0 100644 --- a/chromium/dbus/object_proxy_unittest.cc +++ b/chromium/dbus/object_proxy_unittest.cc @@ -29,44 +29,110 @@ class ObjectProxyTest : public testing::Test { }; // Used as a WaitForServiceToBeAvailableCallback. -void OnServiceIsAvailable(std::unique_ptr<base::RunLoop>* run_loop, - bool service_is_available) { - EXPECT_TRUE(service_is_available); - ASSERT_TRUE(*run_loop); - (*run_loop)->Quit(); +void OnServiceIsAvailable(bool* dest_service_is_available, + int* num_calls, + bool src_service_is_available) { + *dest_service_is_available = src_service_is_available; + (*num_calls)++; +} + +// Used as a callback for TestService::RequestOwnership(). +void OnOwnershipRequestDone(bool success) { + ASSERT_TRUE(success); } -TEST_F(ObjectProxyTest, WaitForServiceToBeAvailable) { - std::unique_ptr<base::RunLoop> run_loop; +// Used as a callback for TestService::ReleaseOwnership(). +void OnOwnershipReleased() {} +TEST_F(ObjectProxyTest, WaitForServiceToBeAvailableRunOnce) { TestService::Options options; TestService test_service(options); - - // Callback is not yet called because the service is not available. ObjectProxy* object_proxy = bus_->GetObjectProxy( test_service.service_name(), ObjectPath("/org/chromium/TestObject")); + + // The callback is not yet called because the service is not available. + int num_calls = 0; + bool service_is_available = false; object_proxy->WaitForServiceToBeAvailable( - base::Bind(&OnServiceIsAvailable, &run_loop)); + base::Bind(&OnServiceIsAvailable, &service_is_available, &num_calls)); base::RunLoop().RunUntilIdle(); + EXPECT_EQ(0, num_calls); - // Start the service. + // Start the service. The callback should be called asynchronously. ASSERT_TRUE(test_service.StartService()); ASSERT_TRUE(test_service.WaitUntilServiceIsStarted()); ASSERT_TRUE(test_service.has_ownership()); + num_calls = 0; + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(1, num_calls); + EXPECT_TRUE(service_is_available); - // Callback is called beacuse the service became available. - run_loop.reset(new base::RunLoop); - run_loop->Run(); + // Release the service's ownership of its name. The callback should not be + // invoked again. + test_service.ReleaseOwnership(base::Bind(&OnOwnershipReleased)); + num_calls = 0; + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(0, num_calls); - // Callback is called because the service is already available. - run_loop.reset(new base::RunLoop); + // Take ownership of the name and check that the callback is not called. + test_service.RequestOwnership(base::Bind(&OnOwnershipRequestDone)); + num_calls = 0; + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(0, num_calls); +} + +TEST_F(ObjectProxyTest, WaitForServiceToBeAvailableAlreadyRunning) { + TestService::Options options; + TestService test_service(options); + ObjectProxy* object_proxy = bus_->GetObjectProxy( + test_service.service_name(), ObjectPath("/org/chromium/TestObject")); + + ASSERT_TRUE(test_service.StartService()); + ASSERT_TRUE(test_service.WaitUntilServiceIsStarted()); + ASSERT_TRUE(test_service.has_ownership()); + + // Since the service is already running, the callback should be invoked + // immediately (but asynchronously, rather than the callback being invoked + // directly within WaitForServiceToBeAvailable()). + int num_calls = 0; + bool service_is_available = false; + object_proxy->WaitForServiceToBeAvailable( + base::Bind(&OnServiceIsAvailable, &service_is_available, &num_calls)); + EXPECT_EQ(0, num_calls); + + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(1, num_calls); + EXPECT_TRUE(service_is_available); +} + +TEST_F(ObjectProxyTest, WaitForServiceToBeAvailableMultipleCallbacks) { + TestService::Options options; + TestService test_service(options); + ObjectProxy* object_proxy = bus_->GetObjectProxy( + test_service.service_name(), ObjectPath("/org/chromium/TestObject")); + + // Register two callbacks. + int num_calls_1 = 0, num_calls_2 = 0; + bool service_is_available_1 = false, service_is_available_2 = false; object_proxy->WaitForServiceToBeAvailable( - base::Bind(&OnServiceIsAvailable, &run_loop)); - run_loop->Run(); + base::Bind(&OnServiceIsAvailable, &service_is_available_1, &num_calls_1)); + object_proxy->WaitForServiceToBeAvailable( + base::Bind(&OnServiceIsAvailable, &service_is_available_2, &num_calls_2)); + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(0, num_calls_1); + EXPECT_EQ(0, num_calls_2); - // Shut down the service. - test_service.ShutdownAndBlock(); - test_service.Stop(); + // Start the service and confirm that both callbacks are invoked. + ASSERT_TRUE(test_service.StartService()); + ASSERT_TRUE(test_service.WaitUntilServiceIsStarted()); + ASSERT_TRUE(test_service.has_ownership()); + num_calls_1 = 0; + num_calls_2 = 0; + base::RunLoop().RunUntilIdle(); + EXPECT_EQ(1, num_calls_1); + EXPECT_EQ(1, num_calls_2); + EXPECT_TRUE(service_is_available_1); + EXPECT_TRUE(service_is_available_2); } } // namespace diff --git a/chromium/dbus/property.cc b/chromium/dbus/property.cc index faca4a0a1d7..0ac65ef6991 100644 --- a/chromium/dbus/property.cc +++ b/chromium/dbus/property.cc @@ -6,6 +6,8 @@ #include <stddef.h> +#include <memory> + #include "base/bind.h" #include "base/logging.h" @@ -659,6 +661,70 @@ void Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: writer->CloseContainer(&variant_writer); } +// +// Property<std::map<std::string, std::vector<uint8_t>>> +// specialization. +// + +template <> +bool Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: + PopValueFromReader(MessageReader* reader) { + MessageReader variant_reader(nullptr); + MessageReader dict_reader(nullptr); + if (!reader->PopVariant(&variant_reader) || + !variant_reader.PopArray(&dict_reader)) + return false; + + value_.clear(); + while (dict_reader.HasMoreData()) { + MessageReader entry_reader(nullptr); + if (!dict_reader.PopDictEntry(&entry_reader)) + return false; + + std::string key; + MessageReader value_varient_reader(nullptr); + if (!entry_reader.PopString(&key) || + !entry_reader.PopVariant(&value_varient_reader)) + return false; + + const uint8_t* bytes = nullptr; + size_t length = 0; + if (!value_varient_reader.PopArrayOfBytes(&bytes, &length)) + return false; + + value_[key].assign(bytes, bytes + length); + } + return true; +} + +template <> +void Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: + AppendSetValueToWriter(MessageWriter* writer) { + MessageWriter variant_writer(nullptr); + MessageWriter dict_writer(nullptr); + + writer->OpenVariant("a{sv}", &variant_writer); + variant_writer.OpenArray("{sv}", &dict_writer); + + for (const auto& pair : set_value_) { + MessageWriter entry_writer(nullptr); + dict_writer.OpenDictEntry(&entry_writer); + + entry_writer.AppendString(pair.first); + + MessageWriter value_varient_writer(nullptr); + entry_writer.OpenVariant("ay", &value_varient_writer); + value_varient_writer.AppendArrayOfBytes(pair.second.data(), + pair.second.size()); + entry_writer.CloseContainer(&value_varient_writer); + + dict_writer.CloseContainer(&entry_writer); + } + + variant_writer.CloseContainer(&dict_writer); + writer->CloseContainer(&variant_writer); +} + template class Property<uint8_t>; template class Property<bool>; template class Property<int16_t>; @@ -675,5 +741,6 @@ template class Property<std::vector<ObjectPath> >; template class Property<std::vector<uint8_t>>; template class Property<std::map<std::string, std::string>>; template class Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; +template class Property<std::unordered_map<std::string, std::vector<uint8_t>>>; } // namespace dbus diff --git a/chromium/dbus/property.h b/chromium/dbus/property.h index efbad226a69..616a5951483 100644 --- a/chromium/dbus/property.h +++ b/chromium/dbus/property.h @@ -9,6 +9,7 @@ #include <map> #include <string> +#include <unordered_map> #include <utility> #include <vector> @@ -610,6 +611,17 @@ Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: extern template class CHROME_DBUS_EXPORT Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; +template <> +CHROME_DBUS_EXPORT bool +Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: + PopValueFromReader(MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void +Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: + AppendSetValueToWriter(MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT + Property<std::unordered_map<std::string, std::vector<uint8_t>>>; + #pragma GCC diagnostic pop } // namespace dbus diff --git a/chromium/dbus/property_unittest.cc b/chromium/dbus/property_unittest.cc index 5922554f23d..8208581c4e0 100644 --- a/chromium/dbus/property_unittest.cc +++ b/chromium/dbus/property_unittest.cc @@ -7,6 +7,7 @@ #include <stddef.h> #include <stdint.h> +#include <memory> #include <string> #include <vector> @@ -431,4 +432,59 @@ TEST(PropertyTestStatic, SerializeNetAddressArray) { EXPECT_EQ(test_list, ip_list.value()); } +TEST(PropertyTestStatic, ReadWriteStringToByteVectorMap) { + std::unique_ptr<Response> message(Response::CreateEmpty()); + MessageWriter writer(message.get()); + MessageWriter variant_writer(nullptr); + MessageWriter dict_writer(nullptr); + + writer.OpenVariant("a{sv}", &variant_writer); + variant_writer.OpenArray("{sv}", &dict_writer); + + const char* keys[] = {"One", "Two", "Three", "Four"}; + const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}}; + for (unsigned i = 0; i < arraysize(keys); ++i) { + MessageWriter entry_writer(nullptr); + dict_writer.OpenDictEntry(&entry_writer); + + entry_writer.AppendString(keys[i]); + + MessageWriter value_varient_writer(nullptr); + entry_writer.OpenVariant("ay", &value_varient_writer); + value_varient_writer.AppendArrayOfBytes(values[i].data(), values[i].size()); + entry_writer.CloseContainer(&value_varient_writer); + + dict_writer.CloseContainer(&entry_writer); + } + + variant_writer.CloseContainer(&dict_writer); + writer.CloseContainer(&variant_writer); + + MessageReader reader(message.get()); + Property<std::unordered_map<std::string, std::vector<uint8_t>>> test_property; + EXPECT_TRUE(test_property.PopValueFromReader(&reader)); + + ASSERT_EQ(arraysize(keys), test_property.value().size()); + for (unsigned i = 0; i < arraysize(keys); ++i) + EXPECT_EQ(values[i], test_property.value().at(keys[i])); +} + +TEST(PropertyTestStatic, SerializeStringToByteVectorMap) { + std::unordered_map<std::string, std::vector<uint8_t>> test_map; + test_map["Hi"] = {1, 2, 3}; + test_map["Map"] = {0xab, 0xcd}; + test_map["Random"] = {0x0}; + + std::unique_ptr<Response> message(Response::CreateEmpty()); + MessageWriter writer(message.get()); + + Property<std::unordered_map<std::string, std::vector<uint8_t>>> test_property; + test_property.ReplaceSetValueForTesting(test_map); + test_property.AppendSetValueToWriter(&writer); + + MessageReader reader(message.get()); + EXPECT_TRUE(test_property.PopValueFromReader(&reader)); + EXPECT_EQ(test_map, test_property.value()); +} + } // namespace dbus diff --git a/chromium/dbus/signal_sender_verification_unittest.cc b/chromium/dbus/signal_sender_verification_unittest.cc index 3b2cf6f5073..320718dcc78 100644 --- a/chromium/dbus/signal_sender_verification_unittest.cc +++ b/chromium/dbus/signal_sender_verification_unittest.cc @@ -10,6 +10,7 @@ #include "base/metrics/histogram_samples.h" #include "base/metrics/statistics_recorder.h" #include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "base/threading/thread_restrictions.h" @@ -117,7 +118,7 @@ class SignalSenderVerificationTest : public testing::Test { void OnOwnership(bool expected, bool success) { ASSERT_EQ(expected, success); // PostTask to quit the MessageLoop as this is called from D-Bus thread. - message_loop_.PostTask( + message_loop_.task_runner()->PostTask( FROM_HERE, base::Bind(&SignalSenderVerificationTest::OnOwnershipInternal, base::Unretained(this))); diff --git a/chromium/dbus/test_server.cc b/chromium/dbus/test_server.cc index 1b630648b70..54bb0c00764 100644 --- a/chromium/dbus/test_server.cc +++ b/chromium/dbus/test_server.cc @@ -13,16 +13,15 @@ int main(int argc, char** argv) { base::CommandLine::Init(argc, argv); TestTimeouts::Initialize(); - base::Thread* dbus_thread = new base::Thread("D-Bus Thread"); + base::Thread dbus_thread("D-Bus Thread"); base::Thread::Options thread_options; thread_options.message_loop_type = base::MessageLoop::TYPE_IO; - CHECK(dbus_thread->StartWithOptions(thread_options)); + CHECK(dbus_thread.StartWithOptions(thread_options)); dbus::TestService::Options options; - options.dbus_task_runner = dbus_thread->task_runner(); + options.dbus_task_runner = dbus_thread.task_runner(); dbus::TestService* test_service = new dbus::TestService(options); CHECK(test_service->StartService()); CHECK(test_service->WaitUntilServiceIsStarted()); CHECK(test_service->HasDBusThread()); - base::PlatformThread::Join(dbus_thread->thread_handle()); } diff --git a/chromium/dbus/test_service.cc b/chromium/dbus/test_service.cc index 6445f6a6467..209b41dfe62 100644 --- a/chromium/dbus/test_service.cc +++ b/chromium/dbus/test_service.cc @@ -11,6 +11,8 @@ #include "base/bind.h" #include "base/guid.h" +#include "base/run_loop.h" +#include "base/single_thread_task_runner.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "dbus/bus.h" @@ -74,10 +76,9 @@ bool TestService::WaitUntilServiceIsStarted() { } void TestService::ShutdownAndBlock() { - message_loop()->PostTask( - FROM_HERE, - base::Bind(&TestService::ShutdownAndBlockInternal, - base::Unretained(this))); + message_loop()->task_runner()->PostTask( + FROM_HERE, base::Bind(&TestService::ShutdownAndBlockInternal, + base::Unretained(this))); } bool TestService::HasDBusThread() { @@ -92,19 +93,15 @@ void TestService::ShutdownAndBlockInternal() { } void TestService::SendTestSignal(const std::string& message) { - message_loop()->PostTask( - FROM_HERE, - base::Bind(&TestService::SendTestSignalInternal, - base::Unretained(this), - message)); + message_loop()->task_runner()->PostTask( + FROM_HERE, base::Bind(&TestService::SendTestSignalInternal, + base::Unretained(this), message)); } void TestService::SendTestSignalFromRoot(const std::string& message) { - message_loop()->PostTask( - FROM_HERE, - base::Bind(&TestService::SendTestSignalFromRootInternal, - base::Unretained(this), - message)); + message_loop()->task_runner()->PostTask( + FROM_HERE, base::Bind(&TestService::SendTestSignalFromRootInternal, + base::Unretained(this), message)); } void TestService::SendTestSignalInternal(const std::string& message) { @@ -131,11 +128,9 @@ void TestService::SendTestSignalFromRootInternal(const std::string& message) { } void TestService::RequestOwnership(base::Callback<void(bool)> callback) { - message_loop()->PostTask( - FROM_HERE, - base::Bind(&TestService::RequestOwnershipInternal, - base::Unretained(this), - callback)); + message_loop()->task_runner()->PostTask( + FROM_HERE, base::Bind(&TestService::RequestOwnershipInternal, + base::Unretained(this), callback)); } void TestService::RequestOwnershipInternal( @@ -202,7 +197,7 @@ void TestService::OnExported(const std::string& interface_name, } } -void TestService::Run(base::MessageLoop* message_loop) { +void TestService::Run(base::RunLoop* run_loop) { Bus::Options bus_options; bus_options.bus_type = Bus::SESSION; bus_options.connection_type = Bus::PRIVATE; @@ -302,7 +297,7 @@ void TestService::Run(base::MessageLoop* message_loop) { if (num_methods != kNumMethodsToExport) { LOG(ERROR) << "The number of methods does not match"; } - message_loop->Run(); + run_loop->Run(); } void TestService::Echo(MethodCall* method_call, @@ -329,12 +324,10 @@ void TestService::SlowEcho(MethodCall* method_call, void TestService::AsyncEcho(MethodCall* method_call, ExportedObject::ResponseSender response_sender) { // Schedule a call to Echo() to send an asynchronous response after we return. - message_loop()->PostDelayedTask(FROM_HERE, - base::Bind(&TestService::Echo, - base::Unretained(this), - method_call, - response_sender), - TestTimeouts::tiny_timeout()); + message_loop()->task_runner()->PostDelayedTask( + FROM_HERE, base::Bind(&TestService::Echo, base::Unretained(this), + method_call, response_sender), + TestTimeouts::tiny_timeout()); } void TestService::BrokenMethod(MethodCall* method_call, @@ -647,11 +640,9 @@ void TestService::AddPropertiesToWriter(MessageWriter* writer) { } void TestService::AddObject(const ObjectPath& object_path) { - message_loop()->PostTask( - FROM_HERE, - base::Bind(&TestService::AddObjectInternal, - base::Unretained(this), - object_path)); + message_loop()->task_runner()->PostTask( + FROM_HERE, base::Bind(&TestService::AddObjectInternal, + base::Unretained(this), object_path)); } void TestService::AddObjectInternal(const ObjectPath& object_path) { @@ -673,10 +664,9 @@ void TestService::AddObjectInternal(const ObjectPath& object_path) { } void TestService::RemoveObject(const ObjectPath& object_path) { - message_loop()->PostTask(FROM_HERE, - base::Bind(&TestService::RemoveObjectInternal, - base::Unretained(this), - object_path)); + message_loop()->task_runner()->PostTask( + FROM_HERE, base::Bind(&TestService::RemoveObjectInternal, + base::Unretained(this), object_path)); } void TestService::RemoveObjectInternal(const ObjectPath& object_path) { @@ -693,11 +683,9 @@ void TestService::RemoveObjectInternal(const ObjectPath& object_path) { } void TestService::SendPropertyChangedSignal(const std::string& name) { - message_loop()->PostTask( - FROM_HERE, - base::Bind(&TestService::SendPropertyChangedSignalInternal, - base::Unretained(this), - name)); + message_loop()->task_runner()->PostTask( + FROM_HERE, base::Bind(&TestService::SendPropertyChangedSignalInternal, + base::Unretained(this), name)); } void TestService::SendPropertyChangedSignalInternal(const std::string& name) { @@ -724,7 +712,7 @@ void TestService::SendPropertyChangedSignalInternal(const std::string& name) { } void TestService::SendPropertyInvalidatedSignal() { - message_loop()->PostTask( + message_loop()->task_runner()->PostTask( FROM_HERE, base::Bind(&TestService::SendPropertyInvalidatedSignalInternal, base::Unretained(this))); } diff --git a/chromium/dbus/test_service.h b/chromium/dbus/test_service.h index e2ed480e9d3..b151b9b5471 100644 --- a/chromium/dbus/test_service.h +++ b/chromium/dbus/test_service.h @@ -112,7 +112,7 @@ class TestService : public base::Thread { bool success); // base::Thread override. - void Run(base::MessageLoop* message_loop) override; + void Run(base::RunLoop* run_loop) override; // // Exported methods. |