xref: /aosp_15_r20/external/libchrome/dbus/property.h (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file.
4*635a8641SAndroid Build Coastguard Worker 
5*635a8641SAndroid Build Coastguard Worker #ifndef DBUS_PROPERTY_H_
6*635a8641SAndroid Build Coastguard Worker #define DBUS_PROPERTY_H_
7*635a8641SAndroid Build Coastguard Worker 
8*635a8641SAndroid Build Coastguard Worker #include <stdint.h>
9*635a8641SAndroid Build Coastguard Worker 
10*635a8641SAndroid Build Coastguard Worker #include <map>
11*635a8641SAndroid Build Coastguard Worker #include <string>
12*635a8641SAndroid Build Coastguard Worker #include <utility>
13*635a8641SAndroid Build Coastguard Worker #include <vector>
14*635a8641SAndroid Build Coastguard Worker 
15*635a8641SAndroid Build Coastguard Worker #include "base/bind.h"
16*635a8641SAndroid Build Coastguard Worker #include "base/callback.h"
17*635a8641SAndroid Build Coastguard Worker #include "base/macros.h"
18*635a8641SAndroid Build Coastguard Worker #include "dbus/dbus_export.h"
19*635a8641SAndroid Build Coastguard Worker #include "dbus/message.h"
20*635a8641SAndroid Build Coastguard Worker #include "dbus/object_proxy.h"
21*635a8641SAndroid Build Coastguard Worker 
22*635a8641SAndroid Build Coastguard Worker // D-Bus objects frequently provide sets of properties accessed via a
23*635a8641SAndroid Build Coastguard Worker // standard interface of method calls and signals to obtain the current value,
24*635a8641SAndroid Build Coastguard Worker // set a new value and be notified of changes to the value. Unfortunately this
25*635a8641SAndroid Build Coastguard Worker // interface makes heavy use of variants and dictionaries of variants. The
26*635a8641SAndroid Build Coastguard Worker // classes defined here make dealing with properties in a type-safe manner
27*635a8641SAndroid Build Coastguard Worker // possible.
28*635a8641SAndroid Build Coastguard Worker //
29*635a8641SAndroid Build Coastguard Worker // Client implementation classes should define a Properties structure, deriving
30*635a8641SAndroid Build Coastguard Worker // from the PropertySet class defined here. This structure should contain a
31*635a8641SAndroid Build Coastguard Worker // member for each property defined as an instance of the Property<> class,
32*635a8641SAndroid Build Coastguard Worker // specifying the type to the template. Finally the structure should chain up
33*635a8641SAndroid Build Coastguard Worker // to the PropertySet constructor, and then call RegisterProperty() for each
34*635a8641SAndroid Build Coastguard Worker // property defined to associate them with their string name.
35*635a8641SAndroid Build Coastguard Worker //
36*635a8641SAndroid Build Coastguard Worker // Example:
37*635a8641SAndroid Build Coastguard Worker //   class ExampleClient {
38*635a8641SAndroid Build Coastguard Worker //    public:
39*635a8641SAndroid Build Coastguard Worker //     struct Properties : public dbus::PropertySet {
40*635a8641SAndroid Build Coastguard Worker //       dbus::Property<std::string> name;
41*635a8641SAndroid Build Coastguard Worker //       dbus::Property<uint16_t> version;
42*635a8641SAndroid Build Coastguard Worker //       dbus::Property<dbus::ObjectPath> parent;
43*635a8641SAndroid Build Coastguard Worker //       dbus::Property<std::vector<std::string>> children;
44*635a8641SAndroid Build Coastguard Worker //
45*635a8641SAndroid Build Coastguard Worker //       Properties(dbus::ObjectProxy* object_proxy,
46*635a8641SAndroid Build Coastguard Worker //                  const PropertyChangedCallback callback)
47*635a8641SAndroid Build Coastguard Worker //           : dbus::PropertySet(object_proxy, "com.example.DBus", callback) {
48*635a8641SAndroid Build Coastguard Worker //         RegisterProperty("Name", &name);
49*635a8641SAndroid Build Coastguard Worker //         RegisterProperty("Version", &version);
50*635a8641SAndroid Build Coastguard Worker //         RegisterProperty("Parent", &parent);
51*635a8641SAndroid Build Coastguard Worker //         RegisterProperty("Children", &children);
52*635a8641SAndroid Build Coastguard Worker //       }
53*635a8641SAndroid Build Coastguard Worker //       virtual ~Properties() {}
54*635a8641SAndroid Build Coastguard Worker //     };
55*635a8641SAndroid Build Coastguard Worker //
56*635a8641SAndroid Build Coastguard Worker // The Properties structure requires a pointer to the object proxy of the
57*635a8641SAndroid Build Coastguard Worker // actual object to track, and after construction should have signals
58*635a8641SAndroid Build Coastguard Worker // connected to that object and initial values set by calling ConnectSignals()
59*635a8641SAndroid Build Coastguard Worker // and GetAll(). The structure should not outlive the object proxy, so it
60*635a8641SAndroid Build Coastguard Worker // is recommended that the lifecycle of both be managed together.
61*635a8641SAndroid Build Coastguard Worker //
62*635a8641SAndroid Build Coastguard Worker // Example (continued):
63*635a8641SAndroid Build Coastguard Worker //
64*635a8641SAndroid Build Coastguard Worker //     typedef std::map<std::pair<dbus::ObjectProxy*, Properties*>> Object;
65*635a8641SAndroid Build Coastguard Worker //     typedef std::map<dbus::ObjectPath, Object> ObjectMap;
66*635a8641SAndroid Build Coastguard Worker //     ObjectMap object_map_;
67*635a8641SAndroid Build Coastguard Worker //
68*635a8641SAndroid Build Coastguard Worker //     dbus::ObjectProxy* GetObjectProxy(const dbus::ObjectPath& object_path) {
69*635a8641SAndroid Build Coastguard Worker //       return GetObject(object_path).first;
70*635a8641SAndroid Build Coastguard Worker //     }
71*635a8641SAndroid Build Coastguard Worker //
72*635a8641SAndroid Build Coastguard Worker //     Properties* GetProperties(const dbus::ObjectPath& object_path) {
73*635a8641SAndroid Build Coastguard Worker //       return GetObject(object_path).second;
74*635a8641SAndroid Build Coastguard Worker //     }
75*635a8641SAndroid Build Coastguard Worker //
76*635a8641SAndroid Build Coastguard Worker //     Object GetObject(const dbus::ObjectPath& object_path) {
77*635a8641SAndroid Build Coastguard Worker //       ObjectMap::iterator it = object_map_.find(object_path);
78*635a8641SAndroid Build Coastguard Worker //       if (it != object_map_.end())
79*635a8641SAndroid Build Coastguard Worker //         return it->second;
80*635a8641SAndroid Build Coastguard Worker //
81*635a8641SAndroid Build Coastguard Worker //       dbus::ObjectProxy* object_proxy = bus->GetObjectProxy(...);
82*635a8641SAndroid Build Coastguard Worker //       // connect signals, etc.
83*635a8641SAndroid Build Coastguard Worker //
84*635a8641SAndroid Build Coastguard Worker //       Properties* properties = new Properties(
85*635a8641SAndroid Build Coastguard Worker //           object_proxy,
86*635a8641SAndroid Build Coastguard Worker //           base::Bind(&PropertyChanged,
87*635a8641SAndroid Build Coastguard Worker //                      weak_ptr_factory_.GetWeakPtr(),
88*635a8641SAndroid Build Coastguard Worker //                      object_path));
89*635a8641SAndroid Build Coastguard Worker //       properties->ConnectSignals();
90*635a8641SAndroid Build Coastguard Worker //       properties->GetAll();
91*635a8641SAndroid Build Coastguard Worker //
92*635a8641SAndroid Build Coastguard Worker //       Object object = std::make_pair(object_proxy, properties);
93*635a8641SAndroid Build Coastguard Worker //       object_map_[object_path] = object;
94*635a8641SAndroid Build Coastguard Worker //       return object;
95*635a8641SAndroid Build Coastguard Worker //     }
96*635a8641SAndroid Build Coastguard Worker //  };
97*635a8641SAndroid Build Coastguard Worker //
98*635a8641SAndroid Build Coastguard Worker // This now allows code using the client implementation to access properties
99*635a8641SAndroid Build Coastguard Worker // in a type-safe manner, and assuming the PropertyChanged callback is
100*635a8641SAndroid Build Coastguard Worker // propogated up to observers, be notified of changes. A typical access of
101*635a8641SAndroid Build Coastguard Worker // the current value of the name property would be:
102*635a8641SAndroid Build Coastguard Worker //
103*635a8641SAndroid Build Coastguard Worker //   ExampleClient::Properties* p = example_client->GetProperties(object_path);
104*635a8641SAndroid Build Coastguard Worker //   std::string name = p->name.value();
105*635a8641SAndroid Build Coastguard Worker //
106*635a8641SAndroid Build Coastguard Worker // Normally these values are updated from signals emitted by the remote object,
107*635a8641SAndroid Build Coastguard Worker // in case an explicit round-trip is needed to obtain the current value, the
108*635a8641SAndroid Build Coastguard Worker // Get() method can be used and indicates whether or not the value update was
109*635a8641SAndroid Build Coastguard Worker // successful. The updated value can be obtained in the callback using the
110*635a8641SAndroid Build Coastguard Worker // value() method.
111*635a8641SAndroid Build Coastguard Worker //
112*635a8641SAndroid Build Coastguard Worker //   p->children.Get(base::Bind(&OnGetChildren));
113*635a8641SAndroid Build Coastguard Worker //
114*635a8641SAndroid Build Coastguard Worker // A new value can be set using the Set() method, the callback indicates
115*635a8641SAndroid Build Coastguard Worker // success only; it is up to the remote object when (and indeed if) it updates
116*635a8641SAndroid Build Coastguard Worker // the property value, and whether it emits a signal or a Get() call is
117*635a8641SAndroid Build Coastguard Worker // required to obtain it.
118*635a8641SAndroid Build Coastguard Worker //
119*635a8641SAndroid Build Coastguard Worker //   p->version.Set(20, base::Bind(&OnSetVersion))
120*635a8641SAndroid Build Coastguard Worker 
121*635a8641SAndroid Build Coastguard Worker namespace dbus {
122*635a8641SAndroid Build Coastguard Worker 
123*635a8641SAndroid Build Coastguard Worker // D-Bus Properties interface constants, declared here rather than
124*635a8641SAndroid Build Coastguard Worker // in property.cc because template methods use them.
125*635a8641SAndroid Build Coastguard Worker const char kPropertiesInterface[] = "org.freedesktop.DBus.Properties";
126*635a8641SAndroid Build Coastguard Worker const char kPropertiesGetAll[] = "GetAll";
127*635a8641SAndroid Build Coastguard Worker const char kPropertiesGet[] = "Get";
128*635a8641SAndroid Build Coastguard Worker const char kPropertiesSet[] = "Set";
129*635a8641SAndroid Build Coastguard Worker const char kPropertiesChanged[] = "PropertiesChanged";
130*635a8641SAndroid Build Coastguard Worker 
131*635a8641SAndroid Build Coastguard Worker class PropertySet;
132*635a8641SAndroid Build Coastguard Worker 
133*635a8641SAndroid Build Coastguard Worker // PropertyBase is an abstract base-class consisting of the parts of
134*635a8641SAndroid Build Coastguard Worker // the Property<> template that are not type-specific, such as the
135*635a8641SAndroid Build Coastguard Worker // associated PropertySet, property name, and the type-unsafe parts
136*635a8641SAndroid Build Coastguard Worker // used by PropertySet.
137*635a8641SAndroid Build Coastguard Worker class CHROME_DBUS_EXPORT PropertyBase {
138*635a8641SAndroid Build Coastguard Worker  public:
139*635a8641SAndroid Build Coastguard Worker   PropertyBase();
140*635a8641SAndroid Build Coastguard Worker   virtual ~PropertyBase();
141*635a8641SAndroid Build Coastguard Worker 
142*635a8641SAndroid Build Coastguard Worker   // Initializes the |property_set| and property |name| so that method
143*635a8641SAndroid Build Coastguard Worker   // calls may be made from this class. This method is called by
144*635a8641SAndroid Build Coastguard Worker   // PropertySet::RegisterProperty() passing |this| for |property_set| so
145*635a8641SAndroid Build Coastguard Worker   // there should be no need to call it directly. If you do beware that
146*635a8641SAndroid Build Coastguard Worker   // no ownership or reference to |property_set| is taken so that object
147*635a8641SAndroid Build Coastguard Worker   // must outlive this one.
148*635a8641SAndroid Build Coastguard Worker   void Init(PropertySet* property_set, const std::string& name);
149*635a8641SAndroid Build Coastguard Worker 
150*635a8641SAndroid Build Coastguard Worker   // Retrieves the name of this property, this may be useful in observers
151*635a8641SAndroid Build Coastguard Worker   // to avoid specifying the name in more than once place, e.g.
152*635a8641SAndroid Build Coastguard Worker   //
153*635a8641SAndroid Build Coastguard Worker   //   void Client::PropertyChanged(const dbus::ObjectPath& object_path,
154*635a8641SAndroid Build Coastguard Worker   //                                const std::string &property_name) {
155*635a8641SAndroid Build Coastguard Worker   //     Properties& properties = GetProperties(object_path);
156*635a8641SAndroid Build Coastguard Worker   //     if (property_name == properties.version.name()) {
157*635a8641SAndroid Build Coastguard Worker   //       // Handle version property changing
158*635a8641SAndroid Build Coastguard Worker   //     }
159*635a8641SAndroid Build Coastguard Worker   //   }
name()160*635a8641SAndroid Build Coastguard Worker   const std::string& name() const { return name_; }
161*635a8641SAndroid Build Coastguard Worker 
162*635a8641SAndroid Build Coastguard Worker   // Returns true if property is valid, false otherwise.
is_valid()163*635a8641SAndroid Build Coastguard Worker   bool is_valid() const { return is_valid_; }
164*635a8641SAndroid Build Coastguard Worker 
165*635a8641SAndroid Build Coastguard Worker   // Allows to mark Property as valid or invalid.
set_valid(bool is_valid)166*635a8641SAndroid Build Coastguard Worker   void set_valid(bool is_valid) { is_valid_ = is_valid; }
167*635a8641SAndroid Build Coastguard Worker 
168*635a8641SAndroid Build Coastguard Worker   // Method used by PropertySet to retrieve the value from a MessageReader,
169*635a8641SAndroid Build Coastguard Worker   // no knowledge of the contained type is required, this method returns
170*635a8641SAndroid Build Coastguard Worker   // true if its expected type was found, false if not.
171*635a8641SAndroid Build Coastguard Worker   // Implementation provided by specialization.
172*635a8641SAndroid Build Coastguard Worker   virtual bool PopValueFromReader(MessageReader* reader) = 0;
173*635a8641SAndroid Build Coastguard Worker 
174*635a8641SAndroid Build Coastguard Worker   // Method used by PropertySet to append the set value to a MessageWriter,
175*635a8641SAndroid Build Coastguard Worker   // no knowledge of the contained type is required.
176*635a8641SAndroid Build Coastguard Worker   // Implementation provided by specialization.
177*635a8641SAndroid Build Coastguard Worker   virtual void AppendSetValueToWriter(MessageWriter* writer) = 0;
178*635a8641SAndroid Build Coastguard Worker 
179*635a8641SAndroid Build Coastguard Worker   // Method used by test and stub implementations of dbus::PropertySet::Set
180*635a8641SAndroid Build Coastguard Worker   // to replace the property value with the set value without using a
181*635a8641SAndroid Build Coastguard Worker   // dbus::MessageReader.
182*635a8641SAndroid Build Coastguard Worker   virtual void ReplaceValueWithSetValue() = 0;
183*635a8641SAndroid Build Coastguard Worker 
184*635a8641SAndroid Build Coastguard Worker  protected:
185*635a8641SAndroid Build Coastguard Worker   // Retrieves the associated property set.
property_set()186*635a8641SAndroid Build Coastguard Worker   PropertySet* property_set() { return property_set_; }
187*635a8641SAndroid Build Coastguard Worker 
188*635a8641SAndroid Build Coastguard Worker  private:
189*635a8641SAndroid Build Coastguard Worker   // Pointer to the PropertySet instance that this instance is a member of,
190*635a8641SAndroid Build Coastguard Worker   // no ownership is taken and |property_set_| must outlive this class.
191*635a8641SAndroid Build Coastguard Worker   PropertySet* property_set_;
192*635a8641SAndroid Build Coastguard Worker 
193*635a8641SAndroid Build Coastguard Worker   bool is_valid_;
194*635a8641SAndroid Build Coastguard Worker 
195*635a8641SAndroid Build Coastguard Worker   // Name of the property.
196*635a8641SAndroid Build Coastguard Worker   std::string name_;
197*635a8641SAndroid Build Coastguard Worker 
198*635a8641SAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(PropertyBase);
199*635a8641SAndroid Build Coastguard Worker };
200*635a8641SAndroid Build Coastguard Worker 
201*635a8641SAndroid Build Coastguard Worker // PropertySet groups a collection of properties for a remote object
202*635a8641SAndroid Build Coastguard Worker // together into a single structure, fixing their types and name such
203*635a8641SAndroid Build Coastguard Worker // that calls made through it are type-safe.
204*635a8641SAndroid Build Coastguard Worker //
205*635a8641SAndroid Build Coastguard Worker // Clients always sub-class this to add the properties, and should always
206*635a8641SAndroid Build Coastguard Worker // provide a constructor that chains up to this and then calls
207*635a8641SAndroid Build Coastguard Worker // RegisterProperty() for each property defined.
208*635a8641SAndroid Build Coastguard Worker //
209*635a8641SAndroid Build Coastguard Worker // After creation, client code should call ConnectSignals() and most likely
210*635a8641SAndroid Build Coastguard Worker // GetAll() to seed initial values and update as changes occur.
211*635a8641SAndroid Build Coastguard Worker class CHROME_DBUS_EXPORT PropertySet {
212*635a8641SAndroid Build Coastguard Worker  public:
213*635a8641SAndroid Build Coastguard Worker   // Callback for changes to cached values of properties, either notified
214*635a8641SAndroid Build Coastguard Worker   // via signal, or as a result of calls to Get() and GetAll(). The |name|
215*635a8641SAndroid Build Coastguard Worker   // argument specifies the name of the property changed.
216*635a8641SAndroid Build Coastguard Worker   typedef base::Callback<void(const std::string& name)> PropertyChangedCallback;
217*635a8641SAndroid Build Coastguard Worker 
218*635a8641SAndroid Build Coastguard Worker   // Constructs a property set, where |object_proxy| specifies the proxy for
219*635a8641SAndroid Build Coastguard Worker   // the/ remote object that these properties are for, care should be taken to
220*635a8641SAndroid Build Coastguard Worker   // ensure that this object does not outlive the lifetime of the proxy;
221*635a8641SAndroid Build Coastguard Worker   // |interface| specifies the D-Bus interface of these properties, and
222*635a8641SAndroid Build Coastguard Worker   // |property_changed_callback| specifies the callback for when properties
223*635a8641SAndroid Build Coastguard Worker   // are changed, this may be a NULL callback.
224*635a8641SAndroid Build Coastguard Worker   PropertySet(ObjectProxy* object_proxy, const std::string& interface,
225*635a8641SAndroid Build Coastguard Worker               const PropertyChangedCallback& property_changed_callback);
226*635a8641SAndroid Build Coastguard Worker 
227*635a8641SAndroid Build Coastguard Worker   // Destructor; we don't hold on to any references or memory that needs
228*635a8641SAndroid Build Coastguard Worker   // explicit clean-up, but clang thinks we might.
229*635a8641SAndroid Build Coastguard Worker   virtual ~PropertySet();
230*635a8641SAndroid Build Coastguard Worker 
231*635a8641SAndroid Build Coastguard Worker   // Registers a property, generally called from the subclass constructor;
232*635a8641SAndroid Build Coastguard Worker   // pass the |name| of the property as used in method calls and signals,
233*635a8641SAndroid Build Coastguard Worker   // and the pointer to the |property| member of the structure. This will
234*635a8641SAndroid Build Coastguard Worker   // call the PropertyBase::Init method.
235*635a8641SAndroid Build Coastguard Worker   void RegisterProperty(const std::string& name, PropertyBase* property);
236*635a8641SAndroid Build Coastguard Worker 
237*635a8641SAndroid Build Coastguard Worker   // Connects property change notification signals to the object, generally
238*635a8641SAndroid Build Coastguard Worker   // called immediately after the object is created and before calls to other
239*635a8641SAndroid Build Coastguard Worker   // methods. Sub-classes may override to use different D-Bus signals.
240*635a8641SAndroid Build Coastguard Worker   virtual void ConnectSignals();
241*635a8641SAndroid Build Coastguard Worker 
242*635a8641SAndroid Build Coastguard Worker   // Methods connected by ConnectSignals() and called by dbus:: when
243*635a8641SAndroid Build Coastguard Worker   // a property is changed. Sub-classes may override if the property
244*635a8641SAndroid Build Coastguard Worker   // changed signal provides different arguments.
245*635a8641SAndroid Build Coastguard Worker   virtual void ChangedReceived(Signal* signal);
246*635a8641SAndroid Build Coastguard Worker   virtual void ChangedConnected(const std::string& interface_name,
247*635a8641SAndroid Build Coastguard Worker                                 const std::string& signal_name,
248*635a8641SAndroid Build Coastguard Worker                                 bool success);
249*635a8641SAndroid Build Coastguard Worker 
250*635a8641SAndroid Build Coastguard Worker   // Callback for Get() method, |success| indicates whether or not the
251*635a8641SAndroid Build Coastguard Worker   // value could be retrived, if true the new value can be obtained by
252*635a8641SAndroid Build Coastguard Worker   // calling value() on the property.
253*635a8641SAndroid Build Coastguard Worker   typedef base::Callback<void(bool success)> GetCallback;
254*635a8641SAndroid Build Coastguard Worker 
255*635a8641SAndroid Build Coastguard Worker   // Requests an updated value from the remote object for |property|
256*635a8641SAndroid Build Coastguard Worker   // incurring a round-trip. |callback| will be called when the new
257*635a8641SAndroid Build Coastguard Worker   // value is available. This may not be implemented by some interfaces,
258*635a8641SAndroid Build Coastguard Worker   // and may be overriden by sub-classes if interfaces use different
259*635a8641SAndroid Build Coastguard Worker   // method calls.
260*635a8641SAndroid Build Coastguard Worker   virtual void Get(PropertyBase* property, GetCallback callback);
261*635a8641SAndroid Build Coastguard Worker   virtual void OnGet(PropertyBase* property, GetCallback callback,
262*635a8641SAndroid Build Coastguard Worker                      Response* response);
263*635a8641SAndroid Build Coastguard Worker 
264*635a8641SAndroid Build Coastguard Worker   // The synchronous version of Get().
265*635a8641SAndroid Build Coastguard Worker   // This should never be used on an interactive thread.
266*635a8641SAndroid Build Coastguard Worker   virtual bool GetAndBlock(PropertyBase* property);
267*635a8641SAndroid Build Coastguard Worker 
268*635a8641SAndroid Build Coastguard Worker   // Queries the remote object for values of all properties and updates
269*635a8641SAndroid Build Coastguard Worker   // initial values. Sub-classes may override to use a different D-Bus
270*635a8641SAndroid Build Coastguard Worker   // method, or if the remote object does not support retrieving all
271*635a8641SAndroid Build Coastguard Worker   // properties, either ignore or obtain each property value individually.
272*635a8641SAndroid Build Coastguard Worker   virtual void GetAll();
273*635a8641SAndroid Build Coastguard Worker   virtual void OnGetAll(Response* response);
274*635a8641SAndroid Build Coastguard Worker 
275*635a8641SAndroid Build Coastguard Worker   // Callback for Set() method, |success| indicates whether or not the
276*635a8641SAndroid Build Coastguard Worker   // new property value was accepted by the remote object.
277*635a8641SAndroid Build Coastguard Worker   typedef base::Callback<void(bool success)> SetCallback;
278*635a8641SAndroid Build Coastguard Worker 
279*635a8641SAndroid Build Coastguard Worker   // Requests that the remote object for |property| change the property to
280*635a8641SAndroid Build Coastguard Worker   // its new value. |callback| will be called to indicate the success or
281*635a8641SAndroid Build Coastguard Worker   // failure of the request, however the new value may not be available
282*635a8641SAndroid Build Coastguard Worker   // depending on the remote object. This method may be overridden by
283*635a8641SAndroid Build Coastguard Worker   // sub-classes if interfaces use different method calls.
284*635a8641SAndroid Build Coastguard Worker   virtual void Set(PropertyBase* property, SetCallback callback);
285*635a8641SAndroid Build Coastguard Worker   virtual void OnSet(PropertyBase* property, SetCallback callback,
286*635a8641SAndroid Build Coastguard Worker                      Response* response);
287*635a8641SAndroid Build Coastguard Worker 
288*635a8641SAndroid Build Coastguard Worker   // The synchronous version of Set().
289*635a8641SAndroid Build Coastguard Worker   // This should never be used on an interactive thread.
290*635a8641SAndroid Build Coastguard Worker   virtual bool SetAndBlock(PropertyBase* property);
291*635a8641SAndroid Build Coastguard Worker 
292*635a8641SAndroid Build Coastguard Worker   // Update properties by reading an array of dictionary entries, each
293*635a8641SAndroid Build Coastguard Worker   // containing a string with the name and a variant with the value, from
294*635a8641SAndroid Build Coastguard Worker   // |message_reader|. Returns false if message is in incorrect format.
295*635a8641SAndroid Build Coastguard Worker   bool UpdatePropertiesFromReader(MessageReader* reader);
296*635a8641SAndroid Build Coastguard Worker 
297*635a8641SAndroid Build Coastguard Worker   // Updates a single property by reading a string with the name and a
298*635a8641SAndroid Build Coastguard Worker   // variant with the value from |message_reader|. Returns false if message
299*635a8641SAndroid Build Coastguard Worker   // is in incorrect format, or property type doesn't match.
300*635a8641SAndroid Build Coastguard Worker   bool UpdatePropertyFromReader(MessageReader* reader);
301*635a8641SAndroid Build Coastguard Worker 
302*635a8641SAndroid Build Coastguard Worker   // Calls the property changed callback passed to the constructor, used
303*635a8641SAndroid Build Coastguard Worker   // by sub-classes that do not call UpdatePropertiesFromReader() or
304*635a8641SAndroid Build Coastguard Worker   // UpdatePropertyFromReader(). Takes the |name| of the changed property.
305*635a8641SAndroid Build Coastguard Worker   void NotifyPropertyChanged(const std::string& name);
306*635a8641SAndroid Build Coastguard Worker 
307*635a8641SAndroid Build Coastguard Worker   // Retrieves the object proxy this property set was initialized with,
308*635a8641SAndroid Build Coastguard Worker   // provided for sub-classes overriding methods that make D-Bus calls
309*635a8641SAndroid Build Coastguard Worker   // and for Property<>. Not permitted with const references to this class.
object_proxy()310*635a8641SAndroid Build Coastguard Worker   ObjectProxy* object_proxy() { return object_proxy_; }
311*635a8641SAndroid Build Coastguard Worker 
312*635a8641SAndroid Build Coastguard Worker   // Retrieves the interface of this property set.
interface()313*635a8641SAndroid Build Coastguard Worker   const std::string& interface() const { return interface_; }
314*635a8641SAndroid Build Coastguard Worker 
315*635a8641SAndroid Build Coastguard Worker  protected:
316*635a8641SAndroid Build Coastguard Worker   // Get a weak pointer to this property set, provided so that sub-classes
317*635a8641SAndroid Build Coastguard Worker   // overriding methods that make D-Bus calls may use the existing (or
318*635a8641SAndroid Build Coastguard Worker   // override) callbacks without providing their own weak pointer factory.
GetWeakPtr()319*635a8641SAndroid Build Coastguard Worker   base::WeakPtr<PropertySet> GetWeakPtr() {
320*635a8641SAndroid Build Coastguard Worker     return weak_ptr_factory_.GetWeakPtr();
321*635a8641SAndroid Build Coastguard Worker   }
322*635a8641SAndroid Build Coastguard Worker 
323*635a8641SAndroid Build Coastguard Worker  private:
324*635a8641SAndroid Build Coastguard Worker   // Invalidates properties by reading an array of names, from
325*635a8641SAndroid Build Coastguard Worker   // |message_reader|. Returns false if message is in incorrect format.
326*635a8641SAndroid Build Coastguard Worker   bool InvalidatePropertiesFromReader(MessageReader* reader);
327*635a8641SAndroid Build Coastguard Worker 
328*635a8641SAndroid Build Coastguard Worker   // Pointer to object proxy for making method calls, no ownership is taken
329*635a8641SAndroid Build Coastguard Worker   // so this must outlive this class.
330*635a8641SAndroid Build Coastguard Worker   ObjectProxy* object_proxy_;
331*635a8641SAndroid Build Coastguard Worker 
332*635a8641SAndroid Build Coastguard Worker   // Interface of property, e.g. "org.chromium.ExampleService", this is
333*635a8641SAndroid Build Coastguard Worker   // distinct from the interface of the method call itself which is the
334*635a8641SAndroid Build Coastguard Worker   // general D-Bus Properties interface "org.freedesktop.DBus.Properties".
335*635a8641SAndroid Build Coastguard Worker   std::string interface_;
336*635a8641SAndroid Build Coastguard Worker 
337*635a8641SAndroid Build Coastguard Worker   // Callback for property changes.
338*635a8641SAndroid Build Coastguard Worker   PropertyChangedCallback property_changed_callback_;
339*635a8641SAndroid Build Coastguard Worker 
340*635a8641SAndroid Build Coastguard Worker   // Map of properties (as PropertyBase*) defined in the structure to
341*635a8641SAndroid Build Coastguard Worker   // names as used in D-Bus method calls and signals. The base pointer
342*635a8641SAndroid Build Coastguard Worker   // restricts property access via this map to type-unsafe and non-specific
343*635a8641SAndroid Build Coastguard Worker   // actions only.
344*635a8641SAndroid Build Coastguard Worker   typedef std::map<const std::string, PropertyBase*> PropertiesMap;
345*635a8641SAndroid Build Coastguard Worker   PropertiesMap properties_map_;
346*635a8641SAndroid Build Coastguard Worker 
347*635a8641SAndroid Build Coastguard Worker   // Weak pointer factory as D-Bus callbacks may last longer than these
348*635a8641SAndroid Build Coastguard Worker   // objects.
349*635a8641SAndroid Build Coastguard Worker   base::WeakPtrFactory<PropertySet> weak_ptr_factory_;
350*635a8641SAndroid Build Coastguard Worker 
351*635a8641SAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(PropertySet);
352*635a8641SAndroid Build Coastguard Worker };
353*635a8641SAndroid Build Coastguard Worker 
354*635a8641SAndroid Build Coastguard Worker // Property template, this defines the type-specific and type-safe methods
355*635a8641SAndroid Build Coastguard Worker // of properties that can be accessed as members of a PropertySet structure.
356*635a8641SAndroid Build Coastguard Worker //
357*635a8641SAndroid Build Coastguard Worker // Properties provide a cached value that has an initial sensible default
358*635a8641SAndroid Build Coastguard Worker // until the reply to PropertySet::GetAll() is retrieved and is updated by
359*635a8641SAndroid Build Coastguard Worker // all calls to that method, PropertySet::Get() and property changed signals
360*635a8641SAndroid Build Coastguard Worker // also handled by PropertySet. It can be obtained by calling value() on the
361*635a8641SAndroid Build Coastguard Worker // property.
362*635a8641SAndroid Build Coastguard Worker //
363*635a8641SAndroid Build Coastguard Worker // It is recommended that this cached value be used where necessary, with
364*635a8641SAndroid Build Coastguard Worker // code using PropertySet::PropertyChangedCallback to be notified of changes,
365*635a8641SAndroid Build Coastguard Worker // rather than incurring a round-trip to the remote object for each property
366*635a8641SAndroid Build Coastguard Worker // access.
367*635a8641SAndroid Build Coastguard Worker //
368*635a8641SAndroid Build Coastguard Worker // Where a round-trip is necessary, the Get() method is provided. And to
369*635a8641SAndroid Build Coastguard Worker // update the remote object value, the Set() method is also provided; these
370*635a8641SAndroid Build Coastguard Worker // both simply call methods on PropertySet.
371*635a8641SAndroid Build Coastguard Worker //
372*635a8641SAndroid Build Coastguard Worker // Handling of particular D-Bus types is performed via specialization,
373*635a8641SAndroid Build Coastguard Worker // typically the PopValueFromReader() and AppendSetValueToWriter() methods
374*635a8641SAndroid Build Coastguard Worker // will need to be provided, and in rare cases a constructor to provide a
375*635a8641SAndroid Build Coastguard Worker // default value. Specializations for basic D-Bus types, strings, object
376*635a8641SAndroid Build Coastguard Worker // paths and arrays are provided for you.
377*635a8641SAndroid Build Coastguard Worker template <class T>
378*635a8641SAndroid Build Coastguard Worker class CHROME_DBUS_EXPORT Property : public PropertyBase {
379*635a8641SAndroid Build Coastguard Worker  public:
Property()380*635a8641SAndroid Build Coastguard Worker   Property() {}
~Property()381*635a8641SAndroid Build Coastguard Worker   ~Property() override {}
382*635a8641SAndroid Build Coastguard Worker 
383*635a8641SAndroid Build Coastguard Worker   // Retrieves the cached value.
value()384*635a8641SAndroid Build Coastguard Worker   const T& value() const { return value_; }
385*635a8641SAndroid Build Coastguard Worker 
386*635a8641SAndroid Build Coastguard Worker   // Requests an updated value from the remote object incurring a
387*635a8641SAndroid Build Coastguard Worker   // round-trip. |callback| will be called when the new value is available.
388*635a8641SAndroid Build Coastguard Worker   // This may not be implemented by some interfaces.
Get(dbus::PropertySet::GetCallback callback)389*635a8641SAndroid Build Coastguard Worker   virtual void Get(dbus::PropertySet::GetCallback callback) {
390*635a8641SAndroid Build Coastguard Worker     property_set()->Get(this, callback);
391*635a8641SAndroid Build Coastguard Worker   }
392*635a8641SAndroid Build Coastguard Worker 
393*635a8641SAndroid Build Coastguard Worker   // The synchronous version of Get().
394*635a8641SAndroid Build Coastguard Worker   // This should never be used on an interactive thread.
GetAndBlock()395*635a8641SAndroid Build Coastguard Worker   virtual bool GetAndBlock() {
396*635a8641SAndroid Build Coastguard Worker     return property_set()->GetAndBlock(this);
397*635a8641SAndroid Build Coastguard Worker   }
398*635a8641SAndroid Build Coastguard Worker 
399*635a8641SAndroid Build Coastguard Worker   // Requests that the remote object change the property value to |value|,
400*635a8641SAndroid Build Coastguard Worker   // |callback| will be called to indicate the success or failure of the
401*635a8641SAndroid Build Coastguard Worker   // request, however the new value may not be available depending on the
402*635a8641SAndroid Build Coastguard Worker   // remote object.
Set(const T & value,dbus::PropertySet::SetCallback callback)403*635a8641SAndroid Build Coastguard Worker   virtual void Set(const T& value, dbus::PropertySet::SetCallback callback) {
404*635a8641SAndroid Build Coastguard Worker     set_value_ = value;
405*635a8641SAndroid Build Coastguard Worker     property_set()->Set(this, callback);
406*635a8641SAndroid Build Coastguard Worker   }
407*635a8641SAndroid Build Coastguard Worker 
408*635a8641SAndroid Build Coastguard Worker   // The synchronous version of Set().
409*635a8641SAndroid Build Coastguard Worker   // This should never be used on an interactive thread.
SetAndBlock(const T & value)410*635a8641SAndroid Build Coastguard Worker   virtual bool SetAndBlock(const T& value) {
411*635a8641SAndroid Build Coastguard Worker     set_value_ = value;
412*635a8641SAndroid Build Coastguard Worker     return property_set()->SetAndBlock(this);
413*635a8641SAndroid Build Coastguard Worker   }
414*635a8641SAndroid Build Coastguard Worker 
415*635a8641SAndroid Build Coastguard Worker   // Method used by PropertySet to retrieve the value from a MessageReader,
416*635a8641SAndroid Build Coastguard Worker   // no knowledge of the contained type is required, this method returns
417*635a8641SAndroid Build Coastguard Worker   // true if its expected type was found, false if not.
418*635a8641SAndroid Build Coastguard Worker   bool PopValueFromReader(MessageReader* reader) override;
419*635a8641SAndroid Build Coastguard Worker 
420*635a8641SAndroid Build Coastguard Worker   // Method used by PropertySet to append the set value to a MessageWriter,
421*635a8641SAndroid Build Coastguard Worker   // no knowledge of the contained type is required.
422*635a8641SAndroid Build Coastguard Worker   // Implementation provided by specialization.
423*635a8641SAndroid Build Coastguard Worker   void AppendSetValueToWriter(MessageWriter* writer) override;
424*635a8641SAndroid Build Coastguard Worker 
425*635a8641SAndroid Build Coastguard Worker   // Method used by test and stub implementations of dbus::PropertySet::Set
426*635a8641SAndroid Build Coastguard Worker   // to replace the property value with the set value without using a
427*635a8641SAndroid Build Coastguard Worker   // dbus::MessageReader.
ReplaceValueWithSetValue()428*635a8641SAndroid Build Coastguard Worker   void ReplaceValueWithSetValue() override {
429*635a8641SAndroid Build Coastguard Worker     value_ = set_value_;
430*635a8641SAndroid Build Coastguard Worker     property_set()->NotifyPropertyChanged(name());
431*635a8641SAndroid Build Coastguard Worker   }
432*635a8641SAndroid Build Coastguard Worker 
433*635a8641SAndroid Build Coastguard Worker   // Method used by test and stub implementations to directly set the
434*635a8641SAndroid Build Coastguard Worker   // value of a property.
ReplaceValue(const T & value)435*635a8641SAndroid Build Coastguard Worker   void ReplaceValue(const T& value) {
436*635a8641SAndroid Build Coastguard Worker     value_ = value;
437*635a8641SAndroid Build Coastguard Worker     property_set()->NotifyPropertyChanged(name());
438*635a8641SAndroid Build Coastguard Worker   }
439*635a8641SAndroid Build Coastguard Worker 
440*635a8641SAndroid Build Coastguard Worker   // Method used by test and stub implementations to directly set the
441*635a8641SAndroid Build Coastguard Worker   // |set_value_| of a property.
ReplaceSetValueForTesting(const T & value)442*635a8641SAndroid Build Coastguard Worker   void ReplaceSetValueForTesting(const T& value) { set_value_ = value; }
443*635a8641SAndroid Build Coastguard Worker 
444*635a8641SAndroid Build Coastguard Worker  private:
445*635a8641SAndroid Build Coastguard Worker   // Current cached value of the property.
446*635a8641SAndroid Build Coastguard Worker   T value_;
447*635a8641SAndroid Build Coastguard Worker 
448*635a8641SAndroid Build Coastguard Worker   // Replacement value of the property.
449*635a8641SAndroid Build Coastguard Worker   T set_value_;
450*635a8641SAndroid Build Coastguard Worker };
451*635a8641SAndroid Build Coastguard Worker 
452*635a8641SAndroid Build Coastguard Worker // Clang and GCC don't agree on how attributes should work for explicitly
453*635a8641SAndroid Build Coastguard Worker // instantiated templates. GCC ignores attributes on explicit instantiations
454*635a8641SAndroid Build Coastguard Worker // (and emits a warning) while Clang requires the visiblity attribute on the
455*635a8641SAndroid Build Coastguard Worker // explicit instantiations for them to be visible to other compilation units.
456*635a8641SAndroid Build Coastguard Worker // Hopefully clang and GCC agree one day, and this can be cleaned up:
457*635a8641SAndroid Build Coastguard Worker // https://llvm.org/bugs/show_bug.cgi?id=24815
458*635a8641SAndroid Build Coastguard Worker #pragma GCC diagnostic push
459*635a8641SAndroid Build Coastguard Worker #pragma GCC diagnostic ignored "-Wattributes"
460*635a8641SAndroid Build Coastguard Worker 
461*635a8641SAndroid Build Coastguard Worker template <>
462*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<uint8_t>::Property();
463*635a8641SAndroid Build Coastguard Worker template <>
464*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<uint8_t>::PopValueFromReader(
465*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
466*635a8641SAndroid Build Coastguard Worker template <>
467*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<uint8_t>::AppendSetValueToWriter(
468*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
469*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<uint8_t>;
470*635a8641SAndroid Build Coastguard Worker 
471*635a8641SAndroid Build Coastguard Worker template <>
472*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<bool>::Property();
473*635a8641SAndroid Build Coastguard Worker template <>
474*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<bool>::PopValueFromReader(
475*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
476*635a8641SAndroid Build Coastguard Worker template <>
477*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<bool>::AppendSetValueToWriter(
478*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
479*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<bool>;
480*635a8641SAndroid Build Coastguard Worker 
481*635a8641SAndroid Build Coastguard Worker template <>
482*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<int16_t>::Property();
483*635a8641SAndroid Build Coastguard Worker template <>
484*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<int16_t>::PopValueFromReader(
485*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
486*635a8641SAndroid Build Coastguard Worker template <>
487*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<int16_t>::AppendSetValueToWriter(
488*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
489*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<int16_t>;
490*635a8641SAndroid Build Coastguard Worker 
491*635a8641SAndroid Build Coastguard Worker template <>
492*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<uint16_t>::Property();
493*635a8641SAndroid Build Coastguard Worker template <>
494*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<uint16_t>::PopValueFromReader(
495*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
496*635a8641SAndroid Build Coastguard Worker template <>
497*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<uint16_t>::AppendSetValueToWriter(
498*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
499*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<uint16_t>;
500*635a8641SAndroid Build Coastguard Worker 
501*635a8641SAndroid Build Coastguard Worker template <>
502*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<int32_t>::Property();
503*635a8641SAndroid Build Coastguard Worker template <>
504*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<int32_t>::PopValueFromReader(
505*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
506*635a8641SAndroid Build Coastguard Worker template <>
507*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<int32_t>::AppendSetValueToWriter(
508*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
509*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<int32_t>;
510*635a8641SAndroid Build Coastguard Worker 
511*635a8641SAndroid Build Coastguard Worker template <>
512*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<uint32_t>::Property();
513*635a8641SAndroid Build Coastguard Worker template <>
514*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<uint32_t>::PopValueFromReader(
515*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
516*635a8641SAndroid Build Coastguard Worker template <>
517*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<uint32_t>::AppendSetValueToWriter(
518*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
519*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<uint32_t>;
520*635a8641SAndroid Build Coastguard Worker 
521*635a8641SAndroid Build Coastguard Worker template <>
522*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<int64_t>::Property();
523*635a8641SAndroid Build Coastguard Worker template <>
524*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<int64_t>::PopValueFromReader(
525*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
526*635a8641SAndroid Build Coastguard Worker template <>
527*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<int64_t>::AppendSetValueToWriter(
528*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
529*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<int64_t>;
530*635a8641SAndroid Build Coastguard Worker 
531*635a8641SAndroid Build Coastguard Worker template <>
532*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<uint64_t>::Property();
533*635a8641SAndroid Build Coastguard Worker template <>
534*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<uint64_t>::PopValueFromReader(
535*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
536*635a8641SAndroid Build Coastguard Worker template <>
537*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<uint64_t>::AppendSetValueToWriter(
538*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
539*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<uint64_t>;
540*635a8641SAndroid Build Coastguard Worker 
541*635a8641SAndroid Build Coastguard Worker template <>
542*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT Property<double>::Property();
543*635a8641SAndroid Build Coastguard Worker template <>
544*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<double>::PopValueFromReader(
545*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
546*635a8641SAndroid Build Coastguard Worker template <>
547*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<double>::AppendSetValueToWriter(
548*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
549*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<double>;
550*635a8641SAndroid Build Coastguard Worker 
551*635a8641SAndroid Build Coastguard Worker template <>
552*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<std::string>::PopValueFromReader(
553*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
554*635a8641SAndroid Build Coastguard Worker template <>
555*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<std::string>::AppendSetValueToWriter(
556*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
557*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<std::string>;
558*635a8641SAndroid Build Coastguard Worker 
559*635a8641SAndroid Build Coastguard Worker template <>
560*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<ObjectPath>::PopValueFromReader(
561*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
562*635a8641SAndroid Build Coastguard Worker template <>
563*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<ObjectPath>::AppendSetValueToWriter(
564*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
565*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<ObjectPath>;
566*635a8641SAndroid Build Coastguard Worker 
567*635a8641SAndroid Build Coastguard Worker template <>
568*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<std::vector<std::string>>::PopValueFromReader(
569*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
570*635a8641SAndroid Build Coastguard Worker template <>
571*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<
572*635a8641SAndroid Build Coastguard Worker     std::vector<std::string>>::AppendSetValueToWriter(MessageWriter* writer);
573*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<std::vector<std::string>>;
574*635a8641SAndroid Build Coastguard Worker 
575*635a8641SAndroid Build Coastguard Worker template <>
576*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<std::vector<ObjectPath>>::PopValueFromReader(
577*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
578*635a8641SAndroid Build Coastguard Worker template <>
579*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<
580*635a8641SAndroid Build Coastguard Worker     std::vector<ObjectPath>>::AppendSetValueToWriter(MessageWriter* writer);
581*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<std::vector<ObjectPath>>;
582*635a8641SAndroid Build Coastguard Worker 
583*635a8641SAndroid Build Coastguard Worker template <>
584*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool Property<std::vector<uint8_t>>::PopValueFromReader(
585*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
586*635a8641SAndroid Build Coastguard Worker template <>
587*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void Property<std::vector<uint8_t>>::AppendSetValueToWriter(
588*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
589*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT Property<std::vector<uint8_t>>;
590*635a8641SAndroid Build Coastguard Worker 
591*635a8641SAndroid Build Coastguard Worker template <>
592*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool
593*635a8641SAndroid Build Coastguard Worker Property<std::map<std::string, std::string>>::PopValueFromReader(
594*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
595*635a8641SAndroid Build Coastguard Worker template <>
596*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void
597*635a8641SAndroid Build Coastguard Worker Property<std::map<std::string, std::string>>::AppendSetValueToWriter(
598*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
599*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT
600*635a8641SAndroid Build Coastguard Worker     Property<std::map<std::string, std::string>>;
601*635a8641SAndroid Build Coastguard Worker 
602*635a8641SAndroid Build Coastguard Worker template <>
603*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool
604*635a8641SAndroid Build Coastguard Worker Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>::
605*635a8641SAndroid Build Coastguard Worker     PopValueFromReader(MessageReader* reader);
606*635a8641SAndroid Build Coastguard Worker template <>
607*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void
608*635a8641SAndroid Build Coastguard Worker Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>::
609*635a8641SAndroid Build Coastguard Worker     AppendSetValueToWriter(MessageWriter* writer);
610*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT
611*635a8641SAndroid Build Coastguard Worker     Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>;
612*635a8641SAndroid Build Coastguard Worker 
613*635a8641SAndroid Build Coastguard Worker template <>
614*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool
615*635a8641SAndroid Build Coastguard Worker Property<std::map<std::string, std::vector<uint8_t>>>::PopValueFromReader(
616*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
617*635a8641SAndroid Build Coastguard Worker template <>
618*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void
619*635a8641SAndroid Build Coastguard Worker Property<std::map<std::string, std::vector<uint8_t>>>::AppendSetValueToWriter(
620*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
621*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT
622*635a8641SAndroid Build Coastguard Worker     Property<std::map<std::string, std::vector<uint8_t>>>;
623*635a8641SAndroid Build Coastguard Worker 
624*635a8641SAndroid Build Coastguard Worker template <>
625*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT bool
626*635a8641SAndroid Build Coastguard Worker Property<std::map<uint16_t, std::vector<uint8_t>>>::PopValueFromReader(
627*635a8641SAndroid Build Coastguard Worker     MessageReader* reader);
628*635a8641SAndroid Build Coastguard Worker template <>
629*635a8641SAndroid Build Coastguard Worker CHROME_DBUS_EXPORT void
630*635a8641SAndroid Build Coastguard Worker Property<std::map<uint16_t, std::vector<uint8_t>>>::AppendSetValueToWriter(
631*635a8641SAndroid Build Coastguard Worker     MessageWriter* writer);
632*635a8641SAndroid Build Coastguard Worker extern template class CHROME_DBUS_EXPORT
633*635a8641SAndroid Build Coastguard Worker     Property<std::map<uint16_t, std::vector<uint8_t>>>;
634*635a8641SAndroid Build Coastguard Worker 
635*635a8641SAndroid Build Coastguard Worker #pragma GCC diagnostic pop
636*635a8641SAndroid Build Coastguard Worker 
637*635a8641SAndroid Build Coastguard Worker }  // namespace dbus
638*635a8641SAndroid Build Coastguard Worker 
639*635a8641SAndroid Build Coastguard Worker #endif  // DBUS_PROPERTY_H_
640