| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_DBUS_NFC_PROPERTY_SET_H_ | |
| 6 #define CHROMEOS_DBUS_NFC_PROPERTY_SET_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "dbus/message.h" | |
| 13 #include "dbus/object_proxy.h" | |
| 14 #include "dbus/property.h" | |
| 15 | |
| 16 namespace chromeos { | |
| 17 | |
| 18 // neard doesn't use the standard D-Bus interfaces for property access and | |
| 19 // instead defines property accessor methods in each D-Bus interface. This | |
| 20 // class customizes dbus::PropertySet to generate the correct method call to | |
| 21 // get all properties, connect to the correct signal and parse it correctly. | |
| 22 class NfcPropertySet : public dbus::PropertySet { | |
| 23 public: | |
| 24 NfcPropertySet(dbus::ObjectProxy* object_proxy, | |
| 25 const std::string& interface, | |
| 26 const PropertyChangedCallback& callback); | |
| 27 | |
| 28 // Destructor; we don't hold on to any references or memory that needs | |
| 29 // explicit clean-up, but clang thinks we might. | |
| 30 ~NfcPropertySet() override; | |
| 31 | |
| 32 // Caches |callback| so that it will be invoked after a call to GetAll() | |
| 33 // has successfully received all existing properties from the remote object. | |
| 34 void SetAllPropertiesReceivedCallback(const base::Closure& callback); | |
| 35 | |
| 36 // dbus::PropertySet overrides | |
| 37 void ConnectSignals() override; | |
| 38 void Get(dbus::PropertyBase* property, GetCallback callback) override; | |
| 39 void GetAll() override; | |
| 40 void OnGetAll(dbus::Response* response) override; | |
| 41 void Set(dbus::PropertyBase* property, SetCallback callback) override; | |
| 42 void ChangedReceived(dbus::Signal* signal) override; | |
| 43 | |
| 44 protected: | |
| 45 const base::Closure& on_get_all_callback() { return on_get_all_callback_; } | |
| 46 | |
| 47 private: | |
| 48 void OnGetAllError(dbus::ErrorResponse* response); | |
| 49 | |
| 50 // Optional callback used to notify clients when all properties were received | |
| 51 // after a call to GetAll. | |
| 52 base::Closure on_get_all_callback_; | |
| 53 | |
| 54 base::WeakPtrFactory<NfcPropertySet> weak_ptr_factory_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(NfcPropertySet); | |
| 57 }; | |
| 58 | |
| 59 } // namespace chromeos | |
| 60 | |
| 61 #endif // CHROMEOS_DBUS_NFC_PROPERTY_SET_H_ | |
| OLD | NEW |