OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PROPERTY_H_ | 5 #ifndef DBUS_PROPERTY_H_ |
6 #define DBUS_PROPERTY_H_ | 6 #define DBUS_PROPERTY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 | 252 |
253 // Requests an updated value from the remote object for |property| | 253 // Requests an updated value from the remote object for |property| |
254 // incurring a round-trip. |callback| will be called when the new | 254 // incurring a round-trip. |callback| will be called when the new |
255 // value is available. This may not be implemented by some interfaces, | 255 // value is available. This may not be implemented by some interfaces, |
256 // and may be overriden by sub-classes if interfaces use different | 256 // and may be overriden by sub-classes if interfaces use different |
257 // method calls. | 257 // method calls. |
258 virtual void Get(PropertyBase* property, GetCallback callback); | 258 virtual void Get(PropertyBase* property, GetCallback callback); |
259 virtual void OnGet(PropertyBase* property, GetCallback callback, | 259 virtual void OnGet(PropertyBase* property, GetCallback callback, |
260 Response* response); | 260 Response* response); |
261 | 261 |
262 // The synchronous version of Get(). | |
stevenjb
2015/09/28 20:24:54
I assume this is for use outside of Chrome?
I wou
nywang
2015/09/28 20:45:33
Thanks.
Yes this is used outside Chrome. It is fo
| |
263 virtual bool GetAndBlock(PropertyBase* property); | |
264 | |
262 // Queries the remote object for values of all properties and updates | 265 // Queries the remote object for values of all properties and updates |
263 // initial values. Sub-classes may override to use a different D-Bus | 266 // initial values. Sub-classes may override to use a different D-Bus |
264 // method, or if the remote object does not support retrieving all | 267 // method, or if the remote object does not support retrieving all |
265 // properties, either ignore or obtain each property value individually. | 268 // properties, either ignore or obtain each property value individually. |
266 virtual void GetAll(); | 269 virtual void GetAll(); |
267 virtual void OnGetAll(Response* response); | 270 virtual void OnGetAll(Response* response); |
268 | 271 |
269 // Callback for Set() method, |success| indicates whether or not the | 272 // Callback for Set() method, |success| indicates whether or not the |
270 // new property value was accepted by the remote object. | 273 // new property value was accepted by the remote object. |
271 typedef base::Callback<void(bool success)> SetCallback; | 274 typedef base::Callback<void(bool success)> SetCallback; |
272 | 275 |
273 // Requests that the remote object for |property| change the property to | 276 // Requests that the remote object for |property| change the property to |
274 // its new value. |callback| will be called to indicate the success or | 277 // its new value. |callback| will be called to indicate the success or |
275 // failure of the request, however the new value may not be available | 278 // failure of the request, however the new value may not be available |
276 // depending on the remote object. This method may be overridden by | 279 // depending on the remote object. This method may be overridden by |
277 // sub-classes if interfaces use different method calls. | 280 // sub-classes if interfaces use different method calls. |
278 virtual void Set(PropertyBase* property, SetCallback callback); | 281 virtual void Set(PropertyBase* property, SetCallback callback); |
279 // The sychronous version of Set(). | |
280 virtual bool SetAndBlock(PropertyBase* property); | |
281 virtual void OnSet(PropertyBase* property, SetCallback callback, | 282 virtual void OnSet(PropertyBase* property, SetCallback callback, |
282 Response* response); | 283 Response* response); |
283 | 284 |
285 // The synchronous version of Set(). | |
stevenjb
2015/09/28 20:24:54
We should add a warning here too.
| |
286 virtual bool SetAndBlock(PropertyBase* property); | |
287 | |
284 // Update properties by reading an array of dictionary entries, each | 288 // Update properties by reading an array of dictionary entries, each |
285 // containing a string with the name and a variant with the value, from | 289 // containing a string with the name and a variant with the value, from |
286 // |message_reader|. Returns false if message is in incorrect format. | 290 // |message_reader|. Returns false if message is in incorrect format. |
287 bool UpdatePropertiesFromReader(MessageReader* reader); | 291 bool UpdatePropertiesFromReader(MessageReader* reader); |
288 | 292 |
289 // Updates a single property by reading a string with the name and a | 293 // Updates a single property by reading a string with the name and a |
290 // variant with the value from |message_reader|. Returns false if message | 294 // variant with the value from |message_reader|. Returns false if message |
291 // is in incorrect format, or property type doesn't match. | 295 // is in incorrect format, or property type doesn't match. |
292 bool UpdatePropertyFromReader(MessageReader* reader); | 296 bool UpdatePropertyFromReader(MessageReader* reader); |
293 | 297 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 // Retrieves the cached value. | 379 // Retrieves the cached value. |
376 const T& value() const { return value_; } | 380 const T& value() const { return value_; } |
377 | 381 |
378 // Requests an updated value from the remote object incurring a | 382 // Requests an updated value from the remote object incurring a |
379 // round-trip. |callback| will be called when the new value is available. | 383 // round-trip. |callback| will be called when the new value is available. |
380 // This may not be implemented by some interfaces. | 384 // This may not be implemented by some interfaces. |
381 virtual void Get(dbus::PropertySet::GetCallback callback) { | 385 virtual void Get(dbus::PropertySet::GetCallback callback) { |
382 property_set()->Get(this, callback); | 386 property_set()->Get(this, callback); |
383 } | 387 } |
384 | 388 |
389 // The synchronous version of Get(). | |
390 virtual bool GetAndBlock() { | |
391 return property_set()->GetAndBlock(this); | |
392 } | |
393 | |
385 // Requests that the remote object change the property value to |value|, | 394 // Requests that the remote object change the property value to |value|, |
386 // |callback| will be called to indicate the success or failure of the | 395 // |callback| will be called to indicate the success or failure of the |
387 // request, however the new value may not be available depending on the | 396 // request, however the new value may not be available depending on the |
388 // remote object. | 397 // remote object. |
389 virtual void Set(const T& value, dbus::PropertySet::SetCallback callback) { | 398 virtual void Set(const T& value, dbus::PropertySet::SetCallback callback) { |
390 set_value_ = value; | 399 set_value_ = value; |
391 property_set()->Set(this, callback); | 400 property_set()->Set(this, callback); |
392 } | 401 } |
393 | 402 |
394 // The sychronous version of Set(). | 403 // The synchronous version of Set(). |
395 virtual bool SetAndBlock(const T& value) { | 404 virtual bool SetAndBlock(const T& value) { |
396 set_value_ = value; | 405 set_value_ = value; |
397 return property_set()->SetAndBlock(this); | 406 return property_set()->SetAndBlock(this); |
398 } | 407 } |
399 | 408 |
400 // Method used by PropertySet to retrieve the value from a MessageReader, | 409 // Method used by PropertySet to retrieve the value from a MessageReader, |
401 // no knowledge of the contained type is required, this method returns | 410 // no knowledge of the contained type is required, this method returns |
402 // true if its expected type was found, false if not. | 411 // true if its expected type was found, false if not. |
403 bool PopValueFromReader(MessageReader* reader) override; | 412 bool PopValueFromReader(MessageReader* reader) override; |
404 | 413 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: | 602 Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: |
594 AppendSetValueToWriter(MessageWriter* writer); | 603 AppendSetValueToWriter(MessageWriter* writer); |
595 extern template class CHROME_DBUS_EXPORT | 604 extern template class CHROME_DBUS_EXPORT |
596 Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; | 605 Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; |
597 | 606 |
598 #pragma GCC diagnostic pop | 607 #pragma GCC diagnostic pop |
599 | 608 |
600 } // namespace dbus | 609 } // namespace dbus |
601 | 610 |
602 #endif // DBUS_PROPERTY_H_ | 611 #endif // DBUS_PROPERTY_H_ |
OLD | NEW |