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_EXPORTED_OBJECT_H_ | 5 #ifndef DBUS_EXPORTED_OBJECT_H_ |
6 #define DBUS_EXPORTED_OBJECT_H_ | 6 #define DBUS_EXPORTED_OBJECT_H_ |
7 | 7 |
8 #include <dbus/dbus.h> | 8 #include <dbus/dbus.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "dbus/dbus_export.h" |
19 #include "dbus/object_path.h" | 20 #include "dbus/object_path.h" |
20 | 21 |
21 namespace dbus { | 22 namespace dbus { |
22 | 23 |
23 class Bus; | 24 class Bus; |
24 class MethodCall; | 25 class MethodCall; |
25 class Response; | 26 class Response; |
26 class Signal; | 27 class Signal; |
27 | 28 |
28 // ExportedObject is used to export objects and methods to other D-Bus | 29 // ExportedObject is used to export objects and methods to other D-Bus |
29 // clients. | 30 // clients. |
30 // | 31 // |
31 // ExportedObject is a ref counted object, to ensure that |this| of the | 32 // ExportedObject is a ref counted object, to ensure that |this| of the |
32 // object is alive when callbacks referencing |this| are called. | 33 // object is alive when callbacks referencing |this| are called. |
33 class ExportedObject : public base::RefCountedThreadSafe<ExportedObject> { | 34 class CHROME_DBUS_EXPORT ExportedObject |
| 35 : public base::RefCountedThreadSafe<ExportedObject> { |
34 public: | 36 public: |
35 // Client code should use Bus::GetExportedObject() instead of this | 37 // Client code should use Bus::GetExportedObject() instead of this |
36 // constructor. | 38 // constructor. |
37 ExportedObject(Bus* bus, const ObjectPath& object_path); | 39 ExportedObject(Bus* bus, const ObjectPath& object_path); |
38 | 40 |
39 // Called to send a response from an exported method. Response* is the | 41 // Called to send a response from an exported method. Response* is the |
40 // response message. Callers should pass a NULL Response* in the event | 42 // response message. Callers should pass a NULL Response* in the event |
41 // of an error that prevents the sending of a response. | 43 // of an error that prevents the sending of a response. |
42 typedef base::Callback<void (Response*)> ResponseSender; | 44 typedef base::Callback<void (Response*)> ResponseSender; |
43 | 45 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 161 |
160 // The method table where keys are absolute method names (i.e. interface | 162 // The method table where keys are absolute method names (i.e. interface |
161 // name + method name), and values are the corresponding callbacks. | 163 // name + method name), and values are the corresponding callbacks. |
162 typedef std::map<std::string, MethodCallCallback> MethodTable; | 164 typedef std::map<std::string, MethodCallCallback> MethodTable; |
163 MethodTable method_table_; | 165 MethodTable method_table_; |
164 }; | 166 }; |
165 | 167 |
166 } // namespace dbus | 168 } // namespace dbus |
167 | 169 |
168 #endif // DBUS_EXPORTED_OBJECT_H_ | 170 #endif // DBUS_EXPORTED_OBJECT_H_ |
OLD | NEW |