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

Side by Side Diff: dbus/object_manager.h

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, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DBUS_OBJECT_MANAGER_H_ 5 #ifndef DBUS_OBJECT_MANAGER_H_
6 #define DBUS_OBJECT_MANAGER_H_ 6 #define DBUS_OBJECT_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // : bus_(bus), 64 // : bus_(bus),
65 // weak_ptr_factory_(this) { 65 // weak_ptr_factory_(this) {
66 // object_manager_ = bus_->GetObjectManager(kServiceName, kManagerPath); 66 // object_manager_ = bus_->GetObjectManager(kServiceName, kManagerPath);
67 // object_manager_->RegisterInterface(kInterface, this); 67 // object_manager_->RegisterInterface(kInterface, this);
68 // } 68 // }
69 // 69 //
70 // virtual ExampleClient::~ExampleClient() { 70 // virtual ExampleClient::~ExampleClient() {
71 // object_manager_->UnregisterInterface(kInterface); 71 // object_manager_->UnregisterInterface(kInterface);
72 // } 72 // }
73 // 73 //
74 // The D-Bus thread manager takes care of issuing the necessary call to 74 // This class calls GetManagedObjects() asynchronously after the remote service
75 // GetManagedObjects() after the implementation classes have been set up. 75 // becomes available and additionally refreshes managed objects after the
76 // service stops or restarts.
76 // 77 //
77 // The object manager interface class has one abstract method that must be 78 // The object manager interface class has one abstract method that must be
78 // implemented by the class to create Properties structures on demand. As well 79 // implemented by the class to create Properties structures on demand. As well
79 // as implementing this, you will want to implement a public GetProperties() 80 // as implementing this, you will want to implement a public GetProperties()
80 // method. 81 // method.
81 // 82 //
82 // Example: 83 // Example:
83 // dbus::PropertySet* CreateProperties(dbus::ObjectProxy* object_proxy, 84 // dbus::PropertySet* CreateProperties(dbus::ObjectProxy* object_proxy,
84 // const std::string& interface_name) 85 // const std::string& interface_name)
85 // override { 86 // override {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // 232 //
232 // BLOCKING CALL. 233 // BLOCKING CALL.
233 void CleanUp(); 234 void CleanUp();
234 235
235 protected: 236 protected:
236 virtual ~ObjectManager(); 237 virtual ~ObjectManager();
237 238
238 private: 239 private:
239 friend class base::RefCountedThreadSafe<ObjectManager>; 240 friend class base::RefCountedThreadSafe<ObjectManager>;
240 241
242 // Callback for ObjectProxy::WaitForServiceToBeAvailable() that refreshes
243 // objects when the service becomes initially available if
244 // |signals_are_connected_| is already true.
245 void OnServiceInitiallyAvailable(bool service_is_available);
246
241 // Connects the InterfacesAdded and InterfacesRemoved signals and calls 247 // Connects the InterfacesAdded and InterfacesRemoved signals and calls
242 // GetManagedObjects. Called from OnSetupMatchRuleAndFilterComplete. 248 // GetManagedObjects if |service_initially_available_| is already true. Called
249 // from OnSetupMatchRuleAndFilterComplete.
243 void InitializeObjects(); 250 void InitializeObjects();
244 251
245 // Called from the constructor to add a match rule for PropertiesChanged 252 // Called from the constructor to add a match rule for PropertiesChanged
246 // signals on the DBus thread and set up a corresponding filter function. 253 // signals on the DBus thread and set up a corresponding filter function.
247 bool SetupMatchRuleAndFilter(); 254 bool SetupMatchRuleAndFilter();
248 255
249 // Called on the origin thread once the match rule and filter have been set 256 // Called on the origin thread once the match rule and filter have been set
250 // up. |success| is false, if an error occurred during set up; it's true 257 // up. |success| is false, if an error occurred during set up; it's true
251 // otherwise. 258 // otherwise.
252 void OnSetupMatchRuleAndFilterComplete(bool success); 259 void OnSetupMatchRuleAndFilterComplete(bool success);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 326
320 Bus* bus_; 327 Bus* bus_;
321 std::string service_name_; 328 std::string service_name_;
322 std::string service_name_owner_; 329 std::string service_name_owner_;
323 std::string match_rule_; 330 std::string match_rule_;
324 ObjectPath object_path_; 331 ObjectPath object_path_;
325 ObjectProxy* object_proxy_; 332 ObjectProxy* object_proxy_;
326 bool setup_success_; 333 bool setup_success_;
327 bool cleanup_called_; 334 bool cleanup_called_;
328 335
336 // Set to true by OnServiceInitiallyAvailable() once the service becomes
337 // initially available.
338 bool service_initially_available_;
339
340 // Set to true by InitializeObjects() once signals are connected.
341 bool signals_are_connected_;
342
329 // Maps the name of an interface to the implementation class used for 343 // Maps the name of an interface to the implementation class used for
330 // instantiating PropertySet structures for that interface's properties. 344 // instantiating PropertySet structures for that interface's properties.
331 typedef std::map<std::string, Interface*> InterfaceMap; 345 typedef std::map<std::string, Interface*> InterfaceMap;
332 InterfaceMap interface_map_; 346 InterfaceMap interface_map_;
333 347
334 // Each managed object consists of a ObjectProxy used to make calls 348 // Each managed object consists of a ObjectProxy used to make calls
335 // against that object and a collection of D-Bus interface names and their 349 // against that object and a collection of D-Bus interface names and their
336 // associated PropertySet structures. 350 // associated PropertySet structures.
337 struct Object { 351 struct Object {
338 Object(); 352 Object();
(...skipping 16 matching lines...) Expand all
355 // Note: This should remain the last member so it'll be destroyed and 369 // Note: This should remain the last member so it'll be destroyed and
356 // invalidate its weak pointers before any other members are destroyed. 370 // invalidate its weak pointers before any other members are destroyed.
357 base::WeakPtrFactory<ObjectManager> weak_ptr_factory_; 371 base::WeakPtrFactory<ObjectManager> weak_ptr_factory_;
358 372
359 DISALLOW_COPY_AND_ASSIGN(ObjectManager); 373 DISALLOW_COPY_AND_ASSIGN(ObjectManager);
360 }; 374 };
361 375
362 } // namespace dbus 376 } // namespace dbus
363 377
364 #endif // DBUS_OBJECT_MANAGER_H_ 378 #endif // DBUS_OBJECT_MANAGER_H_
OLDNEW
« no previous file with comments | « dbus/mock_object_manager.h ('k') | dbus/object_manager.cc » ('j') | dbus/object_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698