OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
241 // Connects the InterfacesAdded and InterfacesRemoved signals and calls | |
242 // GetManagedObjects. Called from OnSetupMatchRuleAndFilterComplete. | |
243 void InitializeObjects(); | |
Daniel Erat
2016/09/01 17:06:25
i moved this into OnSetupMatchRuleAndFilterComplet
| |
244 | |
245 // Called from the constructor to add a match rule for PropertiesChanged | 242 // Called from the constructor to add a match rule for PropertiesChanged |
246 // signals on the DBus thread and set up a corresponding filter function. | 243 // signals on the DBus thread and set up a corresponding filter function. |
247 bool SetupMatchRuleAndFilter(); | 244 bool SetupMatchRuleAndFilter(); |
248 | 245 |
249 // Called on the origin thread once the match rule and filter have been set | 246 // 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 | 247 // up. Connects the InterfacesAdded and InterfacesRemoved signals and calls |
251 // otherwise. | 248 // ObjectProxy::WaitForServiceToBeAvailable to initially refresh objects. |
249 // |success| is false if an error occurred during setup and true otherwise. | |
252 void OnSetupMatchRuleAndFilterComplete(bool success); | 250 void OnSetupMatchRuleAndFilterComplete(bool success); |
253 | 251 |
252 // Callback for ObjectProxy::WaitForServiceToBeAvailable that refreshes | |
253 // objects when the service becomes initially available. Scheduled by | |
254 // OnSetupMatchRuleAndFilterComplete. | |
255 void OnServiceInitiallyAvailable(bool service_is_available); | |
256 | |
254 // Called by dbus:: when a message is received. This is used to filter | 257 // Called by dbus:: when a message is received. This is used to filter |
255 // PropertiesChanged signals from the correct sender and relay the event to | 258 // PropertiesChanged signals from the correct sender and relay the event to |
256 // the correct PropertySet. | 259 // the correct PropertySet. |
257 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, | 260 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, |
258 DBusMessage* raw_message, | 261 DBusMessage* raw_message, |
259 void* user_data); | 262 void* user_data); |
260 DBusHandlerResult HandleMessage(DBusConnection* connection, | 263 DBusHandlerResult HandleMessage(DBusConnection* connection, |
261 DBusMessage* raw_message); | 264 DBusMessage* raw_message); |
262 | 265 |
263 // Called when a PropertiesChanged signal is received from the sender. | 266 // Called when a PropertiesChanged signal is received from the sender. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 // Note: This should remain the last member so it'll be destroyed and | 358 // Note: This should remain the last member so it'll be destroyed and |
356 // invalidate its weak pointers before any other members are destroyed. | 359 // invalidate its weak pointers before any other members are destroyed. |
357 base::WeakPtrFactory<ObjectManager> weak_ptr_factory_; | 360 base::WeakPtrFactory<ObjectManager> weak_ptr_factory_; |
358 | 361 |
359 DISALLOW_COPY_AND_ASSIGN(ObjectManager); | 362 DISALLOW_COPY_AND_ASSIGN(ObjectManager); |
360 }; | 363 }; |
361 | 364 |
362 } // namespace dbus | 365 } // namespace dbus |
363 | 366 |
364 #endif // DBUS_OBJECT_MANAGER_H_ | 367 #endif // DBUS_OBJECT_MANAGER_H_ |
OLD | NEW |