| 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_OBJECT_PROXY_H_ | 5 #ifndef DBUS_OBJECT_PROXY_H_ |
| 6 #define DBUS_OBJECT_PROXY_H_ | 6 #define DBUS_OBJECT_PROXY_H_ |
| 7 | 7 |
| 8 #include <dbus/dbus.h> | 8 #include <dbus/dbus.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "dbus/dbus_export.h" | 19 #include "dbus/dbus_export.h" |
| 20 #include "dbus/object_path.h" | 20 #include "dbus/object_path.h" |
| 21 | 21 |
| 22 namespace dbus { | 22 namespace dbus { |
| 23 | 23 |
| 24 class Bus; | 24 class Bus; |
| 25 class ErrorResponse; | 25 class ErrorResponse; |
| 26 class MethodCall; | 26 class MethodCall; |
| 27 class Response; | 27 class Response; |
| 28 class ScopedDBusError; |
| 28 class Signal; | 29 class Signal; |
| 29 | 30 |
| 30 // ObjectProxy is used to communicate with remote objects, mainly for | 31 // ObjectProxy is used to communicate with remote objects, mainly for |
| 31 // calling methods of these objects. | 32 // calling methods of these objects. |
| 32 // | 33 // |
| 33 // ObjectProxy is a ref counted object, to ensure that |this| of the | 34 // ObjectProxy is a ref counted object, to ensure that |this| of the |
| 34 // object is is alive when callbacks referencing |this| are called; the | 35 // object is alive when callbacks referencing |this| are called; the |
| 35 // bus always holds at least one of those references so object proxies | 36 // bus always holds at least one of those references so object proxies |
| 36 // always last as long as the bus that created them. | 37 // always last as long as the bus that created them. |
| 37 class CHROME_DBUS_EXPORT ObjectProxy | 38 class CHROME_DBUS_EXPORT ObjectProxy |
| 38 : public base::RefCountedThreadSafe<ObjectProxy> { | 39 : public base::RefCountedThreadSafe<ObjectProxy> { |
| 39 public: | 40 public: |
| 40 // Client code should use Bus::GetObjectProxy() or | 41 // Client code should use Bus::GetObjectProxy() or |
| 41 // Bus::GetObjectProxyWithOptions() instead of this constructor. | 42 // Bus::GetObjectProxyWithOptions() instead of this constructor. |
| 42 ObjectProxy(Bus* bus, | 43 ObjectProxy(Bus* bus, |
| 43 const std::string& service_name, | 44 const std::string& service_name, |
| 44 const ObjectPath& object_path, | 45 const ObjectPath& object_path, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 85 |
| 85 // Called when the object proxy is connected to the signal. | 86 // Called when the object proxy is connected to the signal. |
| 86 // Parameters: | 87 // Parameters: |
| 87 // - the interface name. | 88 // - the interface name. |
| 88 // - the signal name. | 89 // - the signal name. |
| 89 // - whether it was successful or not. | 90 // - whether it was successful or not. |
| 90 typedef base::Callback<void (const std::string&, const std::string&, bool)> | 91 typedef base::Callback<void (const std::string&, const std::string&, bool)> |
| 91 OnConnectedCallback; | 92 OnConnectedCallback; |
| 92 | 93 |
| 93 // Calls the method of the remote object and blocks until the response | 94 // Calls the method of the remote object and blocks until the response |
| 95 // is returned. Returns NULL on error with the error details specified |
| 96 // in the |error| object. |
| 97 // |
| 98 // BLOCKING CALL. |
| 99 virtual scoped_ptr<Response> CallMethodAndBlockWithErrorDetails( |
| 100 MethodCall* method_call, |
| 101 int timeout_ms, |
| 102 ScopedDBusError* error); |
| 103 |
| 104 // Calls the method of the remote object and blocks until the response |
| 94 // is returned. Returns NULL on error. | 105 // is returned. Returns NULL on error. |
| 95 // | 106 // |
| 96 // BLOCKING CALL. | 107 // BLOCKING CALL. |
| 97 virtual scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call, | 108 virtual scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call, |
| 98 int timeout_ms); | 109 int timeout_ms); |
| 99 | 110 |
| 100 // Requests to call the method of the remote object. | 111 // Requests to call the method of the remote object. |
| 101 // | 112 // |
| 102 // |callback| will be called in the origin thread, once the method call | 113 // |callback| will be called in the origin thread, once the method call |
| 103 // is complete. As it's called in the origin thread, |callback| can | 114 // is complete. As it's called in the origin thread, |callback| can |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 NameOwnerChangedCallback name_owner_changed_callback_; | 309 NameOwnerChangedCallback name_owner_changed_callback_; |
| 299 | 310 |
| 300 // Called when the service becomes available. | 311 // Called when the service becomes available. |
| 301 std::vector<WaitForServiceToBeAvailableCallback> | 312 std::vector<WaitForServiceToBeAvailableCallback> |
| 302 wait_for_service_to_be_available_callbacks_; | 313 wait_for_service_to_be_available_callbacks_; |
| 303 | 314 |
| 304 std::set<std::string> match_rules_; | 315 std::set<std::string> match_rules_; |
| 305 | 316 |
| 306 const bool ignore_service_unknown_errors_; | 317 const bool ignore_service_unknown_errors_; |
| 307 | 318 |
| 308 // Known name owner of the well-known bus name represnted by |service_name_|. | 319 // Known name owner of the well-known bus name represented by |service_name_|. |
| 309 std::string service_name_owner_; | 320 std::string service_name_owner_; |
| 310 | 321 |
| 311 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); | 322 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); |
| 312 }; | 323 }; |
| 313 | 324 |
| 314 } // namespace dbus | 325 } // namespace dbus |
| 315 | 326 |
| 316 #endif // DBUS_OBJECT_PROXY_H_ | 327 #endif // DBUS_OBJECT_PROXY_H_ |
| OLD | NEW |