Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1882)

Unified Diff: dbus/object_manager.cc

Issue 2239123002: dbus: Make Bus::GetManagedObjects skip unavailable services. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove Bus::GetManagedObjects and BluezDBusManager's call to it Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/object_manager.h ('k') | device/bluetooth/dbus/bluez_dbus_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/object_manager.cc
diff --git a/dbus/object_manager.cc b/dbus/object_manager.cc
index 56143c758b4bb9b40f72e0f55075e0caa1f77ddc..1e165af141c07496805ae65de0d9314a8bd880e7 100644
--- a/dbus/object_manager.cc
+++ b/dbus/object_manager.cc
@@ -37,12 +37,17 @@ ObjectManager::ObjectManager(Bus* bus,
object_path_(object_path),
setup_success_(false),
cleanup_called_(false),
+ service_initially_available_(false),
+ signals_are_connected_(false),
weak_ptr_factory_(this) {
DVLOG(1) << "Creating ObjectManager for " << service_name_
<< " " << object_path_.value();
DCHECK(bus_);
bus_->AssertOnOriginThread();
object_proxy_ = bus_->GetObjectProxy(service_name_, object_path_);
+ object_proxy_->WaitForServiceToBeAvailable(
+ base::Bind(&ObjectManager::OnServiceInitiallyAvailable,
+ weak_ptr_factory_.GetWeakPtr()));
object_proxy_->SetNameOwnerChangedCallback(
base::Bind(&ObjectManager::NameOwnerChanged,
weak_ptr_factory_.GetWeakPtr()));
@@ -167,6 +172,18 @@ void ObjectManager::CleanUp() {
match_rule_.clear();
}
+void ObjectManager::OnServiceInitiallyAvailable(bool service_is_available) {
+ if (!service_is_available) {
+ LOG(WARNING) << service_name_ << " " << object_path_.value()
+ << ": Failed to wait for service to become available";
+ return;
+ }
+
+ service_initially_available_ = true;
+ if (signals_are_connected_)
+ GetManagedObjects();
+}
+
void ObjectManager::InitializeObjects() {
DCHECK(bus_);
DCHECK(object_proxy_);
@@ -193,7 +210,9 @@ void ObjectManager::InitializeObjects() {
base::Bind(&ObjectManager::InterfacesRemovedConnected,
weak_ptr_factory_.GetWeakPtr()));
- GetManagedObjects();
+ signals_are_connected_ = true;
+ if (service_initially_available_)
+ GetManagedObjects();
hashimoto 2016/09/01 03:26:07 How about calling WaitForServiceToBeAvailable() he
Daniel Erat 2016/09/01 04:15:55 thanks, that seems like a good suggestion! and no,
}
bool ObjectManager::SetupMatchRuleAndFilter() {
« no previous file with comments | « dbus/object_manager.h ('k') | device/bluetooth/dbus/bluez_dbus_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698