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 <memory> |
11 #include <set> | 12 #include <set> |
12 #include <string> | 13 #include <string> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | |
19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "dbus/dbus_export.h" | 21 #include "dbus/dbus_export.h" |
22 #include "dbus/object_path.h" | 22 #include "dbus/object_path.h" |
23 | 23 |
24 namespace dbus { | 24 namespace dbus { |
25 | 25 |
26 class Bus; | 26 class Bus; |
27 class ErrorResponse; | 27 class ErrorResponse; |
28 class MethodCall; | 28 class MethodCall; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // - the signal name. | 91 // - the signal name. |
92 // - whether it was successful or not. | 92 // - whether it was successful or not. |
93 typedef base::Callback<void (const std::string&, const std::string&, bool)> | 93 typedef base::Callback<void (const std::string&, const std::string&, bool)> |
94 OnConnectedCallback; | 94 OnConnectedCallback; |
95 | 95 |
96 // Calls the method of the remote object and blocks until the response | 96 // Calls the method of the remote object and blocks until the response |
97 // is returned. Returns NULL on error with the error details specified | 97 // is returned. Returns NULL on error with the error details specified |
98 // in the |error| object. | 98 // in the |error| object. |
99 // | 99 // |
100 // BLOCKING CALL. | 100 // BLOCKING CALL. |
101 virtual scoped_ptr<Response> CallMethodAndBlockWithErrorDetails( | 101 virtual std::unique_ptr<Response> CallMethodAndBlockWithErrorDetails( |
102 MethodCall* method_call, | 102 MethodCall* method_call, |
103 int timeout_ms, | 103 int timeout_ms, |
104 ScopedDBusError* error); | 104 ScopedDBusError* error); |
105 | 105 |
106 // Calls the method of the remote object and blocks until the response | 106 // Calls the method of the remote object and blocks until the response |
107 // is returned. Returns NULL on error. | 107 // is returned. Returns NULL on error. |
108 // | 108 // |
109 // BLOCKING CALL. | 109 // BLOCKING CALL. |
110 virtual scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call, | 110 virtual std::unique_ptr<Response> CallMethodAndBlock(MethodCall* method_call, |
111 int timeout_ms); | 111 int timeout_ms); |
112 | 112 |
113 // Requests to call the method of the remote object. | 113 // Requests to call the method of the remote object. |
114 // | 114 // |
115 // |callback| will be called in the origin thread, once the method call | 115 // |callback| will be called in the origin thread, once the method call |
116 // is complete. As it's called in the origin thread, |callback| can | 116 // is complete. As it's called in the origin thread, |callback| can |
117 // safely reference objects in the origin thread (i.e. UI thread in most | 117 // safely reference objects in the origin thread (i.e. UI thread in most |
118 // cases). If the caller is not interested in the response from the | 118 // cases). If the caller is not interested in the response from the |
119 // method (i.e. calling a method that does not return a value), | 119 // method (i.e. calling a method that does not return a value), |
120 // EmptyResponseCallback() can be passed to the |callback| parameter. | 120 // EmptyResponseCallback() can be passed to the |callback| parameter. |
121 // | 121 // |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 bool AddMatchRuleWithoutCallback(const std::string& match_rule, | 283 bool AddMatchRuleWithoutCallback(const std::string& match_rule, |
284 const std::string& absolute_signal_name); | 284 const std::string& absolute_signal_name); |
285 | 285 |
286 // Calls D-Bus's GetNameOwner method synchronously to update | 286 // Calls D-Bus's GetNameOwner method synchronously to update |
287 // |service_name_owner_| with the current owner of |service_name_|. | 287 // |service_name_owner_| with the current owner of |service_name_|. |
288 // | 288 // |
289 // BLOCKING CALL. | 289 // BLOCKING CALL. |
290 void UpdateNameOwnerAndBlock(); | 290 void UpdateNameOwnerAndBlock(); |
291 | 291 |
292 // Handles NameOwnerChanged signal from D-Bus's special message bus. | 292 // Handles NameOwnerChanged signal from D-Bus's special message bus. |
293 DBusHandlerResult HandleNameOwnerChanged(scoped_ptr<dbus::Signal> signal); | 293 DBusHandlerResult HandleNameOwnerChanged( |
| 294 std::unique_ptr<dbus::Signal> signal); |
294 | 295 |
295 // Runs |name_owner_changed_callback_|. | 296 // Runs |name_owner_changed_callback_|. |
296 void RunNameOwnerChangedCallback(const std::string& old_owner, | 297 void RunNameOwnerChangedCallback(const std::string& old_owner, |
297 const std::string& new_owner); | 298 const std::string& new_owner); |
298 | 299 |
299 // Runs |wait_for_service_to_be_available_callbacks_|. | 300 // Runs |wait_for_service_to_be_available_callbacks_|. |
300 void RunWaitForServiceToBeAvailableCallbacks(bool service_is_available); | 301 void RunWaitForServiceToBeAvailableCallbacks(bool service_is_available); |
301 | 302 |
302 scoped_refptr<Bus> bus_; | 303 scoped_refptr<Bus> bus_; |
303 std::string service_name_; | 304 std::string service_name_; |
(...skipping 19 matching lines...) Expand all Loading... |
323 std::string service_name_owner_; | 324 std::string service_name_owner_; |
324 | 325 |
325 std::set<DBusPendingCall*> pending_calls_; | 326 std::set<DBusPendingCall*> pending_calls_; |
326 | 327 |
327 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); | 328 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); |
328 }; | 329 }; |
329 | 330 |
330 } // namespace dbus | 331 } // namespace dbus |
331 | 332 |
332 #endif // DBUS_OBJECT_PROXY_H_ | 333 #endif // DBUS_OBJECT_PROXY_H_ |
OLD | NEW |