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> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 OnExportedCallback; | 59 OnExportedCallback; |
60 | 60 |
61 // Exports the method specified by |interface_name| and |method_name|, | 61 // Exports the method specified by |interface_name| and |method_name|, |
62 // and blocks until exporting is done. Returns true on success. | 62 // and blocks until exporting is done. Returns true on success. |
63 // | 63 // |
64 // |method_call_callback| will be called in the origin thread, when the | 64 // |method_call_callback| will be called in the origin thread, when the |
65 // exported method is called. As it's called in the origin thread, | 65 // exported method is called. As it's called in the origin thread, |
66 // |method_callback| can safely reference objects in the origin thread | 66 // |method_callback| can safely reference objects in the origin thread |
67 // (i.e. UI thread in most cases). | 67 // (i.e. UI thread in most cases). |
68 // | 68 // |
| 69 // IMPORTANT NOTE: You should export all methods before requesting a |
| 70 // service name by Bus::RequestOwnership/AndBlock(). If you do it in the |
| 71 // wrong order (i.e. request a service name then export methods), there |
| 72 // will be a short time period where your service is unable to respond to |
| 73 // method calls because these methods aren't yet exposed. This race is a |
| 74 // real problem as clients may start calling methods of your service as |
| 75 // soon as you acquire a service name, by watching the name owner change. |
| 76 // |
69 // BLOCKING CALL. | 77 // BLOCKING CALL. |
70 virtual bool ExportMethodAndBlock(const std::string& interface_name, | 78 virtual bool ExportMethodAndBlock(const std::string& interface_name, |
71 const std::string& method_name, | 79 const std::string& method_name, |
72 MethodCallCallback method_call_callback); | 80 MethodCallCallback method_call_callback); |
73 | 81 |
74 // Requests to export the method specified by |interface_name| and | 82 // Requests to export the method specified by |interface_name| and |
75 // |method_name|. See Also ExportMethodAndBlock(). | 83 // |method_name|. See Also ExportMethodAndBlock(). |
76 // | 84 // |
77 // |on_exported_callback| is called when the method is exported or | 85 // |on_exported_callback| is called when the method is exported or |
78 // failed to be exported, in the origin thread. | 86 // failed to be exported, in the origin thread. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 171 |
164 // The method table where keys are absolute method names (i.e. interface | 172 // The method table where keys are absolute method names (i.e. interface |
165 // name + method name), and values are the corresponding callbacks. | 173 // name + method name), and values are the corresponding callbacks. |
166 typedef std::map<std::string, MethodCallCallback> MethodTable; | 174 typedef std::map<std::string, MethodCallCallback> MethodTable; |
167 MethodTable method_table_; | 175 MethodTable method_table_; |
168 }; | 176 }; |
169 | 177 |
170 } // namespace dbus | 178 } // namespace dbus |
171 | 179 |
172 #endif // DBUS_EXPORTED_OBJECT_H_ | 180 #endif // DBUS_EXPORTED_OBJECT_H_ |
OLD | NEW |